10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Representing XML Content<br />

More about Unmarshalling<br />

Unmarshalling provides a client application the ability to convert XML data into JAXB-derived<br />

<strong>Java</strong> objects.<br />

More about Marshalling<br />

Marshalling provides a client application the ability to convert a JAXB-derived <strong>Java</strong> object tree<br />

back into XML data.<br />

By default, the Marshaller uses UTF-8 encoding when generating XML data.<br />

Client applications are not required to validate the <strong>Java</strong> content tree before marshalling. <strong>The</strong>re<br />

is also no requirement that the <strong>Java</strong> content tree be valid with respect to its original schema to<br />

marshal it back into XML data.<br />

More aboutValidation<br />

Validation is the process of verifying that an XML document meets all the constraints expressed<br />

in the schema. JAXB 1.0 provided validation at unmarshal time and also enabled on-demand<br />

validation on a JAXB content tree. JAXB 2.0 only allows validation at unmarshal and marshal<br />

time. A web service processing model is to be lax in reading in data and strict on writing it out.<br />

To meet that model, validation was added to marshal time so one could confirm that they did<br />

not invalidate the XML document when modifying the document in JAXB form.<br />

Representing XML Content<br />

490<br />

This section describes how JAXB represents XML content as <strong>Java</strong> objects.<br />

<strong>Java</strong> Representation of XML Schema<br />

JAXB supports the grouping of generated classes in <strong>Java</strong> packages. A package consists of the<br />

following:<br />

■ A <strong>Java</strong> class name that is derived from the XML element name, or specified by a binding<br />

customization.<br />

■ An ObjectFactory class, which is a factory that is used to return instances of a bound <strong>Java</strong><br />

class.<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!