The JAXB APIs and tools are shipped in the jaxb subdirectory of the Java WSDP. This directory contains sample applications, a JAXB binding compiler (xjc), and implementations of the runtime binding framework APIs contained in the javax.xml.bind package. For more information on binding between XML Schema and Java Classes, refer to the following tutorial: http://java.sun.com/javaee/5/docs/tutorial/doc/bnazf.html.
The following steps demonstrate ONE particular way to bind XML schemas and Java representations. Depending on your requirements, the binding process can be achieved in several different ways..
Generate JAXB classes.
An XML schema is used as input to the JAXB binding compiler to generate JAXB classes based on that schema.
Compile JAXB classes.
All of the generated classes, source files, and application code must be compiled.
Unmarshal XML documents.
XML documents written according to the constraints in the source schema are unmarshalled by the JAXB binding framework.
JAXB also supports the unmarshalling of XML data from sources other than files/documents, such as DOM nodes, string buffers, and SAX Sources.
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.
Validate source XML (optional).
The unmarshalling process optionally involves validation of the source XML documents before generating the content tree.
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.
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.
Marshal the content tree out to one or more XML output documents.
The content may be validated before marshalling.
To summarize, using JAXB involves two discrete sets of activities:
Generate and compile JAXB classes from a source schema, and build an application that implements these classes
Run the application to unmarshal, process, validate, and marshal XML content through the JAXB binding framework
These two steps are usually performed at separate times in two distinct phases. Typically, there is an application development phase in which JAXB classes are generated and compiled, with a binding implementation being built. That is followed by a deployment phase in which the generated JAXB classes are used to process XML content in an ongoing live production setting.