newXSLT20Processor
newXSLT20Processor($xslt as Document?) → XSLT20Processor
The factory method for creating a new XSLT20Processor object.
Arguments |
|||
|
$xslt |
Document? |
The XML Document containing the stylesheet. |
Result |
XSLT20Processor |
Details
The optional xslt
argument is used to specify the
stylesheet to be used when one of the transform functions of this object is
called. The function,
requestXML,
provides a cross-browser method for getting a Document instance of the
stylesheet.
If the xslt
argument is null when XSLT20Procssor is
initialised using this function, the
importStylesheet
function should always be called first, before initiating a transform.
It's possible to use a number of XSLT20Processor instances. This may
be useful either when you want to exploit a number of previously compiled
stylesheets, or when working with different HTML target pages (events from
the host page are broadcast to all processors that have stylesheets with
ixsl:event
templates).
If the stylesheet contains references to other stylesheet
modules in xsl:include
or xsl:import
declarations,
the other modules will be fetched automatically. For this to work, however,
Saxon-CE needs to know the base URI to use. There are several ways to supply this
information:
-
By default, Saxon-CE uses the URI of the HTML page as the base URI for the stylesheet. This works fine if the HTML page and the stylesheet are in the same directory on the server, but will cause problems if not. A possible workaround is to always load the principal stylesheet module from the directory containing the HTML, if necessary by creating a simple stub stylesheet that contains only an
xsl:include
pointing to the "real" stylesheet. -
If the stylesheet document is loaded using the
Saxon.requestXML
method, then the URI passed to that method is remembered as the base URI of the stylesheet module when it is eventually fetched. -
It is possible to include an
xml:base
attribute in thexsl:stylesheet
element of the principal stylesheet module, containing the absolute URI from which the stylesheet is loaded. This might be generated as part of the script for deploying the stylesheet. -
It is also possible (though probably inconvenient) for all
xsl:include
andxsl:import
declarations to use absolute URIs.