xsl-list
[Top] [All Lists]

RE: Grouping is not working that great over here

2003-04-14 06:17:36
Hi

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
Matts Isuls
Sent: Friday, April 11, 2003 6:32 AM
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: [xsl] Grouping is not working that great over here


Hi

Having problems grouping (first timer). Someone please help 
me out of this darkness.

(...)

Your main problem is that you are grouping by all 'payment' but you only
want to group by those that have the same parent 'payments'

To do that you'll have to change a little your key definition and your
for-each call.
<!-- you'll need the generate-id(parent::payments) because you want all
payment belonging to the same parent -->
<xsl:key name="mkey" match="payment[date]"
use="concat(generate-id(parent::payments),' ',date)"/>

(...)

<xsl:template match="parcel">
 <br/>        ------
 <!-- altered for-each -->
 <xsl:for-each
select="payments/payment[generate-id()=generate-id(key('mkey',concat(generat
e-id(parent::payments),' ' ,date))[1])]">
  <xsl:sort select="date" />
  <br/>
  <!-- here you'll just need to sum the amount of the keys nodeset -->
  <xsl:value-of select="date"/>::<xsl:value-of
select="sum(key('mkey',concat(generate-id(parent::payments),' '
,date))/amount)"/>
 </xsl:for-each>
</xsl:template>



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