Structure and Global Options

You’ve already seen the basic format of a binding schema. The xml-java-binding-schema element is the top-level element, and the version attribute on that element is required. Here’s the relevant entry in the binding schema DTD:[12]

<!ELEMENT xml-java-binding-schema 
          ( options?, (element | interface | enumeration | conversion)* ) >
<!ATTLIST xml-java-binding-schema
          version CDATA #FIXED "1.0ea" >

Tip

The version attribute is the declaration for the 1.0 early-access release of JAXB. As new versions come out, this value is likely to change with those versions.

Although you’ve seen the global options that JAXB provides, I want to review them briefly in this section. These options are all specified to a binding schema via the options element, which appears just within the top-level xml-java-binding-schema element. The entry for that element is shown here:

<!ELEMENT options EMPTY >
<!ATTLIST options
          package                           NMTOKEN        #IMPLIED
          default-reference-collection-type (array | list) "list"
          property-get-set-prefixes         (true | false) "true"
          marshallable                      (true | false) "true"
          unmarshallable                    (true | false) "true" >

Packaging

Setting the Java package of the generated classes is a matter of using the package attribute on the options element:

<options package="javajaxb.generated" />

You’ve already seen this in action, so little description is required. Keep in mind that this package applies for all generated classes. There is currently no option for specifying the Java package ...

Get Java & XML Data Binding now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.