users@jaxb.java.net

Re: AW: Forcing xsi:type for non element marshalling

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 17 Nov 2006 09:12:52 -0800

Ernst, Matthias wrote:
>>>From the URL you cite:
>
> "
> At the first glance the second Point.class parameter may look redundant,
> but it's actually necessary to determine if the marshaller will produce
> (infamous) @xsi:type. In this example, both the class and the instance
> are Point, so you won't see @xsi:type. But if they are different, you'll
> see it.
> "
>
> So
>
> marshaller.marshal(
> new JAXBElement(
> new QName("","rootTag"),
> Object.class,
> new Point(3,5)
> )
> );
>
> should produce
>
> <rootTag xsi:type="point" x="3" y="5"/>

Yep.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com