background image

JAXB Version Number

<< External Customize Example | Namespace Declarations >>
<< External Customize Example | Namespace Declarations >>
E
XTERNAL
C
USTOMIZE
E
XAMPLE
57
.
</jxb:bindings>
<!-- schemaLocation="po.xsd" node="/xs:schema" -->
</jxb:bindings>
JAXB Version Number
An XML file with a root element of
<jaxb:bindings>
is considered an external
binding file. The root element must specify the JAXB version attribute with
which its binding declarations must comply; specifically the root
<jxb:bind-
ings>
element must contain either a <
jxb:version>
declaration or a
version
attribute. By contrast, when making binding declarations inline, the JAXB ver-
sion number is made as attribute of the
<xsd:schema>
declaration:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
jxb:version="1.0">
Namespace Declarations
As shown in JAXB Version, Namespace, and Schema Attributes (page 56), the
namespace declarations in the external binding declarations file include both the
JAXB namespace and the XMLSchema namespace. Note that the prefixes used
in this example could in fact be anything you want; the important thing is to con-
sistently use whatever prefixes you define here in subsequent declarations in the
file.
Schema Name and Schema Node
The fourth line of the code in JAXB Version, Namespace, and Schema
Attributes (page 56)
specifies the name of the schema to which this binding dec-
larations file will apply, and the schema node at which the customizations will
first take effect. Subsequent binding declarations in this file will reference spe-
cific 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