Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Writing large XML documents

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Writing large XML documents
  • Date: Wed, 19 Dec 2007 07:05:36 -0500

Eric Wang wrote:

This sentence in the documentation hints at such a capability using
the Serializer class: "However, since this builds the entire document
in memory, it can be problematic for large documents and less
efficient than using a Serializer, which can stream the document." I
just can't figure out how it would work looking at the documentation.
So is the documentation wrong in this respect?



The Document object is still in memory in both cases. However in the toXML case there's also a large String that's also built in memory. With the Serializer, there's no single large string in memory.

It's likely not a huge distinction: probably O(4N) for the Serializer and O(5N) for toXML where N is the size of the serialized document.

A much more important reason for using Serializer is that it starts sending the document immediately. toXML waits until it's built the entire string.

--
Elliotte Rusty Harold elharo AT metalab.unc.edu
Java I/O 2nd Edition Just Published!
http://www.cafeaulait.org/books/javaio2/
http://www.amazon.com/exec/obidos/ISBN=0596527500/ref=nosim/cafeaulaitA/




Archive powered by MHonArc 2.6.24.

Top of Page