Re: [xsl] Acheiving ..2nd level grouping but with different node structure ..

Subject: Re: [xsl] Acheiving ..2nd level grouping but with different node structure ..
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 24 Jul 2002 14:19:15 +0100
Hi Kumar,

> Here is my XSL with first level grouping extracting distinct regions
> and i am having problems grouping users within Region .

The secret of 2nd level grouping with the Muenchian method is to
create keys that combine the two things that you want to group by.
Your first level key is:

<xsl:key name="distinct-region" match="*" use="@reg"/>

(Though I think it would be better as:

<xsl:key name="distinct-region" match="los" use="@reg"/>

since that would limit it to only holding los elements.)

So your second level key should be something along the lines of:

<xsl:key name="distinct-region-and-user" match="los"
         use="concat(@reg, '+', @user)" />

Then, given that you've found a region ($reg), you can get all the
unique users in that region with:

  key('distinct-region', $reg)
    [generate-id() =
     generate-id(key('distinct-region-and-user',
                     concat($reg, '+', @user)))]

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread