XsltSettings.TrustedXslt 属性

定义

获取一个 XsltSettings 对象,该对象启用对 XSLT document() 函数和嵌入式脚本块的支持。

public:
 static property System::Xml::Xsl::XsltSettings ^ TrustedXslt { System::Xml::Xsl::XsltSettings ^ get(); };
public static System.Xml.Xsl.XsltSettings TrustedXslt { get; }
member this.TrustedXslt : System.Xml.Xsl.XsltSettings
Public Shared ReadOnly Property TrustedXslt As XsltSettings

属性值

XsltSettings

XsltSettings 对象,其 EnableDocumentFunctionEnableScript 属性设置为 true

示例

以下示例加载支持 XSLT document() 函数和嵌入脚本块功能的样式表。

// Create a resolver and specify the necessary credentials.
XmlSecureResolver resolver = new XmlSecureResolver(new XmlUrlResolver(), "http://serverName/data/");
System.Net.NetworkCredential myCred;
myCred  = new System.Net.NetworkCredential(UserName,SecurelyStoredPassword,Domain);
resolver.Credentials = myCred;

// Create the XslCompiledTransform object and load the style sheet.
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load("http://serverName/data/script.xsl", XsltSettings.TrustedXslt, resolver);
' Create a resolver and specify the necessary credentials.
Dim resolver As New XmlSecureResolver(New XmlUrlResolver(), "http://serverName/data/")
Dim myCred As System.Net.NetworkCredential
myCred = New System.Net.NetworkCredential(UserName, SecurelyStoredPassword, Domain)
resolver.Credentials = myCred
        
' Create the XslCompiledTransform object and load the style sheet.
Dim xslt As New XslCompiledTransform()
xslt.Load("http://serverName/data/script.xsl", XsltSettings.TrustedXslt, resolver)

注解

重要

只有要求脚本支持并且处于完全可信的环境下时,才应启用 XSLT 脚本。 如果启用函数document(),可以通过将对象Transform传递给XmlSecureResolver方法来限制可访问的资源。

适用于

另请参阅