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

Re: How to group a list twice

Subject: Re: How to group a list twice
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 28 May 2001 22:11:03 +0100
key xsl group twice
Hi Michael,

> but I don't know how to get the 2nd grouping working. Creating a key
> element for <secondLevel> and calling the template inside of the
> first template seems not to work.

I assume that you've got a number of record elements, each of which
has a firstLevel, secondLevel and thirdLevel element child.  Grouping
the second level follows the same principles as grouping the first
level, but rather than have a key that indexes only the first level,
you have to index the second *and first* level by concatenating their
values together:

<xsl:key name="class2"
         match="record"
         use="concat(firstLevel, ':', secondLevel)" />

Then, within the template for the firstLevel, you need to apply
templates to the records that have unique values for the concatenated
value:

<xsl:template match="record" mode="classList">
   <xsl:value-of select="firstLevel" />
   <xsl:apply-templates mode="classList2" />
      select="key('class', firstLevel)
                 [generate-id() =
                  generate-id(key('class2', concat(firstLevel, ':',
                                                   secondLevel))[1])]" />
</xsl:template>

And then, of course, a template to match the records in classList2
mode and give their values:

<xsl:template match="record" mode="classList2">
   <xsl:value-of select="secondLevel" />
   <xsl:for-each select="key('class2',
                             concat(firstLevel, ':', secondLevel))">
      <xsl:value-of select="thirdLevel" />
   </xsl:for-each>
</xsl:template>

I hope that helps,

Jeni

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



 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.