XsltArgumentList::AddExtensionObject Method (String^, Object^)
Adds a new object to the XsltArgumentList and associates it with the namespace URI.
Assembly: System.Xml (in System.Xml.dll)
Parameters
- namespaceUri
-
Type:
System::String^
The namespace URI to associate with the object. To use the default namespace, specify an empty string.
- extension
-
Type:
System::Object^
The object to add to the list.
| Exception | Condition |
|---|---|
| ArgumentException | The namespaceUri is either null or http://www.w3.org/1999/XSL/Transform The namespaceUri already has an extension object associated with it. |
| SecurityException | The caller does not have sufficient permissions to call this method. |
The params keyword, which allows an unspecified number of parameters to be passed, is currently not supported. XSLT style sheets that utilize methods defined with the params keyword does not work correctly. For more information, see params (C# Reference).
In the following example, the style sheet uses an XSLT extension object to convert the book price.
The example uses the following data files as input.
books.xml
<bookstore> <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0"> <title>The Autobiography of Benjamin Franklin</title> <author> <first-name>Benjamin</first-name> <last-name>Franklin</last-name> </author> <price>8.99</price> </book> <book genre="novel" publicationdate="1967" ISBN="0-201-63361-2"> <title>The Confidence Man</title> <author> <first-name>Herman</first-name> <last-name>Melville</last-name> </author> <price>11.99</price> </book> <book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6"> <title>The Gorgias</title> <author> <name>Plato</name> </author> <price>9.99</price> </book> </bookstore>
prices.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:myObj="urn:price-conv"> <!--Price conversion factor--> <xsl:param name="conv" select="1.15"/> <xsl:template match="bookstore"> <bookstore> <xsl:for-each select="book"> <book> <xsl:copy-of select="node()"/> <new-price> <xsl:value-of select="myObj:NewPriceFunc(./price, $conv)"/> </new-price> </book> </xsl:for-each> </bookstore> </xsl:template> </xsl:stylesheet>
Available since 1.1