Resolving External XSLT Style Sheets and Documents
There are several times during a transformation when you may need to resolve external resources.
The XslTransform class is obsolete in the .NET Framework version 2.0. You can perform Extensible Stylesheet Language for Transformations (XSLT) transformations using the XslCompiledTransform class. See Using the XslCompiledTransform Class and Migrating From the XslTransform Class for more information.
There are several times during a transformation when you may need to resolve external resources:
If you have a custom XmlResolver that you want to use, or if you need to specify different credentials, the following table lists the task required, depending on when the external resource needs resolution.
What process requires resolution
During Load to locate the style sheet.
During Load to resolve <xsl:include> or <xsl:import>.
Specify the overloaded Load method that takes, as a parameter, an XmlResolver. The XmlResolver is used to load the style sheets referenced by the import or include statements. If you pass in null, the external resources are not resolved.
During a transformation to resolve any document() functions.
The document() function retrieves other XML resources from a style sheet, in addition to the initial XML data provided by the input stream. Since this function allows the inclusion of XML data that can be located elsewhere, an XmlResolver with a null value supplied to the Transform method prevents the document() function from executing. If you want to use the document() function, use the Transform method that takes an XmlResolver as a parameter, in addition to having the appropriate permission set.
For more information on the Load method and its use of the XmlResolver, see XslTransform.Load(String, XmlResolver). For more information on the XmlResolver class, see Resolving Resources Using the XmlResolver and XmlResolver Class.
When the Transform method is called, permissions are calculated against the evidence provided at load time, and that permission set is assigned to the entire transformation process. If the document() function attempts to initiate an action that requires permissions not found in the set, an exception is thrown.