background image

Inline and External Customizations

<< Why Customize | Binding Customization File Format >>
<< Why Customize | Binding Customization File Format >>

Inline and External Customizations

Inline and External Customizations
Customizations to the default JAXB bindings are made in the form of binding declarations
passed to the JAXB binding compiler. These binding declarations can be made in either of two
ways:
As inline annotations in a source XML schema
As declarations in an external binding customizations file
For some people, using inline customizations is easier because you can see your customizations
in the context of the schema to which they apply. Conversely, using an external binding
customization file enables you to customize JAXB bindings without having to modify the source
schema, and enables you to easily apply customizations to several schema files at once.
Note ­
You can combine the two types of customizations. For example, you could include a
reference to an external binding customizations file in an inline annotation. However, you
cannot declare both an inline and external customization on the same schema element.
Each of these types of customization is described in more detail below.
Inline Customizations
Customizations to JAXB bindings made by means of inline binding declarations in an XML
schema file take the form of <xsd:appinfo> elements embedded in schema <xsd:annotation>
elements (xsd: is the XML schema namespace prefix, as defined in W3C XML Schema Part 1:
Structures). The general form for inline customizations is shown below.
<xs:annotation>
<xs:appinfo>
.
.
binding declarations
.
.
</xs:appinfo>
</xs:annotation>
Customizations are applied at the location at which they are declared in the schema. For
example, a declaration at the level of a particular element would apply to that element only.
Note that the XMLSchema namespace prefix must be used with the <annotation> and
<appinfo>
declaration tags. In the example above, xs: is used as the namespace prefix, so the
declarations are tagged <xs:annotation> and <xs:appinfo>.
External Binding Customization Files
Customizations to JAXB bindings made by means of an external file containing binding
declarations take the general form shown below.
Customizing JAXB Bindings
The Java EE 5 Tutorial · September 2007
516