XslCompiledTransform.Transform Method (String, String)


Executes the transform using the input document specified by the URI and outputs the results to a file.

Namespace:   System.Xml.Xsl
Assembly:  System.Xml (in System.Xml.dll)

member Transform : 
        inputUri:string *
        resultsFile:string -> unit


Type: System.String

The URI of the input document.

Type: System.String

The URI of the output file.

Exception Condition

The inputUri or resultsFile value is null.


There was an error executing the XSLT transform.


The input document cannot be found.


The inputUri or resultsFile value includes a filename or directory cannot be found.


The inputUri or resultsFile value cannot be resolved.


An error occurred while processing the request


inputUri or resultsFile 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 and output documents. 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.

The following example executes a transform and outputs to a file.

No code example is currently available or this language may not be supported.

The sample uses the following two input files:


<?xml version='1.0'?>
<!-- This file represents a fragment of a book store inventory database -->
  <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
    <title>The Autobiography of Benjamin Franklin</title>
  <book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
    <title>The Confidence Man</title>
  <book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
    <title>The Gorgias</title>


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="bookstore">
      <TABLE BORDER="2">
        <xsl:apply-templates select="book"/>
<xsl:template match="book">
    <TD><xsl:value-of select="@ISBN"/></TD>
    <TD><xsl:value-of select="title"/></TD>
    <TD><xsl:value-of select="price"/></TD>

.NET Framework
Available since 2.0
Return to top