trigger_my_passion
New Member
I'm quite new to XSL, and I'm trying to dynamically reference nodes from an XML file using a template. To give a bit more information, I'm using Cast Iron to generate the initial XML, and it returns multiple Result Sets, some of them with multiple rows. A Sample XML is as follows:\[code\]<resultSets> <resultSet/> <resultSet> <row> <column1>1</column1> <column2>Hello</column2> </row> </resultSet> <resultSet> <row> <column1/> </row> <row> <column1/> </row> </resultSet></resultSets>\[/code\]So I'm trying to transform this into something that can be used by the customer. I thought of using a template with a few inputs to make my life easier. I wanted to design the template that by entering a number for the result set, a number for the row, and the name of the column, it would reference the data. The problem is, when I reference it, the resulting node doesn't get created. So my question is: How do I reference a Param as an Xml Node? Here is what I have for the template: \[code\]<xsl:template name="getData"> <xslaram name="resultset" select="0" /> <xslaram name="position" select="0" /> <xslaram name="column-name" select="''" /> <!-- Checking to see if Parameters were passed in. This seems to work correctly --> <xsl:if test="($resultset > 0)and($position > 0)and($column-name != '')"> <!-- Check to see if there are any rows in the resultSet. This seems to work correctly --> <xsl:if test="count(//resultSets/resultSet[position() = $resultset]/row[position() = $position]) > 0"> <!-- This part fails; nothing is referenced --> <xsl:value-of select="//resultSets/resultSet[position() = $resultset]/row[position() = $position][@name = $column-name]"/> </xsl:if> </xsl:if></xsl:template>\[/code\]Here is how I'm trying to reference it (as an example): This should return 'Hello' from the XML file (shouldn't it?)\[code\]<xsl:element name="SampleElement"> <xsl:call-template name="getData"> <xsl:with-param name="resultset" select="2" /> <xsl:with-param name="position" select="1" /> <xsl:with-param name="column-name" select="'column2'" /> </xsl:call-template></xsl:element>\[/code\]Sorry if my question is unclear or has been asked before, I didn't find anything.