users@jaxb.java.net

Re: Get Schema from compiled JAXB-Classes

From: Joe Fialli <Joseph.Fialli_at_Sun.COM>
Date: Mon, 08 Aug 2005 16:05:52 -0400

Roman Seidl wrote:

> Dear JAXB-Users,
>
> i consider switching from XMLBeans to JAXB for my application. There
> is only one limitation of JAXB that seems to make this complicated:
>
> XMLBeans is able to return the Schema of a Document Object compiled by
> its Schma-Compiler. Is it possible to do this with JAXB? And if its
> possible what Version would i have to use and what xjc or other
> settings are required?

JAXB 2.0 does not save the original schema compiled by its schema compiler.
While the generated java program annotations (javax.xml.bind.annotation)
preserve
some characteristics of the original schema, it does not preserve all
constraints.
It is possible to generate a schema from the JAXB 2.0 program
annotations using
the method javax.xml.bind.JAXBContext.generateSchema(...). The generated
schema will not be as precise as the original schema was.

JAXB 2.0 leverages JAXP 1.3 validation by having the application provide
what schema
should be used to validate at unmarshal or marshal time. See
javax.xml.bind.Unmarshaller.setSchema(Schema)
and javax.xml.bind.Marshaller.setSchema(Schema).


-Joe Fialli, Sun Microsystems

>
> cheers
> roman seidl
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>