Re: [xsl] Nodelist as input parameter to XSL stylesheet in .NET

Subject: Re: [xsl] Nodelist as input parameter to XSL stylesheet in .NET
From: Oleg Tkachenko <oleg@xxxxxxxxxxxxx>
Date: Wed, 22 Sep 2004 14:36:40 +0200
Ragulf Pickaxe wrote:

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?

In .NET XSLT data types are mapped to .NET types in the following way: string System.String boolean System.Boolean number System.Double RTF System.Xml.XPath.XPathNavigator node-set System.Xml.XPath.XPathNodeIterator

So to pass nodeset you have to pass an instance of the XPathNodeIterator class.

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']");

XPathNodeIterator oList = oXmlDoc.CreateNavigator().Select("/Root/Elem[@ID='1' or @ID='3' or @ID='4']");


--
Oleg Tkachenko
http://blog.tkachenko.com
Multiconn Technologies, Israel

Current Thread