I have a basic XSLT example below. First I will show you the xml, then the xsl sheet, and then the ouput.
All these works fine.
But when I try to use a variable name, is not working.
XML>
<page>
<group>ColumnB</group>
<rows>
<row>
<ColumnA>any value</ColumnA>
<ColumnB>id1</ColumnB>
<ColumnC>any vlaue</ColumnC>
</row>
<row>
<ColumnA>any value</ColumnA>
<ColumnB>id2</ColumnB>
<ColumnC>any value</ColumnC>
</row>
<row>
<ColumnA>any value</ColumnA>
<ColumnB>id1</ColumnB>
<ColumnC>any value</ColumnC>
</row>
</rows>
</page>
XSL>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/page">
<!-- Any stuff -->
<!-- BODY -->
<xsl:call-template name="template2">
<xsl:with-param name="data" select="rows/row" />
</xsl:call-template>
<!-- Any stuff -->
</xsl:template>
<xsl:template name="template2">
<xsl

aram name="data" />
<xsl:variable name="filter-column" select="group"/>
<xsl:variable name="filter-identifier" select="$data[1]/*[name() = $filter-column]"/>
<xsl:variable name="filtered-data" select="$data[ColumnB = $filter-identifier]"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="$filter-column"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="$filter-identifier"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="count($filtered-data)"/>
</xsl:template>
</xsl:stylesheet>
OUTPUT:
ColumnB
id1
2
This is all fine, but where I try to use a variable. Instead of:
<xsl:variable name="filtered-data" select="$data[ColumnB = $filter-identifier]"/>
Use this(changing just ColumnB literal to its variable, that is the same content):
<xsl:variable name="filtered-data" select="$data[$filter-column = $filter-identifier]"/>
Does not work, because it comes up with this:
ColumnB
id1
0
Where the last number, should be 2.
Can any body help me with this?
Thanks!