users@jaxb.java.net

Re: JAXB Validation without a Schema

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 30 Jul 2007 15:01:12 -0700

Shelley wrote:
> Part of the benefit of JAXB is that a schema is not required; annotating
> Java classes alone allows for XML serialization/deserialization. With the
> deprecation of the Unmarshaller.setValidating() in favor of the
> unmarshaller.setSchema() method, however, it seems that validation is only
> available when an XSD is present. Is there another way to validate XML
> during unmarshalling without a physical schema file?

No. It would be nice if XJC can somehow capture the schema it's
compiling and package it so that you can readily use it at runtime.

Another related thing you can do today is to generate a schema from the
classes and use that for the validation. The constraints will be weaker
than the original schema, but probably still better than nothing.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com