XslTransform.Load Method (IXPathNavigable, XmlResolver)


Loads the XSLT style sheet contained in the IXPathNavigable.

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

public void Load(
	IXPathNavigable stylesheet,
	XmlResolver resolver


Type: System.Xml.XPath.IXPathNavigable

An object implementing the IXPathNavigable interface. In the .NET Framework, this can be either an XmlNode (typically an XmlDocument), or an XPathDocument containing the XSLT style sheet.

Type: System.Xml.XmlResolver

The XmlResolver used to load any style sheets referenced in xsl:import and xsl:include elements. If this is null, external resources are not resolved.

The XmlResolver is not cached after the Load method completes.

Exception Condition

The loaded resource is not a valid style sheet.


The style sheet contains embedded scripts, and the caller does not have UnmanagedCode permission.


The XslTransform class is obsolete in the .NET Framework version 2.0. The XslCompiledTransform class is the new XSLT processor. For more information, see Using the XslCompiledTransform Class and Migrating From the XslTransform Class.

XslTransform supports the XSLT 1.0 syntax. The XSLT style sheet must include the namespace declaration xmlns:xsl= http://www.w3.org/1999/XSL/Transform.

If the style sheet contains embedded scripting, the script is compiled to an assembly. The assembly has full trust. The recommended practice is to provide evidence using the Load(IXPathNavigable, XmlResolver, Evidence) method. For issues with the Load method and style sheets with embedded scripts, see article Q316755 in the Microsoft Knowledge Base at http://support.microsoft.com.


If the caller does not have UnmanagedCode permission, the embedded script is not compiled and a SecurityException is thrown. See SecurityPermission and SecurityPermissionFlag.UnmanagedCode for more information.

.NET Framework
Available since 1.1
Return to top