Download FAQ History |  | API Search Feedback

> ## Binding XML Schemas

> This section describes the default XML-to-Java bindings used by JAXB. All of these bindings can be overridden on global or case-by-case levels by means of a custom binding declaration. The topics in this section are as follows:

> - Simple Type Definitions
> - Default Data Type Bindings
> - Default Binding Rules Summary

> See the JAXB Specification for complete information about the default JAXB bindings.

> ### Simple Type Definitions

> A schema component using a simple type definition typically binds to a Java property. Since there are different kinds of such schema components, the following Java property attributes (common to the schema components) include:

> - Base type
> - Collection type, if any
> - Predicate

> The rest of the Java property attributes are specified in the schema component using the `simple` type definition.

> ### Default Data Type Bindings

> The Java language provides a richer set of data type than XML schema. Table 10-3 lists the mapping of XML data types to Java data types in JAXB.

> Table 10-3 JAXB Mapping of XML Schema Built-in Data Types
> XML Schema Type | Java Data Type
> --- | ---
> `xsd:string` | `java.lang.String`
> `xsd:integer` | `java.math.BigInteger`
> `xsd:int` | `int`
> `xsd.long` | `long`
> `xsd:short` | `short`
> `xsd:decimal` | `java.math.BigDecimal`
> `xsd:float` | `float`
> `xsd:double` | `double`
> `xsd:boolean` | `boolean`
> `xsd:byte` | `byte`
> `xsd:QName` | `javax.xml.namespace.QName`
> `xsd:dateTime` | `java.util.Calendar`
> `xsd:base64Binary` | `byte[]`
> `xsd:hexBinary` | `byte[]`
> `xsd:unsignedInt` | `long`
> `xsd:unsignedShort` | `int`
> `xsd:unsignedByte` | `short`
> `xsd:time` | `java.util.Calendar`
> `xsd:date` | `java.util.Calendar`
> `xsd:anySimpleType` | `java.lang.String`

> ### Default Binding Rules Summary

> The JAXB binding model follows the default binding rules summarized below:

> - Bind the following to Java package:
> - XML Namespace URI
> - Bind the following XML Schema components to Java content interface:
> - Named complex type
> - Anonymous inlined type definition of an element declaration
> - Bind to typesafe enum class:
> - A named simple type definition with a basetype that derives from "`xsd:NCName`" and has enumeration facets.
> - Bind the following XML Schema components to a Java Element interface:
> - A global element declaration to a Element interface.
> - Local element declaration that can be inserted into a general content list.
> - Bind to Java property:
> - Attribute use
> - Particle with a term that is an element reference or local element declaration.
> - Bind model group with a repeating occurrence and complex type definitions with mixed `{content type}` to:
> - A general content property; a List content-property that holds Java instances representing element information items and character data items.

Download FAQ History |  | API Search Feedback

All of the material in The Java(TM) Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.