Class XsltExecutable
XsltExecutable represents the compiled form of a stylesheet.
To execute the stylesheet, it must first be loaded to form an XsltTransformer.
An XsltExecutable is immutable, and therefore thread-safe.
It is simplest to use the load() or load30() method to
load a new XsltTransformer each time the stylesheet is to be run.
However, the XsltTransformer is serially reusable within a single thread.
An XsltExecutable is created by using one of the compile methods on the
XsltCompiler class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInner class containing information about a global parameter to a compiled stylesheet -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedXsltExecutable(Processor processor, PreparedStylesheet preparedStylesheet, int xsltVersion) -
Method Summary
Modifier and TypeMethodDescriptionvoidexplain(Destination destination) Produce a diagnostic representation of the compiled stylesheet, in XML form.voidexport(OutputStream destination) Produce a representation of the compiled stylesheet, in XML form, suitable for distribution and reloading.voidexport(OutputStream destination, String target) Produce a representation of the compiled stylesheet for a particular target environment, in XML form, suitable for distribution and reloading.Get the names of the xsl:param elements defined in this stylesheet, with details of each parameter including its required type, and whether it is required or optionalgetImportedSchema(String role) Get the schema used as the static context of the top-level package in the stylesheet.Get theProcessorthat was used to create thisXsltExecutableGet the underlying implementation object representing the compiled stylesheet.Get the whitespace stripping policy defined by this stylesheet, that is, the policy defined by the xsl:strip-space and xsl:preserve-space elements in the top-level package of this stylesheetintGet the XSLT language version.load()Load the stylesheet to prepare it for execution.load30()Load the stylesheet to prepare it for execution.
-
Constructor Details
-
XsltExecutable
protected XsltExecutable(Processor processor, PreparedStylesheet preparedStylesheet, int xsltVersion)
-
-
Method Details
-
getProcessor
Get theProcessorthat was used to create thisXsltExecutable- Returns:
- the original
Processorobject - Since:
- 9.6
-
getXsltVersion
public int getXsltVersion()Get the XSLT language version. This is the version as configured for the XSLT Compiler, which is not necessarily the same as the version contained in the XSLT source code.- Returns:
- 30 for XSLT 3.0, 40 for XSLT 4.0
-
load
Load the stylesheet to prepare it for execution. This version of the load() method creates anXsltTransformerwhich offers interfaces for stylesheet invocation corresponding to those described in the XSLT 2.0 specification. It can be used with XSLT 2.0 or XSLT 3.0 stylesheets, but does not offer new XSLT 3.0 functionality such as the ability to supply parameters to the initial template, or the ability to invoke stylesheet-defined functions, or the ability to return an arbitrary sequence as a result without wrapping it in a document node. If such facilities are required, use the methodload30()in preference.- Returns:
- An XsltTransformer. The returned XsltTransformer can be used to set up the dynamic context for stylesheet evaluation, and to run the stylesheet.
-
load30
Load the stylesheet to prepare it for execution. This version of theload()method creates anXslt30Transformerwhich offers interfaces for stylesheet invocation corresponding to those described in the XSLT 3.0 specification. It can be used with XSLT 2.0 or XSLT 3.0 stylesheets, and in both cases it offers new XSLT 3.0 functionality such as the ability to supply parameters to the initial template, or the ability to invoke stylesheet-defined functions, or the ability to return an arbitrary sequence as a result without wrapping it in a document node.- Returns:
- An
Xslt30Transformer. The returnedXslt30Transformercan be used to set up the dynamic context for stylesheet evaluation, and to run the stylesheet.
-
getImportedSchema
Get the schema used as the static context of the top-level package in the stylesheet. This will typically include schema components preloaded usingXsltCompiler.useSchema(String, XsdSchema), plus schema components loaded usingxsl:import-schemadeclarations within the stylesheet itself.This schema can usefully be used for validating source documents that are to be supplied as input to the stylesheet.
- Parameters:
role- the role-name of the schema: supply null or "" for the default/unnamed role- Returns:
- the schema used by the top-level package of the stylesheet, or null if there is no imported schema and no externally-supplied schema
- Since:
- 13.0
-
explain
Produce a diagnostic representation of the compiled stylesheet, in XML form.The detailed form of this representation is not stable (or even documented).
Note that although the format of the output is similar to the format of a stylesheet exported in SEF format, it is not identical, and the diagnostic explain output cannot be re-imported to reconstitute the stylesheet. For that purpose, use
export(OutputStream, String).- Parameters:
destination- the destination for the XML document containing the diagnostic representation of the compiled stylesheet- Throws:
SaxonApiException- if an error is detected- Since:
- 9.1
-
export
Produce a representation of the compiled stylesheet, in XML form, suitable for distribution and reloading. If the configuration under which the export takes place is suitably licensed, then license information will be included in the export file allowing execution of the stylesheet without any additional license.The detailed form of the output representation is not documented.
- Parameters:
destination- the destination for the XML document containing the diagnostic representation of the compiled stylesheet. The stream will be closed when writing has finished.- Throws:
SaxonApiException- if the stylesheet was compiled with just-in-time compilation enabled.- Since:
- 9.7
-
export
Produce a representation of the compiled stylesheet for a particular target environment, in XML form, suitable for distribution and reloading. If the configuration under which the export takes place is suitably licensed, then license information will be included in the export file allowing execution of the stylesheet without any additional license.The detailed form of the output representation is not documented.
- Parameters:
destination- the destination for the XML document containing the diagnostic representation of the compiled stylesheet. The stream will be closed when writing has finished.target- the target environment (for example "EE" or "JS")- Throws:
SaxonApiException- if an error is detected, including the case where the stylesheet was compiled with just-in-time compilation enabled.- Since:
- 9.7
-
getWhitespaceStrippingPolicy
Get the whitespace stripping policy defined by this stylesheet, that is, the policy defined by the xsl:strip-space and xsl:preserve-space elements in the top-level package of this stylesheet- Returns:
- a newly constructed WhitespaceStrippingPolicy based on the declarations in
the top-level package of this stylesheet. This policy can be used as input to
a
DocumentBuilder.
-
getGlobalParameters
Get the names of the xsl:param elements defined in this stylesheet, with details of each parameter including its required type, and whether it is required or optional- Returns:
- a Map whose keys are the names of global parameters in the stylesheet,
and whose values are
XsltExecutable.ParameterDetailsobjects giving information about the corresponding parameter. - Since:
- 9.3
-
getUnderlyingCompiledStylesheet
Get the underlying implementation object representing the compiled stylesheet. This provides an escape hatch into lower-level APIs. The object returned by this method may change from release to release.- Returns:
- the underlying implementation of the compiled stylesheet
-