Subject: Re: [xsl] Categorise Node by Unique Attribute From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Thu, 08 Jan 2009 13:15:14 +0100 |
I want to group nodes in an XML file, placing a heading above each category. The category is defined in an attribute which may be the same for a series of records. The code sample below shows what I want to do. I've been going round in circles trying combinations of variables, templates, for-each loops and I just can't seem to get a handle on the problem. Any help would be very gratefully received.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:key name="cat" match="book" use="concat(parent::author/@name, '|', @genre)"/>
<xsl:template match="/"> <html lang="en"> <head> <title>Books</title> </head> <body> <h1>Books</h1> <xsl:apply-templates select="authors/author"/> </body> </html> </xsl:template>
<xsl:template match="book"> <li> <xsl:value-of select="@name"/> </li> </xsl:template>
Read more about that on http://www.jenitennison.com/xslt/grouping/index.xml --
Martin Honnen http://JavaScript.FAQTs.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Categorise Node by Unique Att, William Warby | Thread | Re: [xsl] Categorise Node by Unique, William Warby |
[xsl] Categorise Node by Unique Att, William Warby | Date | Re: [xsl] how to extract text, tran, Ken Starks |
Month |