Class XsltExecutable
- java.lang.Object
-
- net.sf.saxon.s9api.XsltExecutable
-
public class XsltExecutable extends java.lang.Object
An XsltExecutable represents the compiled form of a stylesheet. To execute the stylesheet, it must first be loaded to form anXsltTransformer
.An XsltExecutable is immutable, and therefore thread-safe. It is simplest 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 theXsltCompiler
class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
XsltExecutable.ParameterDetails
Inner class containing information about a global parameter to a compiled stylesheet
-
Constructor Summary
Constructors Modifier Constructor Description protected
XsltExecutable(Processor processor, PreparedStylesheet preparedStylesheet)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
explain(Destination destination)
Produce a diagnostic representation of the compiled stylesheet, in XML form.void
export(java.io.OutputStream destination)
Produce a representation of the compiled stylesheet, in XML form, suitable for distribution and reloading.void
export(java.io.OutputStream destination, java.lang.String target)
Produce a representation of the compiled stylesheet for a particular target environment, in XML form, suitable for distribution and reloading.java.util.HashMap<QName,XsltExecutable.ParameterDetails>
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 optionalProcessor
getProcessor()
Get the Processor that was used to create this XsltExecutablePreparedStylesheet
getUnderlyingCompiledStylesheet()
Get the underlying implementation object representing the compiled stylesheet.WhitespaceStrippingPolicy
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 stylesheetXsltTransformer
load()
Load the stylesheet to prepare it for execution.Xslt30Transformer
load30()
Load the stylesheet to prepare it for execution.
-
-
-
Constructor Detail
-
XsltExecutable
protected XsltExecutable(Processor processor, PreparedStylesheet preparedStylesheet)
-
-
Method Detail
-
getProcessor
public Processor getProcessor()
Get the Processor that was used to create this XsltExecutable- Returns:
- the original Processor object
- Since:
- 9.6
-
load
public XsltTransformer load()
Load the stylesheet to prepare it for execution. This version of the load() method creates anXsltTransformer
which 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
public Xslt30Transformer load30()
Load the stylesheet to prepare it for execution. This version of the load() method creates anXslt30Transformer
which 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 returned Xslt30Transformer can be used to set up the dynamic context for stylesheet evaluation, and to run the stylesheet.
-
explain
public void explain(Destination destination) throws SaxonApiException
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
public void export(java.io.OutputStream destination) throws SaxonApiException
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
public void export(java.io.OutputStream destination, java.lang.String target) throws SaxonApiException
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
public WhitespaceStrippingPolicy 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
public java.util.HashMap<QName,XsltExecutable.ParameterDetails> 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.ParameterDetails
objects giving information about the corresponding parameter. - Since:
- 9.3
-
getUnderlyingCompiledStylesheet
public PreparedStylesheet 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
-
-