Default Binding Rules
The default binding rules are inspiried by the JAXB specification. Though, there are some differences that are pointed out in specific sections. Also, the documentation describes only those rules that are actually implemented. It's possible that mappings that are not covered here are actually not implemented.
Schema To Java Binding
Simple types
An element of a simple type can only contain character data, no attributes and no child elements. By default, elements of simple types are bound to Java properties/fields. But before the property value is set, delivered by the XML parser element's value as a string should be converted to an appropriate Java type. The appropriate Java type is determined by the XML simple type. Simple types can be categorized as schema built-in types and user-derived types.
Schema Built-in Types
Schema built-in types are mapped to Java types as shown in the following table:
XML Schema Type | Java 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{FOOTNOTE DEF } |
xsd:hexBinary | byte{FOOTNOTE DEF } |
xsd:unsignedInt | long |
xsd:unsignedShort | int |
xsd:unsignedByte | short |
xsd:time | java.util.Calendar |
xsd:date | java.util.Calendar |
xsd:g | java.util.Calendar |
xsd:anySimpleType | java.lang.String |
xsd:duration | javax.xml.datatype.Duration |
xsd:NOTATION | javax.xml.namespace.QName |
NOTE: this table looks the same in JAXB2.0 except that instead of java.util.Calendar the JAXB spec uses javax.xml.datatype.XMLGregorianCalendar which is defined in JAXP1.3 and available in JDK1.5. This incompatability will be addressed in the future.
User-derived types
Values of user-derived types are usually not converted and passed as-is, i.e. as java.lang.String values.
NOTE: currently, we don't even look at the extended type. This should be fixed in the future.
Complex types
By default, global complex types are bound to Java classes based on their names. I.e. the package of the Java class is generated based on the namespace URI of the complex type following the JAXB2.0, section D5 Generating a Java package name. The class name is generated based on the local part of the complex type QName with the algorithm defined by the JAXB2.0 in section D.2 The Name to Identifier Mapping Algorithm.
Anonymous complex types are bound to class based on the QName of the element the type is defined in using the same JAXB2.0 algorithms to generate package and class names as in the case of global complex types.
Note, JAXB2.0 also defines how outer class names are generated for anonymous complex types (based on the scope of the element declaration). Here, we currently don't use this approach. I.e. anonymous complex types are bound to Java classes only based on the QName of the element despite what the element's scope is.
Simple content
Like in JAXB2.0 spec, simple content is bound to a property with name 'value'.
Attributes
By default, an attribute is bound to a Java property applying Name to Java Identifier Mapping Algorithm as defined in the JAXB2.0 spec to attribute's name. Note, global attribute to constant binding is not supported currently.
Elements
By default, an element is bound to a Java property applying Name to Java Identifier Mapping Algorithm as defined in the JAXB2.0 spec to element's name.
Comments