XSLT 2.0 transforms can be started from Saxon-CE in various ways to suit your requirement. This section provides an overview of the different transform methods along with links to more detailed documentation.
The first method employs a standard
<?xml-stylesheet?> processing-instruction in the prolog of an XML document, as shown below:
This provides the easiest upgrade from existing XSLT 1.0 applications. Because the processing instruction is read by
the browser, not by Saxon, it can't load the XSLT 2.0 stylesheet directly. Instead,
stylesheet: to set the URL of the actual XSLT 2.0 stylesheet to run (a sample is included in the
samples directory in the Saxon-CE download).
script element within the HTML
function. This is to ensure that Saxon-CE loads first:
Using an XSLT 2.0 Script Element
You can use the XSLT Script Element when you only need to execute a single transform when the HTML page loads, and no XSLT parameters or configuration settings are required.
This utilizes a single call to the
run function in the Saxon namespace.
This takes as its single argument a Command object containing a description
of the transformation to be executed.
Use this when a bit more flexibility is required, such as the need to set XSLT parameters or dynamically select a stylesheet.
When using XSLT 1.0 in the browser, it is common to generate a complete HTML page as output from the transformation. With XSLT 2.0, a more effective technique is to write multiple fragments of HTML, using them to populate named portions of the HTML page. So the initial HTML page will generally contain a skeletal structure of elements such as
div element, each with an
id attribute, waiting to be populated by the stylesheet.