XsltArgumentList::AddParam Method (String^, String^, Object^)
Adds a parameter to the XsltArgumentList and associates it with the namespace qualified name.
Assembly: System.Xml (in System.Xml.dll)
Parameters
- name
-
Type:
System::String^
The name to associate with the parameter.
- namespaceUri
-
Type:
System::String^
The namespace URI to associate with the parameter. To use the default namespace, specify an empty string.
- parameter
-
Type:
System::Object^
The parameter value or object to add to the list.
| Exception | Condition |
|---|---|
| ArgumentException | The namespaceUri is either null or http://www.w3.org/1999/XSL/Transform. The name is not a valid name according to the W3C XML specification. The namespaceUri already has a parameter associated with it. |
The parameter should correspond to a W3C type. The following table shows the W3C types, either XPath or XSLT, and the corresponding.NET class.
W3C Type | Equivalent.NET Class (Type) |
|---|---|
String (XPath) | |
Boolean (XPath) | |
Number (XPath) | |
Result Tree Fragment (XSLT) | |
Node Set (XPath) | XPathNavigator[] |
Node* (XPath) |
*This is equivalent to a node set that contains a single node.
If the parameter object being invoked from within the style sheet is not one of the above, it is converted according to the following rules:
CLR numeric types are converted to Double.
IXPathNavigable types are converted to XPathNavigator. XPathNavigator[] is converted to XPathNodeIterator.
All other types throw an error.
The following example uses the AddParam method to create a parameter representing the current date and time.
The example uses the following two data files as input.
order.xml
<!--Represents a customer order--> <order> <book ISBN='10-861003-324'> <title>The Handmaid's Tale</title> <price>19.95</price> </book> <cd ISBN='2-3631-4'> <title>Americana</title> <price>16.95</price> </cd> </order>
order.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="date"/> <xsl:template match="/"> <order> <date><xsl:value-of select="$date"/></date> <total><xsl:value-of select="sum(//price)"/></total> </order> </xsl:template> </xsl:stylesheet>
Available since 1.1