Class DocumentBuilder
Class DomDestination
Class DynamicError
Class NullDestination
Class Processor
Class QName
Class SchemaManager
Class SchemaValidator
Class SequenceEnumerator
Class Serializer
Class StaticError
Class TextWriterDestination
Class XPathCompiler
Class XPathExecutable
Class XPathSelector
Class XQueryCompiler
Class XQueryEvaluator
Class XQueryExecutable
Class XdmAtomicValue
Class XdmDestination
Class XdmEmptySequence
Class XdmItem
Class XdmNode
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 IXmlLocation
Interface SchemaResolver
public class XsltCompiler
An XsltCompiler
object allows XSLT 2.0 stylesheets to be compiled.
The compiler holds information that represents the static context
for the compilation.
To construct an XsltCompiler
, use the factory method
NewXsltCompiler
on the Processor
object.
An XsltCompiler
may be used repeatedly to compile multiple
queries. Any changes made to the XsltCompiler
(that is, to the
static context) do not affect queries that have already been compiled.
An XsltCompiler
may be used concurrently in multiple threads, but
it should not then be modified once initialized.
Property Summary | |
---|---|
Uri |
BaseUri
The base URI of the stylesheet, which forms part of the static context
of the stylesheet. This is used for resolving any relative URIs appearing
within the stylesheet, for example in |
|
XmlResolver An XmlResolver, which will be used to resolve URI references while compiling a stylesheet |
IList |
ErrorList List of errors. The caller should supply an empty list before calling Compile; the processor will then populate the list with error information obtained during the compilation. Each error will be included as an object of type StaticError. If no error list is supplied by the caller, error information will be written to the standard error stream. |
Method Summary | |
---|---|
XsltExecutable |
Compile(System.IO.Stream input) Compile a stylesheet supplied as a Stream. |
XsltExecutable |
Compile(System.IO.TextReader input) Compile a stylesheet supplied as a TextReader. |
XsltExecutable |
Compile(System.Uri uri) Compile a stylesheet, retrieving the source using a URI. |
XsltExecutable |
Compile(System.Xml.XmlReader ) Compile a stylesheet, delivered using an XmlReader. |
XsltExecutable |
Compile(XdmNode )
Compile a stylesheet, located at an XdmNode. This may be a document node whose
child is an |
XsltExecutable |
CompileAssociatedStylesheet(XdmNode source) Locate and compile a stylesheet identified by an <?xml-stylesheet?> processing instruction within a source document. |
Property Detail |
---|
public Uri BaseUri {get; set; }
The base URI of the stylesheet, which forms part of the static context
of the stylesheet. This is used for resolving any relative URIs appearing
within the stylesheet, for example in xsl:include
and xsl:import
declarations, in schema locations defined to xsl:import-schema
,
or as an argument to the document()
or doc()
function.
This base URI is used only if the input supplied to the Compile
method
does not provide its own base URI. It is therefore used on the version of the
method that supplies input from a Stream
. On the version that supplies
input from an XmlReader
, this base URI is used only if the XmlReader
does not have its own base URI.
public XmlResolver {get; set; }
An XmlResolver, which will be used to resolve URI references while compiling a stylesheet
If no XmlResolver
is set for the XsltCompiler
, the XmlResolver
is used that was set on the Processor
at the time NewXsltCompiler
was called.
public IList ErrorList {get; set; }
List of errors. The caller should supply an empty list before calling Compile; the processor will then populate the list with error information obtained during the compilation. Each error will be included as an object of type StaticError. If no error list is supplied by the caller, error information will be written to the standard error stream.
By supplying a custom List with a user-written add() method, it is possible to intercept error conditions as they occur.
Method Detail |
---|
public XsltExecutable Compile(System.IO.Stream input)
Compile a stylesheet supplied as a Stream.
If the stylesheet contains any xsl:include
or xsl:import
declarations,
then the BaseURI
property must be set to allow these to be resolved.
The stylesheet is contained in the part of the input stream between its current position and the end of the stream. It is the caller's responsibility to close the input stream after use. If the compilation succeeded, then on exit the stream will be exhausted; if compilation failed, the current position of the stream on exit is undefined.
Parameters:input
-
XsltExecutable
which represents the compiled stylesheet object.
The XsltExecutable may be loaded as many times as required, in the same or a different
thread. The XsltExecutable
is not affected by any changes made to the XsltCompiler
once it has been compiled.
public XsltExecutable Compile(System.IO.TextReader input)
Compile a stylesheet supplied as a TextReader.
If the stylesheet contains any xsl:include
or xsl:import
declarations,
then the BaseURI
property must be set to allow these to be resolved.
The stylesheet is contained in the part of the input stream between its current
position and the end of the stream. It is the caller's responsibility to close the
TextReader
after use. If the compilation succeeded, then on exit the stream will be
exhausted; if compilation failed, the current position of the stream on exit is
undefined.
input
-
TextReader
containing the source text of the stylesheet
XsltExecutable
which represents the compiled stylesheet object.
The XsltExecutable may be loaded as many times as required, in the same or a different
thread. The XsltExecutable
is not affected by any changes made to the XsltCompiler
once it has been compiled.
public XsltExecutable Compile(System.Uri uri)
Compile a stylesheet, retrieving the source using a URI.
The document located via the URI is parsed using the System.Xml
parser. This
URI is used as the base URI of the stylesheet: the BaseUri
property of the
Compiler
is ignored.
uri
-
XsltExecutable
which represents the compiled stylesheet object.
The XsltExecutable may be run as many times as required, in the same or a different
thread. The XsltExecutable
is not affected by any changes made to the XsltCompiler
once it has been compiled.
public XsltExecutable Compile(System.Xml.XmlReader )
Compile a stylesheet, delivered using an XmlReader.
The XmlReader
is responsible for parsing the document; this method builds a tree
representation of the document (in an internal Saxon format) and compiles it.
If the XmlReader
is an XmlTextReader
, Saxon will set its Normalization
property to true, and will wrap it in a (non-validating) XmlValidatingReader
to ensure
that entity references are expanded.
If the XmlReader
has a BaseUri
property, then that property determines
the base URI of the stylesheet module, which is used when resolving any xsl:include
or xsl:import
declarations. If the XmlReader
has no BaseUri
property, then the BaseUri
property of the Compiler
is used instead.
An ArgumentNullException
is thrown if this property has not been supplied.
XsltExecutable
which represents the compiled stylesheet object.
The XsltExecutable may be run as many times as required, in the same or a different
thread. The XsltExecutable
is not affected by any changes made to the XsltCompiler
once it has been compiled.
public XsltExecutable Compile(XdmNode )
Compile a stylesheet, located at an XdmNode. This may be a document node whose
child is an xsl:stylesheet
or xsl:transform
element, or it may be
the xsl:stylesheet
or xsl:transform
element itself.
XsltExecutable
which represents the compiled stylesheet object.
The XsltExecutable may be run as many times as required, in the same or a different
thread. The XsltExecutable
is not affected by any changes made to the XsltCompiler
once it has been compiled.
public XsltExecutable CompileAssociatedStylesheet(XdmNode source)
Locate and compile a stylesheet identified by an <?xml-stylesheet?> processing instruction within a source document.
There are some limitations in the current implementation. The media type is ignored, as are the other parameters of the xml-stylesheet instruction. The href attribute must either reference an embedded stylesheet within the same document or a non-embedded external stylesheet.
Parameters:source
-
XsltExecutable
which represents the compiled stylesheet object.