Saxon API for .NET |

# XsltCompiler.Compile Method (XmlReader)

Compile a stylesheet, delivered using an XmlReader.

public XsltExecutable Compile(
XmlReader reader
);

#### Return Value

An `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.

#### Remarks

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.

#### See Also

XsltCompiler Class | Saxon.Api Namespace | XsltCompiler.Compile Overload List