Tushar Tarkas
Tushar Tarkas

Reputation: 1612

Xsl transformation of large xmls

I am aware of ways of applying XSL transformation to XMLs in java using

javax.xml.transform.Transformer

This approach works well for small XML data. But when it comes to large XML data where DOM based approach is difficult to use because of memory constraints, this becomes a nightmare.

I want to know what is the best approach to apply XSL transformation to large XMLs. Is there any transformer which operates on SAX and not DOM?

Upvotes: 2

Views: 2216

Answers (2)

Aravind Yarram
Aravind Yarram

Reputation: 80176

If you are working with huge XSLT and/or working with multiple XSLT's then compiling and caching the xslt is a good option to improve performance. This article explains how to cache xslt's

Upvotes: 2

Martin Honnen
Martin Honnen

Reputation: 167516

There are different implementations of XSLT processors in Java that implement JAXP. Saxon 9.3 is an XSLT 2.0 processor that also implements some streaming features of the XSLT 3.0 working draft, see http://www.saxonica.com/documentation/sourcedocs/streaming.xml. And even if you don't use the latest experimental Saxon 9.3 features it is usually a good idea not to feed a DOMSource to your processor but let the processor use its own tree implementation by feeding a StreamSource.

Upvotes: 3

Related Questions