background image

Customizing JAXB Bindings

<< Building and Running the Example | Why Customize >>
<< Building and Running the Example | Why Customize >>

Customizing JAXB Bindings

3. Select the unmarshal-validate folder.
4. Select the Open as Main Project check box.
5. Click Open Project Folder.
6. Right-click the unmarshal-validate project and select Run Project.
Building and Running the Unmarshal Validate Example Using Ant
To compile and run the Unmarshal Validate example using Ant, in a terminal window, go to
the tut-install/javaeetutorial5/examples/jaxb/unmarshal-validate/ directory and type
the following:
ant runapp
Customizing JAXB Bindings
The next part of this chapter describes several examples that build on the concepts
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
Unlike the examples in
"Basic JAXB Examples" on page 511
, which focus on the Java code in the
respective Main.java class files, the examples here focus on customizations made to the XML
schema before generating the schema-derived Java binding classes.
Note ­
Although JAXB binding customizations must currently be made by hand, it is envisioned
that a tool/wizard might eventually be written by Sun or a third party to make this process more
automatic. One of the goals of the JAXB technology is to standardize the format of binding
declarations, thereby making 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, refer to the
JAXB Specification
(http://jcp.org/en/jsr/detail?id=222)
.
Customizing JAXB Bindings
The Java EE 5 Tutorial · September 2007
514