users@jaxb.java.net

Re: JAXB schema limitations

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Fri, 23 Jan 2009 09:58:40 +0100

Hello Gennady,

this is an excellent question! But, like many a good question, it's
not easy to answer.

A concise and fairly accurate answer would be: If the XML Schema
construct has an equivalent in Java combined with what is in
javax.xml.bind.annotation, then it is supported. But that's not
satisfactory when you expect an XML Schema feature list with ticks in
the JAXB column ;-)

Here are a few pointers to some features that might be considered as
"not (precisely) implemented". But there are sound design decisions
behind all of these issues.

There is one group of Schema features that doesn't fall under the
above definition: facets. They are only checked when validation
according to the schema is explicitly requested.

The sophisticated variety of the XML data types is mapped to a much
smaller set of Java types.

Types defined with xs:simpleType usually "fall back" to the base type
and do not appear as explicit classes in the generated Java code.

An xs:union results in a class with all alternatives being present as
fields with getters and setters.

Certain grouping combinations of xs:sequence, xs:all and xs:choice,
in/maxOccurs and/or tag duplications within one of the grouping
constructs may result in the grouping being mapped to a Java
collection that will accept a wider range of possibilities than the
schema is permitting.

Experience has shown that you can write a schema that results in poor
Java code, for a number of reasons such as heavy use of inline type
definitions, ill-advised groupings, lack of providing proper types,
failure to use ID/IDREF, omission of complexType inheritance, etc. But
that's not JAXB's fault - it is a result of the basic difference in
what XML Schema and the Java language have been designed to be. On
the other hand, a little OO thinking lets you write schema definitions
that define the expected XML structure AND compile into fine Java
code.

Don't let those "statements" deter you from using JAXB.

-W


On Thu, Jan 22, 2009 at 2:46 PM, Gennady Shumakher <gshumakher_at_gmail.com> wrote:
> Hello,
>
> Reading about JAXB I came across statements like "JAXB does not support all
> of the XML schema constructs".
> I wonder is there a list of known XML schema support limitations of latest
> JAXB release?
>
> Thanks,
> Gennady
>