How to Speed Up Your XSLT, Automatically
Written by Erin Cavanaugh
Once you’ve written XSLT code to produce the desired output, optimizing it to deliver the fastest execution is tricky business. Even with the powerful XSLT profiler in XMLSpy, a developer is required to have expert-level XSLT skills to test and fix the bottlenecks that the XSLT profiler identifies. Is the problem in an XPath expression? Is it an XSLT instruction? This can be a frustrating and time consuming task.
To help alleviate this issue and bring the power of XSLT to developers of all skill levels, XMLSpy also includes the XSL Speed Optimizer, which provides fixes to remove bottlenecks automatically, to immediately speed up your XSLT execution – it’s a revolutionary approach to optimizing XSLT performance.
XSL Speed Optimizer
The XMLSpy XSL Speed Optimizer is a brand new, innovative approach to speeding up XSLT transformations. With one click, you can implement an optimization that immediately increases throughput, avoiding the manual analysis and testing usually required to resolve XPath or XSLT-related bottlenecks. This frees you to focus on the transformation logic of your stylesheets and leave speed optimization to XMLSpy.
To use the XSL Speed Optimizer, simply supply an existing XSLT stylesheet along with sample XML data. You can configure a time threshold for single XSLT instructions in a stylesheet, with values ranging from 0.1% of total transformation time to 99% of total time. (.5% is the default value.) If an instruction takes more time to execute than the specified threshold, then optimization analysis is invoked.
How Does Speed Up XSLT?
Once you supply an XSLT stylesheet and sample XML dataset, the XSL Speed Optimizer analyzes the transformation to identify bottlenecks based on the time threshold you’ve set. Then it tests the code against proven best-practices and optimization patterns, as well as proprietary information, to determine speed improvements. It does not alter the XSLT directly, but rather generates XML processing instructions (PI) to automatically insert at the end of the stylesheet.
Then the XSL Speed Optimizer re-runs the execution to determine which optimizations result in an increase in speed, and only saves those that have a positive impact. The optimized stylesheet can then be used to produce faster transformations.
In a test I ran today, I set a minimum relative time limit of .1%, and the XSL Speed Optimizer was able to decrease execution time by 18%!
It should be noted, that if your code is already optimized, and there are no improvements identified, no changes will be made.
Once you save the XSLT code with the processing instructions, your transformation can be executed directly in XMLSpy as well as on RaptorXML Server for lightning-fast processing.