XSL Speed Optimizer
The XSL Speed Optimizer (also referred to in this section as the Optimizer) enables XSLT stylesheets to be optimized so that transformations are carried out faster. The Optimizer works by running the XSLT stylesheet over an XML document, and analyzing the stylesheet's performance. An optimization strategy is derived from this analysis and can be saved with the XSLT stylesheet (as a processing instruction at the end of the stylesheet). The optimized stylesheet can be used subsequently to produce faster transformations.
Optimizing an XSLT stylesheet
To optimize an XSLT stylesheet, you will need, in addition to the XSLT stylesheet, an XML document that will serve as a sample. The XML document must be large enough for all parts of the XSLT stylesheet to be used so that it is properly analysed. Do the optimization as follows:
1.With either the XSLT stylesheet or the XML document active, click the menu command XSL/XQuery | XSL Speed Optimizer or click the Optimizer's icon in the main toolbar.
2.You will be prompted to select, depending on whether an XSLT or XML document is active, respectively, an XML document or XSLT stylesheet. On clicking OK, the analysis starts. (If the XSLT or XML document has already been assigned, then this step is skipped and the analysis will be started directly the command is invoked.)
3.If the optimization analysis is unsuccessful, a message to that effect is displayed. (The possible reasons for an unsuccessful optimization analysis are described below.) If the analysis is successful, a dialog showing the results of the analysis appears (screenshot below).
The dialog gives you the option of saving the optimization (instructions) in the XSLT stylesheet (as a processing instruction at the end of the stylesheet). Click Yes to save the optimization, No to discard it. Whenever an optimization is saved, it overwrites any previously saved optimization.
The optimized stylesheet can now be used to carry out faster transformations.
Reasons for unsuccessful optimization analysis
If the XSL Speed Optimizer is unable to derive an optimization, this could be for one or more of the following reasons:
•The XSLT stylesheet is already time-efficient and does not need to be optimized.
•The XML document that was submitted is too small to optimize. Try again with a larger document.
•The threshold/s for optimization might be too high. Change the thresholds in the XSL Speed Optimizer section of the Options dialog. See below.
•Optimizations for this specific XSLT structure are not available to the Optimizer. Please contact Altova Support.
XSL Speed Optimizer settings
Settings for the Optimizer are made in the XSL Speed Optimizer section of the Options dialog (Tools | Options, screenshot below).
A time threshold for single XSLT instructions in an XSLT stylesheet can be specified for the Optimizer. Values range from 0.1% of total transformation time to 99% of total time. If an instruction takes more time to execute than that specified as the threshold, then optimization analysis is invoked. Otherwise no analysis is carried out. If optimization analysis is unsuccessful, the reason might be that the time threshold in the Optimizer settings is too high. Consider lowering it.