background image

Binding Customization File Format

<< Inline and External Customizations | Restrictions for External Binding Customizations >>
<< Inline and External Customizations | Restrictions for External Binding Customizations >>

Binding Customization File Format

<jxb:bindings schemaLocation =
"xs:anyURI">
<jxb:bindings node =
"xs:string">*
<binding declaration>
<jxb:bindings>
</jxb:bindings>
schemaLocation
is a URI reference to the remote schema.
node
is an XPath 1.0 expression that identifies the schema node within schemaLocation to
which the given binding declaration is associated.
For example, the first schemaLocation/node declaration in a JAXB binding declarations file
specifies the schema name and the root schema node:
<jxb:bindings schemaLocation=
"po.xsd" node="/xs:schema">
A subsequent schemaLocation/node declaration, say for a simpleType element named
ZipCodeType
in the above schema, would take the form:
<jxb:bindings node=
"//xs:simpleType[@name='ZipCodeType']">
Binding Customization File Format
Binding customization files should be straight ASCII text. The name or extension does not
matter, although a typical extension, used in this chapter, is .xjb.
Passing Customization Files to the JAXB Binding Compiler
Customization files containing binding declarations are passed to the JAXB Binding compiler,
xjc
, using the following syntax:
xjc -b
file schema
where file is the name of binding customization file, and schema is the name of the schema or
schemas you want to pass to the binding compiler.
You can have a single binding file that contains customizations for multiple schemas, or you can
break the customizations into multiple bindings files; for example:
xjc schema1.xsd schema2.xsd schema3.xsd -b bindings123.xjb
xjc schema1.xsd schema2.xsd schema3.xsd -b bindings1.xjb -b bindings2.xjb -b bindings3.xjb
Note that the ordering of schema files and binding files on the command line does not matter,
although each binding customization file must be preceded by its own -b switch on the
command line.
For more information about xjc compiler options in general, see
"JAXB Compiler Options" on
page 503
.
Customizing JAXB Bindings
Chapter 17 · Binding between XML Schema and Java Classes
517