Loads the XSLT style sheet contained in the System.Xml.XmlReader. This method allows you to limit the permissions of the style sheet by specifying evidence.
- stylesheet
- An System.Xml.XmlReader object containing the style sheet to load.
- resolver
- The System.Xml.XmlResolver used to load any style sheets referenced in xsl:import and xsl:include elements. If this is null, external resources are not resolved.
- evidence
- The System.Security.Policy.Evidence set on the assembly generated for the script block in the XSLT style sheet.
The System.Xml.Xsl.XslTransform class is obsolete in the .NET Framework version 2.0. The System.Xml.Xsl.XslCompiledTransform class is the new XSLT processor. For more information, see Using the XslCompiledTransform Class and Migrating From the XslTransform Class.
System.Xml.Xsl.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.
This method loads the XSLT style sheet, including any style sheets referenced in xsl:include and xsl:import elements. The style sheet loads from the current node of the System.Xml.XmlReader through all its children. This enables you to use a portion of a document as the style sheet.
After the XslTransform.Load(System.Xml.XmlReader, System.Xml.XmlResolver, System.Security.Policy.Evidence) method returns, the System.Xml.XmlReader is positioned on the next node after the end of the style sheet. If the end of the document is reached, the System.Xml.XmlReader is positioned at the end of file (EOF).
If the style sheet contains entities, you should specify an System.Xml.XmlReader that can resolve entities (System.Xml.XmlReader.CanResolveEntity returns true). In this case, an System.Xml.XmlValidatingReader can be used.
For issues with the erload:System.Xml.Xsl.XslTransform.Load method and style sheets with embedded scripts, see article Q316755 in the Microsoft Knowledge Base at http://support.microsoft.com.
There are different ways to provide evidence. The following table describes what type of evidence to provide for common user scenarios.
The XSLT style sheet is self-contained or comes from a code base that you trust. |
Use the evidence from your assembly. Example XsltTransform xslt = new XslTransform(); xslt.Load(xslReader, resolver, this.GetType().Assembly.Evidence); |
The XSLT style sheet comes from an outside source. The origin of the source is known, and there is a verifiable URL. |
Create evidence using the URL. Example XsltTransform xslt = new XslTransform(); Evidence evidence = XmlSecureResolver.CreateEvidenceForUrl(stylesheetURL); xslt.Load(xslReader,resolver,evidence); |
The XSLT style sheet comes from an outside source. The origin of the source is not known. |
Set evidence to null. Script blocks are not processed, the XSLT document() function is not supported, and privileged extension objects are disallowed. Additionally, you can also set the resolver parameter to null. This ensures that xsl:import and xsl:include elements are not processed. |
The XSLT style sheet comes from an outside source. The origin of the source is not known, but you require script support. |
Request evidence from the caller. The API of the caller must provide a way to provide evidence, typically the System.Security.Policy.Evidence class. |