System.Xml.Xsl.XslTransform Class

Transforms XML data using an Extensible Stylesheet Language for Transformations (XSLT) style sheet.

See Also: XslTransform Members

Syntax

[System.Obsolete]
public sealed class XslTransform

Remarks

Note:

The System.Xml.Xsl.XslTransform class is obsolete in the Microsoft .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 use the namespace http://www.w3.org/1999/XSL/Transform.

Additional arguments can also be added to the style sheet using the System.Xml.Xsl.XsltArgumentList class. This class contains input parameters for the style sheet and extension objects which can be called from the style sheet.

To transform XML data:

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]

Security Considerations

When creating an application that uses the System.Xml.Xsl.XslTransform class, you should be aware of the following items and their implications:

These security issues can be mitigated by not accepting System.Xml.Xsl.XslTransform objects, XSLT style sheets, or XML source data from untrusted sources.

Scripting Support

This class supports embedded scripting using the msxsl:script element.

In version 1.1 of the .NET Framework, the evidence of the style sheet determines what permissions are given to embedded scripts.

Semi-trusted callers: UnmanagedCode permission is required to compile the embedded script. ControlEvidence permission is required to provide System.Security.Policy.Evidence to the erload:System.Xml.Xsl.XslTransform.Load method. A System.Security.SecurityException is thrown if the caller does not have the necessary permissions. See System.Security.Permissions.SecurityPermission and System.Security.Permissions.SecurityPermissionFlag for more information.

The msxsl:script element has the following requirements:

Note It is recommended that you wrap script blocks in a CDATA section.

Example

 <msxsl:script implements-prefix='xy' language='C#'>
   <![CDATA[
   // Add code here.
   ]]>
 </msxsl:script>

Functions can be declared within the msxsl:script element. The following table shows the namespaces that are supported by default.

System

System classes.

System.Collection

Collection classes.

System.Text

Text handling classes.

System.Xml

Core XML classes.

System.Xml.Xsl

XSLT classes.

System.Xml.XPath

XML Path Language (XPath) classes.

The supplied arguments and return values defined by the script functions must be one of the World Wide Web Consortium (W3C) types listed below. The following table details the mapping between the W3C types, either XPath or XSLT, and the corresponding .NET Framework classes.

String (XPath)

System.String

Boolean (XPath)

System.Boolean

Number (XPath)

System.Double

Result Tree Fragment (XSLT)

System.Xml.XPath.XPathNavigator

Node Set (XPath)

System.Xml.XPath.XPathNodeIterator

If the script function utilizes one of the following numeric types: Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, or Decimal, these types are coerced to Double, which maps to the W3C XPath type number.

An exception is thrown when a function is called that cannot convert the argument result to one of the required types.

Note:

msxsl:script and msxsl:node-list are the only functions from the urn:schemas-microsoft-com:xslt namespace that are supported by the System.Xml.Xsl.XslTransform class.

System.Xml.Xsl.XslTransform has the ability to utilize common language runtime (CLR) code as an extension mechanism. This is accomplished by passing an instance of a class to the System.Xml.Xsl.XslTransform class and calling its public methods within an XSLT style sheet. Methods that are defined with the params keyword, which allows an unspecified number of parameters to be passed, do not work correctly in this scenario. See params (C# Programmers Reference) for more details.

For more information see XSLT Transformations with the XslTransform Class.

Requirements

Namespace: System.Xml.Xsl
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0