users@jaxb.java.net

Re: Partial marshaling?

From: Kohsuke Kawaguchi <kohsuke.kawaguchi_at_sun.com>
Date: Thu, 08 Dec 2005 13:41:47 -0800

Sean LeBlanc wrote:
> Yep, I do mean partial marshalling. I'm trying to keep memory use under
> control when creating very large XML documents. It turns out I was able to
> achieve this in XMLBeans, although I'd still be curious how this might be
> achieved in JAXB.

Using XMLStreamWriter in conjunction with JAXB works good with this.

<purchaseOrder>
   <billTo>
     (write by JAXB)
   </billTo>
   <shipTo>
     (write by JAXB)
   </shipTo>
   <items>
     <item> (write by JAXB) </item>
     <item> (write by JAXB) </item>
     <item> (write by JAXB) </item>
     <item> (write by JAXB) </item>
   </items>
</purchaseOrder>

The <xxx> and </xxx> you can write, and you can hand the same writer to
JAXB marshaller to fill in the sub-tree (including such element slike
<billTo>.)

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com