LibraryToggle FramesPrintFeedback

The baseType customization element's name attribute is used to redefine the class of the generated object to a class within the same Java class hierarchy. The attribute specifies the fully qualified name of the Java class to which the XML Schema construct is mapped. The specified Java class must be either a super-class or a sub-class of the Java class that the code generator normally generates for the XML Schema construct. For XML Schema primitive types that map to Java primitive types, the wrapper class is used as the default base class for the purpose of customization.

For example, an element defined as being of xsd:int uses java.lang.Integer as its default base class. The value of the name attribute can specify any super-class of Integer such as Number or Object.

[Tip]Tip

For simple type substitution, the most common customization is to map the primitive types to an Object object.

Example 15.27 shows an in-line customization that maps one element in a complex type to a Java Object object.


Example 15.28 shows an external binding file for the customization shown in Example 15.27.


The resulting Java object's @XmlElement annotation includes a type property. The value of the type property is the class object representing the generated object's default base type. In the case of XML Schema primitive types, the class is the wrapper class of the corresponding Java primitive type.

Example 15.29 shows the class generated based on the schema definition in Example 15.28.


Comments powered by Disqus
loading table of contents...