Tuesday, March 22, 2011

Jaxb : 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.

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 schema component using simple type definition.

Default Data Type Bindings


The Java language provides a richer set of data type than XML schema.
XML Schema TypeJava Data Type
xsd:stringjava.lang.String
xsd:integerjava.math.BigInteger
xsd:intint
xsd.longlong
xsd:shortshort
xsd:decimaljava.math.BigDecimal
xsd:floatfloat
xsd:doubledouble
xsd:booleanboolean
xsd:bytebyte
xsd:QNamejavax.xml.namespace.QName
xsd:dateTimejava.util.Calendar
xsd:base64Binarybyte[]
xsd:hexBinarybyte[]
xsd:unsignedIntlong
xsd:unsignedShortint
xsd:unsignedByteshort
xsd:timejava.util.Calendar
xsd:datejava.util.Calendar
xsd:anySimpleTypejava.lang.String


Default Binding Rules


The JAXB binding model follows the default binding rules summarized below:
FromTo
XML Namespace URIJava package
Named complex typeJava content interface
Anonymous inlined type definition of an element declarationJava content interface
A named simple type definition with a basetype that derives from "xsd:NCName" and has enumeration facetenum class
A global element declaration to a Element interfaceJava Element interface
Local element declaration that can be inserted into a general content listJava Element interface
AttributeJava property

No comments:

Post a Comment

Chitika