[XOM-interest] Writing large XML documents
Elliotte Rusty Harold
elharo at metalab.unc.edu
Wed Dec 19 07:05:36 EST 2007
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/
More information about the XOM-interest
mailing list