Customizing JAXB Bindings
C
USTOMIZING
JAXB B
INDINGS
35
Customizing JAXB Bindings
The remainder of this chapter describes several examples that build on the con-
cepts demonstrated in the basic examples.
The goal of this section is to illustrate how to customize JAXB bindings by
means of custom binding declarations made in either of two ways:
· As annotations made inline in an XML schema
· As statements in an external file passed to the JAXB binding compiler
Main.java
class files, the examples here focus on customiza-
tions made to the XML schema before generating the schema-derived Java bind-
ing classes.
Note: Although JAXB binding customizations must currently be made by hand, it
is envisioned that a tool/wizard may eventually be written by Sun or a third party to
make this process more automatic and easier in general. One of the goals of the
JAXB technology is to standardize the format of binding declarations, thereby mak-
ing it possible to create customization tools and to provide a standard interchange
format between JAXB implementations.
This section just begins to scratch the surface of customizations you can make to
JAXB bindings and validation methods. For more information, please refer to
the JAXB Specification (
Why Customize?
In most cases, the default bindings generated by the JAXB binding compiler will
be sufficient to meet your needs. There are cases, however, in which you may
want to modify the default bindings. Some of these include:
· Creating API documentation for the schema-derived JAXB packages,
classes, methods and constants; by adding custom Javadoc tool annota-
tions to your schemas, you can explain concepts, guidelines, and rules spe-
cific to your implementation.
· Providing semantically meaningful customized names for cases that the
default XML name-to-Java identifier mapping cannot handle automati-
cally; for example: