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[(_at_)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;
input xml (oXmlDoc):
<?xml version="1.0"?>
<Root>
<Elem ID="1">Number 1</Elem>
<Elem ID="2">Number 2</Elem>
<Elem ID="3">Number 3</Elem>
<Elem ID="4">Number 4</Elem>
<Elem ID="5">Number 5</Elem>
<Elem ID="6">Number 6</Elem>
</Root>
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/