Principal output
When a transformation is run from the command line, the destination of the
principal output is given by the -o
option, and defaults to the standard
output stream (that is, the console). The output is always serialized; the format
of the serialization is determined by xsl:output declarations within
the stylesheet itself, or by options such as !indent=yes
on the command line.
Command line options take precedence.
When running from an application, the destination of the principal output is controlled using the API:
In the JAXP interface, the
Transformer.transform()
method takes aResult
object as a parameter. For serialized output, supply aStreamResult
; for tree output, supply aSAXResult
,DOMResult
, orStAXResult
. Raw output is not possible, since JAXP was designed for XSLT 1.0.Saxon also supplies more specialized implementations of the
Result
interface such as JDOM2Writer, XOMWriter, and DOM4JWriter for writing to third party tree models.More generally, Saxon's internal Receiver interface implements a general-purpose push pipeline, and
Receiver
extendsResult
so anyReceiver
can be used as the target of a transformation.In the Java s9api interface, transformation output is sent to a Destination object, which has multiple implementations.
For serialized output, supply a Serializer, which allows you to set serialization options that override the parameters in the
xsl:output
declaration.You can capture the raw output of the transformation as an XdmValue by supplying a RawDestination.
All other options produce tree output. These include the XdmDestination for building a tree, the SAXDestination which wraps a SAX
ContentHandler
, and the DOMDestination for building a DOM in memory. There is also a NullDestination which discards the output, and a TeeDestination which duplicates it.If you want to perform further processing on the output, you can send it to a SchemaValidator for validation, or to an XsltTransformer for further transformation.
In the C# Saxon.Api interface, transformation output is sent to an IDestination object, which has multiple implementations.
For serialized output, supply a Serializer, which allows you to set serialization options that override the parameters in the
xsl:output
declaration.You can capture the raw output of the transformation as an XdmValue by supplying a RawDestination.
All other options produce tree output. These include the XdmDestination for building a tree, the XmlWriterDestination which wraps a
System.Xml.XmlWriter
, and the DomDestination for building a DOM in memory. There is also a NullDestination which discards the output, and aTeeDestination
which duplicates it.If you want to perform further processing on the output, you can send it to a SchemaValidator for validation, or to an XsltTransformer for further transformation.