.NET Framework Class Library
XslCompiledTransform..::.Load Method (XmlReader, XsltSettings, XmlResolver)

Compiles the XSLT style sheet contained in the XmlReader. 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)
Syntax

Visual Basic (Declaration)
Public Sub Load ( _
    stylesheet As XmlReader, _
    settings As XsltSettings, _
    stylesheetResolver As XmlResolver _
)
Visual Basic (Usage)
Dim instance As XslCompiledTransform
Dim stylesheet As XmlReader
Dim settings As XsltSettings
Dim stylesheetResolver As XmlResolver

instance.Load(stylesheet, settings, stylesheetResolver)
C#
public void Load(
    XmlReader stylesheet,
    XsltSettings settings,
    XmlResolver stylesheetResolver
)
Visual C++
public:
void Load(
    XmlReader^ stylesheet, 
    XsltSettings^ settings, 
    XmlResolver^ stylesheetResolver
)
JScript
public function Load(
    stylesheet : XmlReader, 
    settings : XsltSettings, 
    stylesheetResolver : XmlResolver
)

Parameters

stylesheet
Type: System.Xml..::.XmlReader
The XmlReader containing the style sheet.
settings
Type: System.Xml.Xsl..::.XsltSettings
The XsltSettings to apply to the style sheet. If this is nullNothingnullptra null reference (Nothing in Visual Basic), the Default setting is applied.
stylesheetResolver
Type: System.Xml..::.XmlResolver
The XmlResolver used to resolve any style sheets referenced in XSLT import and include elements. If this is nullNothingnullptra null reference (Nothing in Visual Basic), external resources are not resolved.
Exceptions

ExceptionCondition
ArgumentNullException

The stylesheet value is nullNothingnullptra null reference (Nothing in Visual Basic).

XsltException

The style sheet contains an error.

Remarks

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

The style sheet loads from the current node of the XmlReader through all its children. This enables you to use a portion of a document as the style sheet. After the Load method completes, the XmlReader is positioned on the next node after the end of the style sheet. If the end of the document is reached, the XmlReader is positioned at the end of file (EOF).

Examples

The following example loads a style sheet and enables support for XSLT scripting.

Visual Basic
' Create the XslCompiledTransform object.
Dim xslt As New XslCompiledTransform()

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

Dim reader As XmlReader = XmlReader.Create("http://serverName/data/xsl/sort.xsl")

' Create the XsltSettings object with script enabled.
Dim settings As New XsltSettings(False, True)

' Load the style sheet.
xslt.Load(reader, settings, resolver)
C#
// 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;

XmlReader reader = XmlReader.Create("http://serverName/data/xsl/sort.xsl");

// Create the XsltSettings object with script enabled.
XsltSettings settings = new XsltSettings(false,true);

// Load the style sheet.
xslt.Load(reader, settings, resolver);
Platforms

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.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0
See Also

Reference

Other Resources

Tags :


Page view tracker