users@jaxb.java.net

Re: XSd key's and keyref's

From: Vincent Lamareille <vinc_at_sorengo.com>
Date: Tue, 13 Sep 2005 01:37:06 +0200

Thanks Kohsuke,

What I need exactly is to enforce some kind of referential integrity
between Java objects which are marshalled to XML documents and later
unmarshalled.
So I will use JAXB for binding, and apply constraints in Java classes.

As constraints are easy to write in code and difficult to express in
XSD, is it possible to add them into Java classes with a plugin?

Vincent

Kohsuke Kawaguchi wrote:
>
> Vincent Lamareille wrote:
> > But it seems really intricated to express this simple constraint in XML
> > Schema with key's and keyref's and get it in code after compilation?
> >
> > Has somebody a simple explanation for this problem?
>
> I didn't exactly follow the constraints you are trying to enforce, but
> it's very normal for a schema not to capture all the necessary constraints.
>
> Take schema-for-schemas as an example. When you say <xs:element
> name="foo" type="something" />, there are referential integrity that
> requires "something" to be defined as a type somewhere, but it is not
> possible to capture this in a schema.
>
> > Can I do it with jxb: annotations?
>
> You can write code to check those constraints, but I don't think we have
> any customizations like this.
>
> --
> Kohsuke Kawaguchi
> Sun Microsystems kohsuke.kawaguchi_at_sun.com