background image

JAXB Generating Classes

<< The JAXB Binding Process | More about Unmarshalling >>
<< The JAXB Binding Process | More about Unmarshalling >>

JAXB Generating Classes

The general steps in the JAXB data binding process are:
1. Generate classes: An XML schema is used as input to the JAXB binding compiler to
generate JAXB classes based on that schema.
2. Compile classes: All of the generated classes, source files, and application code must be
compiled.
3. Unmarshal: XML documents written according to the constraints in the source schema are
unmarshalled by the JAXB binding framework. Note that JAXB also supports unmarshalling
XML data from sources other than files/documents, such as DOM nodes, string buffers,
SAX Sources, and so forth.
4. Generate content tree: The unmarshalling process generates a content tree of data objects
instantiated from the generated JAXB classes; this content tree represents the structure and
content of the source XML documents.
5. Validate (optional): The unmarshalling process optionally involves validation of the source
XML documents before generating the content tree. Note that if you modify the content tree
in Step 6, below, you can also use the JAXB Validate operation to validate the changes before
marshalling the content back to an XML document.
6. Process content: The client application can modify the XML data represented by the Java
content tree by means of interfaces generated by the binding compiler.
7. Marshal: The processed content tree is marshalled out to one or more XML output
documents. The content may be validated before marshalling.
bind
Schema
JAXB
mapped
classes
Document
Objects
unmarshal
(validate)
marshal
(validate)
instances of
follows
FIGURE 17­2
Steps in the JAXB Binding Process
JAXB Architecture
Chapter 17 · Binding between XML Schema and Java Classes
491