Class XsltTransformer
- All Implemented Interfaces:
Destination
XsltTransformer represents a compiled and loaded stylesheet ready for execution.
The XsltTransformer holds details of the dynamic evaluation context for the stylesheet.
An XsltTransformer must not be used concurrently in multiple threads.
It is safe, however, to reuse the object within a single thread to run the same
stylesheet several times. Running the stylesheet does not change the context
that has been established.
An XsltTransformer is always constructed by running the Load
method of an XsltExecutable.
An XsltTransformer is itself a Destination. This means it is possible to use
one XsltTransformer as the destination to receive the results of another transformation,
this providing a simple way for transformations to be chained into a pipeline.
- Since:
- 9.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedXsltTransformer(Processor processor, Controller controller) Protected constructor -
Method Summary
Modifier and TypeMethodDescriptionGet the destination that was specified in a previous call ofsetDestination(net.sf.saxon.s9api.Destination)Get the initial context node for the transformation, if one has been setGet the initial mode for the transformation, if one has been set.Get the initial named template for the transformation, if one has been setGet the MessageListener to be notified whenever the stylesheet evaluates anxsl:messageinstruction.getParameter(QName name) Get the value that has been set for a stylesheet parametergetReceiver(Configuration config) Return a Receiver which can be used to supply the principal source document for the transformation.Get the underlying Controller used to implement this XsltTransformer.voidsetDestination(Destination destination) Set the destination to be used for the transformation.voidsetInitialContextNode(XdmNode node) Set the initial context node for the transformation.voidsetInitialMode(QName modeName) Set the initial mode for the transformationvoidsetInitialTemplate(QName templateName) Set the initial named template for the transformationvoidsetMessageListener(MessageListener listener) Set the MessageListener to be notified whenever the stylesheet evaluates anxsl:messageinstruction.voidsetParameter(QName name, XdmValue value) Set the value of a stylesheet parametervoidSet the source document for the transformation.voidPerform the transformation.
-
Constructor Details
-
XsltTransformer
Protected constructor- Parameters:
processor- the S9API processorcontroller- the Saxon controller object
-
-
Method Details
-
setInitialTemplate
Set the initial named template for the transformation- Parameters:
templateName- the name of the initial template, or null to indicate that there should be no initial named template- Throws:
SaxonApiException- if there is no named template with this name
-
getInitialTemplate
Get the initial named template for the transformation, if one has been set- Returns:
- the name of the initial template, or null if none has been set
-
setInitialMode
Set the initial mode for the transformation- Parameters:
modeName- the name of the initial mode, or null to indicate the default (unnamed) mode
-
getInitialMode
Get the initial mode for the transformation, if one has been set.- Returns:
- the initial mode for the transformation. Returns null if no mode has been set, or if the mode was set to null to represent the default (unnamed) mode
-
setSource
Set the source document for the transformation. This method is equivalent to building a document from the supplied source object, and then supplying the document node of the resulting document as the initial context node.- Parameters:
source- the principal source document for the transformation- Throws:
SaxonApiException
-
setInitialContextNode
Set the initial context node for the transformation.This is ignored in the case where the
XsltTransformeris used as theDestinationof another process. In that case the initial context node will always be the document node of the document that is being streamed to this destination.- Parameters:
node- the initial context node, or null if there is to be no initial context node
-
getInitialContextNode
Get the initial context node for the transformation, if one has been set- Returns:
- the initial context node, or null if none has been set. This will not necessarily
be the same
XdmNodeinstance as was supplied, but it will be an XdmNode object that represents the same underlying node.
-
setParameter
Set the value of a stylesheet parameter- Parameters:
name- the name of the stylesheet parameter, as a QNamevalue- the value of the stylesheet parameter, or null to clear a previously set value
-
getParameter
Get the value that has been set for a stylesheet parameter- Parameters:
name- the parameter whose name is required- Returns:
- the value that has been set for the parameter, or null if no value has been set
-
setDestination
Set the destination to be used for the transformation.This method can be used to chain transformations into a pipeline, by using one
XsltTransformeras the destination of another- Parameters:
destination- the destination to be used
-
getDestination
Get the destination that was specified in a previous call ofsetDestination(net.sf.saxon.s9api.Destination)- Returns:
- the destination, or null if none has been supplied
-
setMessageListener
Set the MessageListener to be notified whenever the stylesheet evaluates anxsl:messageinstruction. If no MessageListener is nominated, the output ofxsl:messageinstructions will be serialized and sent to the standard error stream.- Parameters:
listener- the MessageListener to be used- Since:
- 9.1
-
getMessageListener
Get the MessageListener to be notified whenever the stylesheet evaluates anxsl:messageinstruction. If no MessageListener has been nominated, return null- Returns:
- the user-supplied MessageListener, or null if none has been supplied
- Since:
- 9.1
-
transform
Perform the transformation. If this method is used, a destination must have been supplied previously- Throws:
SaxonApiException- if any dynamic error occurs during the transformationIllegalStateException- if no destination has been supplied
-
getReceiver
Return a Receiver which can be used to supply the principal source document for the transformation. This method is intended primarily for internal use, though it can also be called by a user application that wishes to feed events into the transformation engine.Saxon calls this method to obtain a Receiver, to which it then sends a sequence of events representing the content of an XML document. This method is provided so that
XsltTransformerimplementsDestination, allowing one transformation to receive the results of another in a pipeline.Before calling this method, the
setDestination(net.sf.saxon.s9api.Destination)method must be called to supply a destination for the transformation.Note that when an
XsltTransformeris used as aDestination, the initial context node set on thatXsltTransformeris ignored.- Specified by:
getReceiverin interfaceDestination- Parameters:
config- The Saxon configuration. This is supplied so that the destination can use information from the configuration (for example, a reference to the name pool) to construct or configure the returned Receiver.- Returns:
- the Receiver to which events are to be sent.
- Throws:
SaxonApiException- if the Receiver cannot be createdIllegalStateException- if no Destination has been supplied
-
getUnderlyingController
Get the underlying Controller used to implement this XsltTransformer. This provides access to lower-level methods not otherwise available in the s9api interface. Note that classes and methods obtained by this route cannot be guaranteed stable from release to release.- Since:
- 9.0.0.4
-