JavaTM Architecture for XML Binding
JAXB RI Vendor Extensions
Customizations

Specification Version: 2.0
Reference Implementation (RI) Version: 2.0 EA

JAXB 2.0: Release Notes | XJC | XJCTask | SchemaGen | schemagenTask | Sample Apps | Changelog
JAXB 1.0.x: Release Notes | Changelog
JAXB RI Extensions: Runtime Properties | XJC Customizations | Develop Plugins
JAXB RI Schema Languages: W3C XML Schema | RELAX NG | DTD
JAXB Community: Java.net Homepage | Developer interest list | FAQ

Customizations

The JAXB RI provides additional customizations that are not defined by the JAXB specification. Note the following:

  • These features may only be used when the JAXB XJC binding compiler is run in the "-extension" mode.
  • All of the JAXB RI vendor extensions are defined in the "http://java.sun.com/xml/ns/jaxb/xjc" namespace.
  • The namespaces containing extension binding declarations are specified to a JAXB processor by the occurrence of the global attribute @jaxb:extensionBindingPrefixes within an instance of <xs:schema> element. The value of this attribute is a whitespace-separated list of namespace prefixes. For more information, please refer to section 6.1.1 of the JAXB Specification.

Index of Customizations

Extending a Common Super Class

It is also possible to specify a common superclass that all generated implementation classes will extend. Again, this customization has no effect on the generated interfaces, only the implementation classes contained in the implementation subpackages.

The <xjc:superClass> customization allows you to specify the fully qualified name of the Java class that is to be used as the superclass. Like the <xjc:serializable> customization, the <xjc:superClass> customization can only occur within your <jaxb:globalBindings> customization on the <xs:schema> element and will only be allowed when xjc is run with the "-extension" switch:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
           xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
           jaxb:extensionBindingPrefixes="xjc"
           jaxb:version="1.0">

    <xs:annotation>
       <xs:appinfo>
          <jaxb:globalBindings generateIsSetMethod="true">
           <xjc:superClass name="org.acme.RocketBooster"/>
          </jaxb:globalBindings>
       </xs:appinfo>
    </xs:annotation>
.
.
.
</xs:schema>
		

In the sample above, the <xjc:superClass> customization will cause all of the generated implementation classes to extend the named class, org.acme.RocketBooster in this case.

The org.acme.RocketBooster class must be compiled and available on your classpath prior to using the XJC binding compiler to compile your schema (use the -classpath option of the xjc command). The examples/vendor-extensions sample application shows how to use this feature.


$Revision: 1.26 $
$Date: 2005/03/29 01:52:22 $
Terms of Use; Privacy Policy; Copyright ©2013-2014 (revision 20131025.e7cbc9d)
 
 
Close
loading
Please Confirm
Close