Q:

Incremental/streaming XSLT transformations?

I'm normally using the XSLT support in the JDK (JDK 7) for XSLT transformations. Recently I've come across a rather large XML document, and applying XSLT transformations to this (even very basic ones) causes a lot of memory to be used.
I've been careful to do all my processing streaming, but it seems the XSLT engine in the JDK (which appears to be a modified Xalan) always builds up a DOM in memory first. Obviously this is not what I want.
Now I found out that the Xalan which is available separately (2.7.1 from 2007!) does have an API for doing incremental transformations. So while this does seem to work, I actually want my code to run on a stock JDK, without telling the user to fiddle with any endorsed folder.
What is the best way to do incremental XSLT transformations in Java so that my code is compatible with unmodified/stock JDK installations?
update:
This recently updated question is strongly related: What is the Most Efficient Java-Based streaming XSLT Processor?

A:

Firstly, I would strongly recommend using the Apache versions of Xalan and Xerces rather than the versions bundled in the JDK, which are very buggy. That's particularly true for Xerces.
Secondly, if you're using Java then you really ought to be moving to XSLT 2.0, which gives you vast improvements in development productivity. In practice that means Saxon (the home edition of Saxon is free).
Incremental transformation in Xalan doesn't actually stop it building the whole source document as a tree in memory; all it does is to allow the tree to be built in parallel with the transformation process. If you want a streaming transformation, Saxon-EE is your only practical option. (Note that the saxon:stream() extension is only one small part of the streaming capabilities that Saxon offers).

