net.sf.saxon.s9api
Class XsltTransformer
java.lang.Object
net.sf.saxon.s9api.XsltTransformer
- Destination
public class XsltTransformer
extends java.lang.Object
An
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.
XsltTransformer
protected XsltTransformer(Processor processor,
Controller controller)
Protected constructor
controller
- the Saxon controller object
getDestination
public Destination getDestination()
- the destination, or null if none has been supplied
getInitialContextNode
public XdmNode getInitialContextNode()
Get the initial context node for the transformation, if one has been set
- the initial context node, or null if none has been set. This will not necessarily
be the same XdmNode instance as was supplied, but it will be an XdmNode object that represents
the same underlying node.
getInitialMode
public QName getInitialMode()
Get the initial mode for the transformation, if one has been set.
- 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
getInitialTemplate
public QName getInitialTemplate()
Get the initial named template for the transformation, if one has been set
- the name of the initial template, or null if none has been set
getParameter
public XdmValue getParameter(QName name)
Get the value that has been set for a stylesheet parameter
name
- the parameter whose name is required
- the value that has been set for the parameter, or null if no value has been set
getReceiver
public Receiver getReceiver(Configuration config)
throws SaxonApiException
Return a Receiver. 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
XsltTransformer
implements
Destination
, allowing one transformation
to receive the results of another in a pipeline.
Note that when an
XsltTransformer
is used as a
Destination
, the initial
context node set on that
XsltTransformer
is ignored.
- getReceiver in interface Destination
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.
- the Receiver to which events are to be sent.
getUnderlyingController
public Controller 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.
setDestination
public void setDestination(Destination destination)
Set the destination to be used for the transformation. This is ignored if a destination
is supplied on the transform() call itself. This method must be used to supply a destination
when transformations are chained together (by using one XsltTransformer as the destination of
another)
destination
- the destination to be used
setInitialContextNode
public void setInitialContextNode(XdmNode node)
Set the initial context node for the transformation
node
- the initial context node, or null if there is to be no initial context node
setInitialMode
public void setInitialMode(QName modeName)
Set the initial mode for the transformation
modeName
- the name of the initial mode, or null to indicate the default
(unnamed) mode
setInitialTemplate
public void setInitialTemplate(QName templateName)
throws SaxonApiException
Set the initial named template for the transformation
templateName
- the name of the initial template, or null to indicate
that there should be no initial named template
setParameter
public void setParameter(QName name,
XdmValue value)
Set the value of a stylesheet parameter
name
- the name of the stylesheet parameter, as a QNamevalue
- the value of the stylesheet parameter, or null to clear a previously set value
setSource
public void setSource(Source source)
throws SaxonApiException
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.
source
- the principal source document for the transformation
transform
public void transform()
throws SaxonApiException
Perform the transformation. If this method is used, a destination must have been supplied
previously