background image

Fix Collides Example

<< Namespace Declarations | The example.xsd Schema >>
<< Namespace Declarations | The example.xsd Schema >>
F
IX
C
OLLIDES
E
XAMPLE
59
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
complex-
Type
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.
Fix Collides Example
The Fix Collides example illustrates how to resolve name conflicts--that is,
places in which a declaration in a source schema uses the same name as another
declaration in that schema (namespace collisions), or places in which a declara-
tion uses a name that does translate by default to a legal Java name.