background image

The example.xsd Schema

<< Fix Collides Example | Looking at the Conflicts >>
<< Fix Collides Example | Looking at the Conflicts >>
60
U
SING
JAXB
Note: Many name collisions can occur because XSD Part 1 introduces six unique
symbol spaces based on type, while Java only has only one. There is a symbols
space for type definitions, elements, attributes, and group definitions. As a result, a
valid XML schema can use the exact same name for both a type definition and a glo-
bal element declaration.
For the purposes of this example, it is recommended that you remove the
bind-
ing
parameter to the
xjc
task in the
build.xml
file in the
<INSTALL>/exam-
ples/jaxb/fix-collides
directory to display the error output generated by the
xjc
compiler. The XML schema for the Fix Collides,
example.xsd
, contains
deliberate name conflicts.
Like the External Customize example, the Fix Collides example uses an external
binding declarations file,
binding.xjb
, to define the JAXB binding customiza-
tions.
· The example.xsd Schema
· Looking at the Conflicts
· Output From Running the ant Task Without Using a Binding Declarations
File
· The binding.xjb Declarations File
· Resolving the Conflicts in example.xsd
The example.xsd Schema
The XML schema,
<INSTALL>/examples/jaxb/fix-collides
/example.xsd
, used in the Fix Collides example illustrates common name con-
flicts encountered when attempting to bind XML names to unique Java identifi-
ers in a Java package. The schema declarations that result in name conflicts 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="Class" type="xs:int"/>
<xs:element name="FooBar" type="FooBar"/>
<xs:complexType name="FooBar">
<xs:sequence>
<xs:element name="foo" type="xs:int"/>
<xs:element ref="Class"/>