|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Nodelist as input parameter to XSL stylesheet in .NET
Hi all,
I am sorry for this vendor-specific question, but I really hope that someone can help me out here. Using C# in .NET, I have an aspx file with an Xml control (Xml1). I try to pass a nodeset as a parameter to the xsl file that transform the xml document (oXmlDoc). This is not succesful. Can someone tell me what I am doing wrong, and how I am able to pass a nodelist to the stylesheet? Thanks in advance! Regards, Ragulf Pickaxe :-) C# code snippet: System.Xml.XmlDocument oXmlDoc = new System.Xml.XmlDocument(); oXmlDoc.LoadXml(sXml); // sXml is the string containing the XML System.Xml.XmlNodeList oList = oXmlDoc.SelectNodes("/Root/Elem[@ID='1' or @ID='3' or @ID='4']"); System.Xml.Xsl.XsltArgumentList args = new System.Xml.Xsl.XsltArgumentList(); args.AddParam("TestList", "", oList); Xml1.TransformArgumentList = args; Xml1.TransformSource = "Transform.xsl"; Xml1.Document=oXmlDoc;
Stylesheet (Transform.xsl): <?xml version="1.0" encoding="ISO-8859-1"> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="ISO-8859-1" indent="no"/> <xsl:param name="TestList"/> <xsl:template match="/">
<HTML><BODY>
TestList: <xsl:copy-of select="$TestList"/><br/>
<xsl:apply-templates select="Root"/>
</BODY></HTML>
</xsl:template> <xsl:template match="Root">
<table>
<xsl:apply-templates select="Elem"/>
</table>
</xsl:template> <xsl:template match="Elem">
<tr><td>
<xsl:value-of select="."/>
</td></tr>
</xsl:template>
</xsl:stylesheet>Output: TestList: System.Xml.XPath.XPathNodeList Number 1 Number 2 Number 3 Number 4 Number 5 Number 6 The data in the table is not important here. What is important is that I wanted the variable $TestList to contain a list of Elem nodes (those with ID one of 1,3,4) but instead it contains: System.Xml.XPath.XPathNodeList. _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today - it's FREE! hthttp://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








