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.

Binding Declaration Files<br />

<strong>The</strong> following sections provide information about binding declaration files:<br />

■ “JAXB Version, Namespace, and Schema Attributes” on page 531<br />

■ “Global and Schema Binding Declarations” on page 532<br />

■ “Class Declarations” on page 533<br />

JAXBVersion, Namespace, and Schema Attributes<br />

All JAXB binding declarations files must begin with:<br />

■ JAXB version number<br />

■ Namespace declarations<br />

■ Schema name and node<br />

<strong>The</strong> version, namespace, and schema declarations in bindings.xjb are as follows:<br />

<br />

<br />

...<br />

binding-declarations ...<br />

<br />

<br />

<br />

JAXBVersion Number<br />

An XML file with a root element of is considered an external binding file. <strong>The</strong><br />

root element must specify the JAXB version attribute with which its binding declarations must<br />

comply; specifically the root element must contain either a <br />

declaration or a version attribute. By contrast, when making binding declarations inline, the<br />

JAXB version number is made as attribute of the declaration:<br />

<br />

Namespace Declarations<br />

Customizing JAXB Bindings<br />

As shown in “JAXB Version, Namespace, and Schema Attributes” on page 531, the namespace<br />

declarations in the external binding declarations file include both the JAXB namespace and the<br />

XMLSchema namespace. Note that the prefixes used in this example could in fact be anything<br />

you want; the important thing is to consistently use whatever prefixes you define here in<br />

subsequent declarations in the file.<br />

Chapter 17 • Binding between XML Schema and <strong>Java</strong> Classes 531

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

Saved successfully!

Ooh no, something went wrong!