xsl-list
[Top] [All Lists]

RE: Optimizing Trax

2003-06-20 07:49:00
Hi,

You want to create javax.xml.transform.Templates objects and keep a cache of
these to retrieve the next time it is needed. You will probably want to
check if the source XSL (and perhaps any dependencies - xsl:include/import's
document() xml) has changed to reset the cache for a specific Templates
object.

There are examples of how to do this out there (google). There are a couple
of examples (one simple and one a little more complex - they don't check for
dependencies, though) in O'Reilly's Java and XSLT (it think it is online
somewhere).

If you are doing this offline you can use the Ant xslt task which gives you
the option of caching the template (you could check out the src to see how
they do it. Even if doing it in a servlet environment you could use the task
there too. However in its current state it does not check for dependencies.

Best,
-Rob

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-
list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of Schwartz, Rechell 
R, ALABS
Sent: Friday, June 20, 2003 6:05 AM
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com

All,

I am using Trax to transform my xml files, and am finding the performance
very slow especially for large files. Are there any ways of optimizing the
performance such as by pre-compiling the stylesheets? If so, how can this
be done?
Here is the code that is slow:
xsl = "/stylesheet.xsl";
transformer = tFactory.newTransformer(new
StreamSource(getClass().getResourceAsStream(xsl)));
transformer.transform(new DOMSource(document), new StreamResult(out));

Rechell Schwartz


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>