Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Resolving External XSLT Stylesheets and Documents

Resolving External XSLT Stylesheets and Documents

There are several times during a transformation when you may need to resolve external resources:

  • During the Load to locate an external style sheet.
  • During Load to resolve any <xsl:include> or <xsl:import> elements found in the style sheet.
  • During Transform to resolve any document() functions.

If authentication is required to access a network resource, use the Load methods that have an XmlResolver parameter to pass the XmlResolver object which has the necessary credential properties set.

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 resolutionTask required
During Load to locate the style sheet.Specify the overloaded Load method that takes, as a parameter, an XmlResolver if the style sheet is on a resource that requires credentials.
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 provide null (Nothing), the external resources are not resolved.
During a transform to resolve any document() functions.Specify the XmlResolver during the transform by using the XslTransform.Transform method that takes an XmlResolver argument.

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 method (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 transform process. If the document() function attempts to initiate an action that requires permissions not found in the set, an exception is thrown.

See Also

XSLT Transformations with the XslTransform Class | XslTransform Class Implements the XSLT Processor | Outputs from an XslTransform | XSLT Transformations Over Different Stores | XsltArgumentList for Stylesheet Parameters and Extension Objects | XSLT Stylesheet Scripting using <msxsl:script> | Support for the msxsl:node-set() Function | XPathNavigator in Transformations | XPathNodeIterator in Transformations | XPathDocument Input to XslTransform | XmlDataDocument Input to XslTransform | XmlDocument Input to XslTransform

Show:
© 2015 Microsoft