The JAXB RI currently has experimental support for the schema languages listed on this page. The features listed on this page are not described by the JAXB Specification - they are only available in the JAXB RI.
JAXB 2.0 RI FCS will contain 100% support for W3C XML Schema. However, this is an Early Access release and is not functionally complete. This section outlines areas that the RI deviates from the JAXB 2.0 Specification Early Draft 2.
- From Section 8: Java to XML
- The specification does not specify the default property order, @XmlType.propOrder(). JAXB RI would like source code order. While source code order is working for @XmlAccessorType(AccessType.FIELD), the default @XmlAccessorType(AccessType.PROPERTY) is not following source code order, but rather Unicode code point alphabetical order. This ordering issue is still open for discussion and debate for future releases.
- The specification states that if a property or a field has been marked with @XmlValue annotation, then the containing class must not extend another class (other than java.lang.Object). The RI currently does not enforce this.
- The specification restricts @XmlJavaTypeAdapter from being placed on a package and the RI enforces this. We may reconsider allowing this in the final version.
- According to Table 8-4 in the specification "Mapping class to Complex Type Definition", when a property/field is annotated with @XmlValue annotation, the complex type to which the class maps must derived from the schema type to which the property/field annotated with @XmlValue is mapped. The RI does not currently bind this correctly.
- The RI has not fully implemented support for the Unmarshal(S4.4.1) and Marshal(S4.5.1) Callback Events from the ObjectLifeCycle interface.
- The RI has not fully implemented support for the schema customizations <inlineBinaryData>to disable MTOM/XOP (S 7.13) and control ref:swaRef binding <jaxb:property @attachmentRef> (S 7.8.1).
- Section 6, 7: Schema to Java Binding
- Binding of a simple element property (Sec 6.7.5) that is the head of an element substition group or customization with <jaxb:property generateElementProperty?="true"/> (Sec 7.8.1). The RI only generates an element setter/getter (Sec 5.5.5), it does not generate the additional type setter/getter(Sec 5.1). The RI generates a raw JAXBElement instead of a JAXBElement with an upper bound wildcard notation. (i.e. JAXBElement instead of JAXBElement<? extends Base>).
- RI annotates the schema-derived class for a global element declaration's anonymous complex type definition with @XmlRootElement instead of generating an element instance factory that returns javax.xml.bind.JAXBElement<JAXBBindingOfAnonComplexTypeDef> as specified in Sec 6.7.3. Note that unmarshal methods do not return an instance of javax.xml.bind.JAXBElement for instances bound in this manner.
- RI does not generate schema derived enum methods, value() or fromValue(String), as specified in Section 6.2.3.3 "Enum Constant".
- Section 7.12 <jaxb:dom> schema customization is not supported by RI.
- The RI does not have support for marshalling fixed attributes bound with customization @fixedAttributesAsConstantProperty. Currently it fails to marshal the attributes.
- @XmlSchemaType was added for mapping XmlGregorianCalendar, but has not been implemented by the RI yet.
- The spec has changed the mapping of XMLGregorianCalendar to xs:anySimpleType, but the RI still maps it to xs:dateTime.
- The spec allows @XmlJavaTypeAdapter on classes and fields, but the RI only supports this annotation on fields.
- The spec allows mapping of public static final fields annotated with @XmlAttribute to a fixed attribute in schema, the RI doesn't handle this case yet.
The RELAX NG support is not yet implemented in this early access.
The JAXB RI is shipped with experimental DTD support, which lets you compile XML DTDs.
To compile a DTD
test.dtd
, run the XJC binding compiler as follows:$ xjc.sh -dtd test.dtdAll the other command-line options of the XJC binding compiler can be applied, no matter what schema language you use. Similarly, the XJC ant task supports DTD. No matter what schema language you use, the generated code will be no different. You'll use the same JAXB API to access the generated code.
Customization
The customization syntax for DTD is roughly based on the ver.0.21 working draft of the JAXB specification, which is available at xml.coverpages.org. The deviations from this document are:
- The whitespace attribute of the conversion element takes "preserve", "replace", and "collapse" instead of "preserve","normalize", and "collapse" as specified in the document.
- The interface customization just generates marker interfaces with no method.