background image

Bind Choice Example

<< Resolving the Conflicts | Customization results >>
<< Resolving the Conflicts | Customization results >>
64
U
SING
JAXB
Bind Choice Example
The Bind Choice example shows how to bind a
choice
model group to a Java
interface. Like the External Customize and Fix Collides examples, the Bind
Choice example uses an external binding declarations file,
binding.xjb
, to
define the JAXB binding customization.
The schema declarations in
<INSTALL>/examples/jaxb/bind-choice
/example.xsd
that will be globally changed are highlighted in bold below.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
jxb:version="1.0">
<xs:element name="FooBar">
<xs:complexType>
<xs:sequence>
<xs:element name="foo" type="xs:int"/>
<xs:element ref="Class"/>
<xs:choice>
<xs:element name="phoneNumber" type="xs:string"/>
<xs:element name="speedDial" type="xs:int"/>
</xs:choice>
<xs:group ref="ModelGroupChoice"/>
</xs:sequence>
<xs:attribute name="zip" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:group name="ModelGroupChoice">
<xs:choice>
<xs:element name="bool" type="xs:boolean"/>
<xs:element name="comment" type="xs:string"/>
<xs:element name="value" type="xs:int"/>
</xs:choice>
</xs:group>
</xs:schema>
Customizing a choice Model Group
The
<INSTALL>/examples/jaxb/bind-choice/binding.xjb
binding declara-
tions file demonstrates one way to override the default derived names for
choice