This documentation is archived and is not being maintained.

XslCompiledTransform.Load Method (String, XsltSettings, XmlResolver)

Loads and compiles the XSLT style sheet specified by the URI. The XmlResolver resolves any XSLT import or include elements and the XSLT settings determine the permissions for the style sheet.

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

public void Load(
	string stylesheetUri,
	XsltSettings settings,
	XmlResolver stylesheetResolver


Type: System.String

The URI of the style sheet.

Type: System.Xml.Xsl.XsltSettings

The XsltSettings to apply to the style sheet. If this is null, the Default setting is applied.

Type: System.Xml.XmlResolver

The XmlResolver used to resolve the style sheet URI and any style sheets referenced in XSLT import and include elements.


The stylesheetUri or stylesheetResolver value is null.


The style sheet contains an error.


The style sheet cannot be found.


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


The stylesheetUri value cannot be resolved.


An error occurred while processing the request.


stylesheetUri is not a valid URI.


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 namespace.

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 following example loads a style sheet that is stored on a network resource. An XmlSecureResolver object specifies the credentials necessary to access the style sheet.

// Create the XslCompiledTransform object.
XslCompiledTransform xslt = new XslCompiledTransform();

// Create a resolver and set the credentials to use.
XmlSecureResolver resolver = new XmlSecureResolver(new XmlUrlResolver(), "http://serverName/data/");
resolver.Credentials = CredentialCache.DefaultCredentials;

// Load the style sheet.
xslt.Load("http://serverName/data/xsl/sort.xsl", null, resolver);

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