background image

Schema Name and Schema Node

<< Binding Declaration Files | Class Declarations >>
<< Binding Declaration Files | Class Declarations >>

Schema Name and Schema Node

Schema Name and Schema Node
The fourth line of the code in
"JAXB Version, Namespace, and Schema Attributes" on page 533
specifies the name of the schema to which this binding declarations file will apply, and the
schema node at which the customizations will first take effect. Subsequent binding declarations
in this file will reference specific nodes within the schema, but this first declaration should
encompass the schema as a whole; for example, in bindings.xjb:
<jxb:bindings schemaLocation=
"po.xsd" node="/xs:schema">
Global and Schema Binding Declarations
The global schema binding declarations in bindings.xjb are the same as those in po.xsd for
the Datatype Converter example. The only difference is that because the declarations in po.xsd
are made inline, you need to embed them in <xs:appinfo> elements, which are in turn
embedded in <xs:annotation> elements. Embedding declarations in this way is unnecessary in
the external bindings file.
<jxb:globalBindings
fixedAttributeAsConstantProperty=
"true"
collectionType=
"java.util.Vector"
typesafeEnumBase=
"xs:NCName"
choiceContentProperty=
"false"
typesafeEnumMemberName=
"generateError"
bindingStyle=
"elementBinding"
enableFailFastCheck=
"false"
generateIsSetMethod=
"false"
underscoreBinding=
"asCharInWord"/>
<jxb:schemaBindings>
<jxb:package name=
"primer.myPo">
<jxb:javadoc>
<![CDATA[<body>Package level documentation for generated package primer.myPo.</body>]]>
</jxb:javadoc>
</jxb:package>
<jxb:nameXmlTransform>
<jxb:elementName suffix=
"Element"/>
</jxb:nameXmlTransform>
</jxb:schemaBindings>
By comparison, the syntax used in po.xsd for the Datatype Converter example is:
<xsd:annotation>
<xsd:appinfo>
<jxb:globalBindings
...
binding-declarations
...
Customizing JAXB Bindings
The Java EE 5 Tutorial · September 2007
534