Thursday, March 03, 2005

Translets

At my current client I have been working on and off on a legacy Java web application utilizing a Servlets->XML->XSLT architecture. The users were complaining that the application seemed sluggish. After profiling the application, I found that our bottleneck was in the XML->XSLT transformation process. I started looking around for some XSL performance tips and came across Xalan's XSLTC. XSLTC is a compiler and runtime processor for XSLT. The compiler compiles a stylesheet to a Translet and the runtime processor applies the translet to an XML document to perform the transformation. Translets can be accessed through the JAXP API, so I did not have to modify much of the existing source code.

The bulk of the work was streamlining the use of XSLTC into our build process. There is not an Ant task available and the command line interface is lacking. I implemented some utilities wrapping the XSLTC process, including a good command line interface and dependency checking for stylesheet compilation. The reason for the dependency checking is to prevent from having to compile all approx. 400 stylesheets in the application during each compilation phase. Although there are nearly 400 stylesheets in the app the bulk of the XSL is contained in a common collection of 30-40 stylesheets that are imported by locale and customer specific stylesheets.

Using the XSLTC compiler and runtime processor showed an approx. 3X performance gain in stylesheet transformations. Our previous implementation utilized the JAXP API to create and cache Templates objects for each stylesheet in the app.

0 Comments:

Post a Comment

<< Home