Saxon.Api

Class DocumentBuilder

Class DomDestination

Class DynamicContext

Class DynamicError

Class EmptyEnumerator

Class ExtensionFunctionCall

Class ExtensionFunctionDefinition

Class NullDestination

Class Processor

Class QName

Class SchemaManager

Class SchemaValidator

Class Serializer

Class StaticContext

Class StaticError

Class TextWriterDestination

Class XPathCompiler

Class XPathExecutable

Class XPathSelector

Class XQueryCompiler

Class XQueryEvaluator

Class XQueryExecutable

Class XdmAnyFunctionType

Class XdmAnyItemType

Class XdmAnyNodeType

Class XdmAtomicType

Class XdmAtomicValue

Class XdmDestination

Class XdmEmptySequence

Class XdmItem

Class XdmItemType

Class XdmNode

Class XdmNodeKind

Class XdmSequenceType

Class XdmValue

Class XmlDestination

Class XsltCompiler

Class XsltExecutable

Class XsltTransformer

Enum RecoveryPolicy

Enum SchemaValidationMode

Enum TreeModel

Enum WhitespacePolicy

Enum XdmAxis

Interface IMessageListener

Interface IQueryResolver

Interface IResultDocumentHandler

Interface IXdmEnumerator

Interface IXmlLocation

Interface SchemaResolver

 

Saxon.Api
Class XsltTransformer


public class XsltTransformer
implements 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 should 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.


Property Summary
 XdmNode InitialContextNode

The initial context item for the stylesheet.

 QName InitialMode

The initial mode for the stylesheet. This is either a QName, for a named mode, or null, for the unnamed (default) mode.

 QName InitialTemplate

The initial template for the stylesheet. This is either a QName, for a named template, or null, if no initial template has been set.

 Uri BaseOutputUri

The base output URI, which acts as the base URI for resolving the href attribute of xsl:result-document.

 RecoveryPolicy RecoveryPolicy
 SchemaValidationMode SchemaValidationMode

The SchemaValidationMode to be used in this transformation, especially for documents loaded using the doc(), document(), or collection() functions.

 XmlResolver InputXmlResolver

The XmlResolver to be used at run-time to resolve and dereference URIs supplied to the doc() and document() functions.

 IResultDocumentHandler ResultDocumentHandler

The IResultDocumentHandler to be used at run-time to process the output produced by any xsl:result-document instruction with an href attribute.

 IMessageListener MessageListener Listener for messages output using <xsl:message>.

The caller may supply a message listener before calling Run; the processor will then invoke the listener once for each message generated during the transformation. Each message will be output as an object of type XdmNode representing a document node.

If no message listener is supplied by the caller, message information will be written to the standard error stream.

 Stream TraceFunctionDestination Destination for output of messages using <trace()>.

If no message listener is supplied by the caller, message information will be written to the standard error stream.

 Controller Implementation

Escape hatch to the underlying Java implementation

 
Method Summary
 void SetInputStream(System.IO.Stream input, System.Uri baseUri)

Supply the principal input document for the transformation in the form of a stream.

 void SetParameter(QName name, XdmValue value)

Set the value of a stylesheet parameter.

 void Run(XmlDestination destination)

Run the transformation, sending the result to a specified destination.

 
Property Detail

InitialContextNode

public XdmNode InitialContextNode {get; set; }

The initial context item for the stylesheet.

This may be either a node or an atomic value. Most commonly it will be a document node, which might be constructed using the Build method of the DocumentBuilder object.

Note that this can be inefficient if the stylesheet uses xsl:strip-space to strip whitespace, or input-type-annotations="strip" to remove type annotations, since this will result in the transformation operating on a virtual document implemented as a view or wrapper of the supplied document.


InitialMode

public QName InitialMode {get; set; }

The initial mode for the stylesheet. This is either a QName, for a named mode, or null, for the unnamed (default) mode.


InitialTemplate

public QName InitialTemplate {get; set; }

The initial template for the stylesheet. This is either a QName, for a named template, or null, if no initial template has been set.


BaseOutputUri

public Uri BaseOutputUri {get; set; }

The base output URI, which acts as the base URI for resolving the href attribute of xsl:result-document.


RecoveryPolicy

public RecoveryPolicy RecoveryPolicy {get; set; }

SchemaValidationMode

public SchemaValidationMode SchemaValidationMode {get; set; }

The SchemaValidationMode to be used in this transformation, especially for documents loaded using the doc(), document(), or collection() functions.


InputXmlResolver

public XmlResolver InputXmlResolver {get; set; }

The XmlResolver to be used at run-time to resolve and dereference URIs supplied to the doc() and document() functions.


ResultDocumentHandler

public IResultDocumentHandler ResultDocumentHandler {get; set; }

The IResultDocumentHandler to be used at run-time to process the output produced by any xsl:result-document instruction with an href attribute.

In the absence of a user-supplied result document handler, the href attribute of the xsl:result-document instruction must be a valid relative URI, which is resolved against the value of the BaseOutputUri property, and the resulting absolute URI must identify a writable resource (typically a file in filestore, using the file: URI scheme).


MessageListener

public IMessageListener MessageListener {get; set; }
Listener for messages output using <xsl:message>.

The caller may supply a message listener before calling Run; the processor will then invoke the listener once for each message generated during the transformation. Each message will be output as an object of type XdmNode representing a document node.

If no message listener is supplied by the caller, message information will be written to the standard error stream.

Each message is presented as an XML document node. Calling ToString() on the message object will usually generate an acceptable representation of the message.

When the <xsl:message> instruction specifies terminate="yes", the message is first notified using this interface, and then an exception is thrown which terminates the transformation.


TraceFunctionDestination

public Stream TraceFunctionDestination {get; set; }
Destination for output of messages using <trace()>.

If no message listener is supplied by the caller, message information will be written to the standard error stream.

The supplied destination is ignored if a TraceListener is in use.


Implementation

public Controller Implementation {get; }

Escape hatch to the underlying Java implementation


Method Detail

SetInputStream

public void SetInputStream(System.IO.Stream input,
                      System.Uri baseUri)

Supply the principal input document for the transformation in the form of a stream.

If this method is used, the InitialContextNode is ignored.

The supplied stream will be consumed by the Run() method. Closing the input stream after use is the client's responsibility.

A base URI must be supplied in all cases. It is used to resolve relative URI references appearing within the input document.

Schema validation is applied to the input document according to the value of the SchemaValidationMode property.

Whitespace stripping is applied according to the value of the xsl:strip-space and xsl:preserve-space declarations in the stylesheet.

Parameters:
input -
The stream containing the source code of the principal input document to the transformation. The document node at the root of this document will be the initial context node for the transformation.
baseUri -
The base URI of the principal input document. This is used for example by the document() function if the document contains links to other documents in the form of relative URIs.

SetParameter

public void SetParameter(QName name,
                    XdmValue value)

Set the value of a stylesheet parameter.

Parameters:
name -
The name of the parameter, expressed as a QName. If a parameter of this name has been declared in the stylesheet, the given value will be assigned to the variable. If the variable has not been declared, calling this method has no effect (it is not an error).
value -
The value to be given to the parameter. If the parameter declaration defines a required type for the variable, then this value will be converted in the same way as arguments to function calls (for example, numeric promotion is applied).

Run

public void Run(XmlDestination destination)

Run the transformation, sending the result to a specified destination.

Parameters:
destination -
The destination for the results of the stylesheet. The class XmlDestination is an abstraction that allows a number of different kinds of destination to be specified.