Compiling a stylesheet
Generally, the cost of analyzing the XSLT source code in a stylesheet and preparing it for execution can be high in relation to the cost of actually running the code to transform an individual source document, especially where the stylesheet is large and the source document is small. Saxon provides several capabilities designed to ensure that when you use the same stylesheet repeatedly, you only need to incur this overhead once.
- In simple cases, you can exploit the ability to process an entire directory of source
files using a single invocation of the
Transform
command on the command line. - All the transformation APIs separate the process of compiling a stylesheet and
the process of using it to transform a source document. With JAXP the object
representing the compiled stylesheet is the
javax.xml.transform.Templates
object, with s9api on Java, Saxon.Api on C#, or with the SaxonC API on C++/PHP/Python it is theXsltExecutable
. If you run transformations within a web service then it is always a good idea to cache the compiled form of the stylesheets it uses. - With Saxon-EE it is also possible to export the compiled form of a stylesheet as an XML file (called the stylesheet export file), in much the same way that object code from other languages is saved to filestore, and distributed from developers to users.
Further information: