aspose file tools*
The moose likes XML and Related Technologies and the fly likes JAXB2 : Generate Java interface out of a xsd element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXB2 : Generate Java interface out of a xsd element" Watch "JAXB2 : Generate Java interface out of a xsd element" New topic
Author

JAXB2 : Generate Java interface out of a xsd element

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9317
    
109

I have been trying some examples of JAXB2.0 for converting xsd to Java objects. My goal is to generate a java "interface" out of a xsd element.

I am following the JavaEE5 tutorial http://java.sun.com/javaee/5/docs/tutorial/doc/bnbbf.html. Section "Class Binding Declarations" says this:

The <class> binding declaration enables you to customize the binding of a schema element to a Java content interface or a Java Element interface. <class> declarations can be used to customize:

* A name for a schema-derived Java interface
* An implementation class for a schema-derived Java content interface

The syntax for <class> customizations is:


* name is the name of the derived Java interface. It must be a legal Java interface name and must not contain a package prefix. The package prefix is inherited from the current value of package.
* implClass is the name of the implementation class for className and must include the complete package name.
* The <javadoc> element specifies the Javadoc tool annotations for the schema-derived Java interface. The string entered here must use CDATA or < to escape embedded HTML tags.




So it does mention that given a xsd schema element, i can generate a Java interface for the element by using something like this:




However when i use the xjc command (and even the XJCTask Ant task), it generates POType as a "class" instead of an interface:


I have been trying various things to get this working, but have failed to do so. To make sure, i understood the tutorial right, i even looked at the xsd for jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd which says this:


So am i doing something wrong here?



[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAXB2 : Generate Java interface out of a xsd element
 
Similar Threads
Baffled by castor and JavaDoc
UnmarshalException:
question - "all" group
xjc:superClass limitation in JAXB
namespace doubt