XslCompiledTransform::Transform Method (String^, String^)
Executes the transform using the input document specified by the URI and outputs the results to a file.
Assembly: System.Xml (in System.Xml.dll)
Parameters
- inputUri
-
Type:
System::String^
The URI of the input document.
- resultsFile
-
Type:
System::String^
The URI of the output file.
| Exception | Condition |
|---|---|
| ArgumentNullException | The inputUri or resultsFile value is null. |
| XsltException | There was an error executing the XSLT transform. |
| FileNotFoundException | The input document cannot be found. |
| DirectoryNotFoundException | The inputUri or resultsFile value includes a filename or directory cannot be found. |
| WebException | The inputUri or resultsFile value cannot be resolved. -or- An error occurred while processing the request |
| UriFormatException | inputUri or resultsFile is not a valid URI. |
| XmlException | 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.
The sample uses the following two input files:
books.xml
<?xml version='1.0'?> <!-- This file represents a fragment of a book store inventory database --> <bookstore> <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0"> <title>The Autobiography of Benjamin Franklin</title> <author> <first-name>Benjamin</first-name> <last-name>Franklin</last-name> </author> <price>8.99</price> </book> <book genre="novel" publicationdate="1967" ISBN="0-201-63361-2"> <title>The Confidence Man</title> <author> <first-name>Herman</first-name> <last-name>Melville</last-name> </author> <price>11.99</price> </book> <book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6"> <title>The Gorgias</title> <author> <name>Plato</name> </author> <price>9.99</price> </book> </bookstore>
output.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="bookstore"> <HTML> <BODY> <TABLE BORDER="2"> <TR> <TD>ISBN</TD> <TD>Title</TD> <TD>Price</TD> </TR> <xsl:apply-templates select="book"/> </TABLE> </BODY> </HTML> </xsl:template> <xsl:template match="book"> <TR> <TD><xsl:value-of select="@ISBN"/></TD> <TD><xsl:value-of select="title"/></TD> <TD><xsl:value-of select="price"/></TD> </TR> </xsl:template> </xsl:stylesheet>
Available since 2.0