XslCompiledTransform.Transform Method (String, XmlWriter)
Executes the transform using the input document specified by the URI and outputs the results to an XmlWriter.
Assembly: System.Xml (in System.Xml.dll)
- Type: System.String
The URI of the input document.
- Type: System.Xml.XmlWriter
The XmlWriter to which you want to output.
If the style sheet contains an xsl:output element, you should create the XmlWriter using the XmlWriterSettings object returned from the OutputSettings property. This ensures that the XmlWriter has the correct output settings.
The inputUri or results value is null.
There was an error executing the XSLT transform.
The inputUri value includes a filename or directory cannot be found.
The inputUri value cannot be resolved.
An error occurred while processing the request.
inputUri is not a valid URI.
There was a parsing error loading the input document.
This method uses a default XmlUrlResolver with no user credentials to resolve the input document and any instances of the XSLT document() function found in the style sheet. If any of these resources are located on a network resource that requires authentication, use the overload that takes an XmlResolver as one of its arguments and specify an XmlResolver with the necessary credentials.
An XmlReader with default settings is used to load the input document. DTD processing is disabled on the XmlReader. If you require DTD processing, create an XmlReader with this feature enabled, and pass it to the Transform method.
This method does not support the xsl:strip-space element. If your compiled style sheet included the xsl:strip-space element, you must use the Transform overload which takes an XmlReader as the input argument.
The following example executes an XSLT transformation and outputs to an XmlWriter object.
// Load the style sheet. XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load("output.xsl"); // Create the writer. XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = "\t"; XmlWriter writer = XmlWriter.Create("output.xml", settings); // Execute the transformation. xslt.Transform("books.xml", writer); writer.Close();
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.