[xsl] grouping within for-each statements

Subject: [xsl] grouping within for-each statements
From: "Todd Binder" <todd_binder@xxxxxxxxxxx>
Date: Fri, 23 Nov 2001 12:44:24 -0500
i have the following XML code

 <entry id="1">
  <week opp="alpha">5</week>
  <week opp="alpha">45</week>
  <week opp="alpha">35</week>
  <week opp="beta">3</week>
  <week opp="beta">23</week>
  <week opp="alpha">37</week>
 </entry>
 <entry id="2">
  <week opp="alpha">5</week>
  <week opp="beta">87</week>
  <week opp="alpha">23</week>
  <week opp="beta">73</week>
  <week opp="beta">238</week>
  <week opp="beta">137</week>
 </entry>

and i am looking to get out put of the following, where for each entry, it
counts each occurance of week under it (based on opp attribute)

1.
alpha: 4
beta: 2

2.
alpha: 2
beta: 4


when i use the following XSL code to create the output table

<xsl:template match="week"
<tr>
<td><xsl:value-of select="@opp"/><xsl:text>: </xsl:text><xsl:value-of
select="count(@opp[.=current()])"/>
</tr>
</xsl:template>

 <xsl:template match="/">
<table>
<xsl:for-each select="entry">
<tr>
<td><xsl:value-of select="@id"/></td>
 <xsl:apply-templates select="week/@opp[not(.=following::week/@opp)]"/>
</tr>
<
</xsl:for-each>

</table>
</xsl:template>

i don't get the right output (it doesn't treat entry/@id = 1 as exclusive
from entry/@id=2, it seems taht the following:: statement is being too
restrictive, how can i get the following:: statement to only looking at
information in the node(s) specified by the for-each statement?

Todd Binder
todd_binder@xxxxxxxxxxx

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread