|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to group a list 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






