I'm trying to make a table with counts grouped by labels. I would like to count how many times each levels of "standings_level" are in my file.
Here is an excerpt of my XML file :
<entries>
<entry>
<standings_levels>
<standings_level>4</standings_level>
</standings_levels>
</entry>
<entry>
<standings_levels>
<standings_level>3</standings_level>
</standings_levels>
</entry>
....
</entries>
I tried with for-each-group
in xsl 2.0 :
<xsl:for-each-group select="entries/entry/standings_levels/standings_level" group-by=".">
<tr>
<td>
<xsl:value-of select="current-grouping-key()"/>
</td>
<td>
<xsl:value-of select="count(current-group())"/>
</td>
</tr>
</xsl:for-each-group>
But it doesn't return anything, what am I doing wrong ?
Here is my full XSL file.
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="../include/template.xsl" />
<xsl:template match="/">
<html lang="en">
<xsl:call-template name="header" />
<body>
<xsl:call-template name="barreMenu" />
<div id="wrap">
<div class="container">
<table class="table table-bordered table-hover table-striped" id="tableTest">
<thead>
<tr>
<th>Label</th>
<th>Count</th>
</tr>
</thead>
<tbody>
<xsl:for-each-group select="entries/entry/standings_levels/standings_level" group-by=".">
<tr>
<td>
<xsl:value-of select="current-grouping-key()"/>
</td>
<td>
<xsl:value-of select="count(current-group())"/>
</td>
</tr>
</xsl:for-each-group>
</tbody>
</table>
</div><!-- /.container -->
</div>
<xsl:call-template name="footer" />
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Thanks for any help.