RE: [xsl] Grouping is not working that great over here

Subject: RE: [xsl] Grouping is not working that great over here
From: Américo Albuquerque <aalbuquerque@xxxxxxxxxxxxxxxx>
Date: Mon, 14 Apr 2003 14:17:36 +0100
Hi

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Matts Isuls
> Sent: Friday, April 11, 2003 6:32 AM
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> 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


Current Thread