users@jaxb.java.net

Re: Error parsing xhtml1-strict.xsd ""Lang" is already defined."

From: Kenny MacLeod <kennym_at_kizoom.com>
Date: Sun, 17 Aug 2008 22:06:07 +0100

Aleksei Valikov wrote:
> I repeat, this is not a problem of schema or JAXB. This is a problem
> of schema not being 100% suitable for Java representations. And it is
> actually your task as a developer to introduce the customizations to
> provide this compatibility.

This reality has been a slow and painful realisation for me over the
last 2 years or so. Some schema just don't bind with JAXB2, period, and
many others need binding customisations to bind, or to make them at all
useable. It is a rare non-trivial schema that generates a useful
binding out of the box, in my experience.

One useful approach I've started using is to combine jaxb customisations
with a XSLT pre-processing step, to "sanitise" the schema. This is
useful for massaging things like type declarations in the schema, for
example to collapse unnecessary complex types down to simple types,
which results in a more lightweight binding. As long as you're careful
to make sure you don't change the semantics of the schema, it's quite a
handy technique.

kenny