Tai-Wei Lin's article "JavaTM Architecture for XML Binding (JAXB): A
Primer" introduces developers to the basics of JAXB Early Access
Implementation v 1.0. Lin provides brief explanations on how to create
simple binding codes using the API and tools. Also discussed are a few
situations where JAXB shows its strengths.
JAXB provides an API and tool that allows automatic two-way mapping
between XML documents and JavaTM technology objects. With a given
Document Type Definition (DTD) and a schema definition, the JAXB
compiler can generate a set of JavaTM Foundation Classes that allow
developers to build applications that can read, manipulate and recreate
XML documents without writing any logic to process XML elements. The
generated codes provide an abstraction layer by exposing a public
interface that allows access to the XML data without any specific
knowledge of the underlying data structure. In addition to DTD
support, future versions of JAXB will add support for other schema
languages, such as the W3C XML Schema. These features enable the JAXB
to provide many benefits for the developers, which are further
explained in the next section.
Lin also discusses the benefits and uses of JAXB, such as manipulating
data in memory and working with valid data that conforms with DTD and
binding schema.
Also covered are the Java API for XML Processing (JAXP) and the options
it provides developers. Different features that JAXB and JAXP offer can
empower developers to have the option to choose the best API to fit
their needs.
Lin provides step-by-step instruction as a jump start on the basics of
using the JAXB API. An implementation of the JAXB API can be
downloaded from the official JAXB page.
There are examples and code samples available online:
- Code Sample 1: Sample XML for the price list example
- Code Sample 2: A simple DTD for item list example: item.dtd
- Code Sample 3: A minimal binding schema: item.xjs
Other topics include:
- Generate Processing Codes
- Unmarshal from an XML Document
- Instantiation
- Work with Data
- Validation
- Marshal to a XML document
For additional technical details and code samples:
http://developer.java.sun.com/developer/technicalArticles/xml/jaxb
Read More ...
[...read more...]