Export (0) Print
Expand All

XslCompiledTransform.Load Method (String)

Loads and compiles the style sheet located at the specified URI.

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

public void Load(
	string stylesheetUri
)

Parameters

stylesheetUri
Type: System.String

The URI of the style sheet.

ExceptionCondition
ArgumentNullException

The stylesheetUri value is null.

XsltException

The style sheet contains an error.

FileNotFoundException

The style sheet cannot be found.

DirectoryNotFoundException

The stylesheetUri value includes a filename or directory that cannot be found.

WebException

The stylesheetUri value cannot be resolved.

-or-

An error occurred while processing the request.

UriFormatException

stylesheetUri is not a valid URI.

XmlException

There was a parsing error loading the style sheet.

The XslCompiledTransform class supports the XSLT 1.0 syntax. The XSLT style sheet must use the http://www.w3.org/1999/XSL/Transform namespace.

This method has the following behavior:

  • An XmlUrlResolver with no user credentials is used to resolve the style sheet URI, and process any xsl:import or xsl:include elements.

  • An XmlReader with default settings is used to load the style sheet. DTD processing is disabled on the XmlReader. If you require DTD processing, create an XmlReader with this feature enabled, and pass it to the Load method.

  • The document() function is disabled.

  • Embedded scripts are not supported.

You can use the Load(String, XsltSettings, XmlResolver) overload to specify an XmlResolver with the necessary authentication credentials, or to specify different XSLT settings.

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

// Load the style sheet.
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load("output.xsl");

// Execute the transform and output the results to a file.
xslt.Transform("books.xml", "books.html");

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft