users@jaxb.java.net

Re: Newbie question !

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 14 May 2007 17:28:51 -0700

tog wrote:
> Hiya
>
> I want to use Jaxb with a dynamic language (namely Groovy).
> In groovy, a simple bean is expressed like this
>
> class Person {
> String name
> }
>
>
> the groovyc compiler generates the setter/getter and a few more
> information. From a user point of view, I would like to marshall and
> unmarshall
> only the name property (avoiding all the extra information addes by the
> compiler).
>
> I guess the @XmlRootElement is not suitable because it will generate
> schema also for my extra properties.
>
> Is one of these annotations @XmlElement or @XmlAttribute worth to be
> used for my need ?

Yes, @XmlElement.

> Is these a way using JAXB to generate the XmlSchema out of a .class file ?

Yes. Use the schemagen tool, or call JAXBContext.generateSchema()

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com