[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

grouping within for-each statements

Subject: grouping within for-each statements
From: "Todd Binder" <todd_binder@xxxxxxxxxxx>
Date: Fri, 23 Nov 2001 12:44:24 -0500
for each statements
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.