background image

Class Declarations

<< Schema Name and Schema Node | External Customize Example >>
<< Schema Name and Schema Node | External Customize Example >>

Class Declarations

<jxb:schemaBindings>
...
binding-declarations
...
</jxb:schemaBindings>
</xsd:appinfo>
</xsd:annotation>
Class Declarations
The class-level binding declarations in bindings.xjb differ from the analogous declarations in
po.xsd
for the Datatype Converter example in two ways:
As with all other binding declarations in bindings.xjb, you do not need to embed your
customizations in schema <xsd:appinfo> elements.
You must specify the schema node to which the customization will be applied. The general
syntax for this type of declaration is:
<jxb:bindings node=
"//node-type[@name='node-name']">
For example, the following code shows binding declarations for the complexType named
USAddress
.
<jxb:bindings node=
"//xs:complexType[@name='USAddress']">
<jxb:class>
<jxb:javadoc>
<![CDATA[First line of documentation for a <b>USAddress</b>.]]>
</jxb:javadoc>
</jxb:class>
<jxb:bindings node=
".//xs:element[@name='name']">
<jxb:property name=
"toName"/>
</jxb:bindings>
<jxb:bindings node=
".//xs:element[@name='zip']">
<jxb:property name=
"zipCode"/>
</jxb:bindings>
</jxb:bindings>
<!-- node=
"//xs:complexType[@name='USAddress']" -->
Note in this example that USAddress is the parent of the child elements name and zip, and
therefore a </jxb:bindings> tag encloses the bindings declarations for the child elements as
well as the class-level javadoc declaration.
Customizing JAXB Bindings
Chapter 17 · Binding between XML Schema and Java Classes
535