users@jaxb.java.net

Re: Root elements

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 18 Feb 2005 09:40:21 -0800

Brian Pontarelli wrote:
> I this case, I could possibly use a JAXBElement to tell the marshaller
> what name to give the root element, but the JAXB 2.0 version available
> right now doesn't support that. Or, additional methods could be added to
> the marshaller to support these situations. Or, JAXB just could say,
> don't do this!

Yes, you can do:

   MyRootElementType t = ...;
   marshaller.marshal(new JAXBElement(new QName("root","tagName"),t));

to marshal it out. But I don't know if this change has made it into the
technology preview release. Sounds like it didn't, and I'm sorry about that.


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com