So if I understand this correctly, even if using the SAX examples, Xalan
still needs access to the entire source XML document?
If so, how efficient would it be if I did a transformation for each chunk of
a document based on SAX events?
Cory
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 12, 2001 7:11 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: DOM and SAX input in DTM
>Is it true when the source is SAX events, Xalan will still need to build
>an internal source tree for the transformation? Now the internal tree
>representation is DTM, done by SAX2DTM?
Given that XSLT can at any time access any node in the document, some sort
of in-memory model is necessary unless you want to reparse the document
every time your stylesheet might look backward. In incremental mode we only
build as much of the document as we must. We do hope eventually to
pre-analyse the stylesheet and further reduce how much is built, and/or
discard data no longer needed (see recent discussion of "pruning"), but
that's an area where a lot more development is needed.
>If I understand right, DOM2DTM is only a wrapper that the same DOM tree
can be
>accessed via DTM interface, right?
That's the idea. DOM2DTM does have some additional setup and storage costs
beyond those of the basic DOM tree, but it tries to use the base DOM for
most of its data (all the strings, for example). DOM2DTM is always built
incrementally. The same comments about pruning apply.
>Which case will be faster, consume less memory?
If you're starting with a DOM, the DOMSource/DOM2DTM approach wins on both
fronts. Absolutely no question. Consider the overhead of recopying text
from the SAX interface, just as one example.
>Another question is about the Result, does Xalan fire the result SAX
>events in any way, then depend on the Result, it will pass the SAX
>events, build DOM, or serialize to Stream, respectively?
Xalan's "native" output is always a SAX stream. If you ask for a DOM, it
feeds that into a DOM-builder and hands you the resulting DOM. If you ask
for a stream, it runs that into a serializer and hands you the serializer's
output stream.