RE: [xsl] Grouping the same set by multiple criteria

Subject: RE: [xsl] Grouping the same set by multiple criteria
From: Américo Albuquerque <aalbuquerque@xxxxxxxxxxxxxxxx>
Date: Wed, 28 May 2003 19:05:00 +0100

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Erika Marlow
> Sent: Wednesday, May 28, 2003 3:49 PM
> To: XSL List
> Subject: [xsl] Grouping the same set by multiple criteria
> Hello.  I'm trying to group a set of transactions by date 
> then site then payer. Then I have to count how many are in 
> each group, i.e., how many total transactions by date, how 
> many in a date group are from a specific site, and how many 
> in a date/site group are the same payer.  I have used the 
> Muenchian technique to find the unique groups, but I am stuck 
> on how to get the counts for the different groupings.  I can 
> find how many unique dates there are, but not how many 
> transactions are in a given date group.  Is this possible with XSL?

Try this:

 <xsl:key name="G1" match="transaction"
 <xsl:key name="G2" match="transaction"
 <xsl:key name="G3" match="transaction"
',original_request/inquiry/site,' ',original_request/inquiry/payer)"/>
 <xsl:key name="payers" match="payer" use="."/>
 <xsl:template match="log">
inquiry/@date))]" mode="G1"/>
 <xsl:template match="transaction" mode="G1">
  <!-- do whatever with the date, here i'm just displaying the value -->
  <xsl:value-of select="original_request/inquiry/@date"/>
  <!-- here i'm applying level2 group -->
',original_request/inquiry/site)))]" mode="G2"/>
  <xsl:text>Total: </xsl:text>
  <!-- the Total is the count of the current group -->
 <xsl:template match="transaction" mode="G2">
  <xsl:text>Site: </xsl:text>
  <xsl:value-of select="original_request/inquiry/site"/>
  <xsl:text> transactions: </xsl:text>
  <!-- counting transactions of the current group -->
  I can't apply as before because you want all payers displayed,
  so i use the payers key to group by unique payers and pass the current
date and site as parameters.
rate-id(key('payers',.))]" mode="G3">
   <xsl:with-param name="date" select="original_request/inquiry/@date"/>
   <xsl:with-param name="site" select="original_request/inquiry/site"/>
 <xsl:template match="payer" mode="G3">
  <xsl:param name="date"/>
  <xsl:param name="site"/>
  <xsl:text>  Payer: </xsl:text>
  <xsl:value-of select="."/>
  <xsl:text> transactions: </xsl:text>
  <!-- use the parameters date and site in the G3 key to get the correct
values for the count -->
  <xsl:value-of select="count(key('G3',concat($date,' ',$site,'

Hope this helps you.

 XSL-List info and archive:

Current Thread