[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Optimizing Trax

Subject: RE: Optimizing Trax
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Sat, 21 Jun 2003 15:22:49 +0100
rechell
You are still compiling the stylesheet (newTemplates()) every time you
execute it.

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Schwartz, Rechell R, ALABS
> Sent: 20 June 2003 19:25
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Optimizing Trax
> 
> 
> Rob,
> 
> I found the following code on-line, but it didn't improve the 
> performance at all. The xml file that is compiled is always 
> dynamic, while the xsl file is static. Any idea what could be wrong.
> 
> Rechell Schwartz
> 
>  public XslTransformer (String theXslFileName) 
>         throws TransformerConfigurationException
>     {
>         xslFileName  = theXslFileName;
>         
>         Templates templates = (Templates)CACHE.get(theXslFileName);
>         if (templates == null)
>         {
>             TransformerFactory factory = 
> TransformerFactory.newInstance();
> 
>           	templates = factory.newTemplates(new 
> StreamSource(xslFileName));
> 
>             CACHE.put(theXslFileName, templates);
>         } 
>         transformer  = templates.newTransformer();
>     }
> 
> -----Original Message-----
> From: Robert Koberg [mailto:rob@xxxxxxxxxx]
> Sent: Friday, June 20, 2003 10:49 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Optimizing Trax
> 
> 
> 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@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl- 
> > list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Schwartz, Rechell R, ALABS
> > Sent: Friday, June 20, 2003 6:05 AM
> > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> > 
> > 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
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.