Subject: Re: [xsl] XML grouping by attribute using Muenchian method? From: nicolas.m@xxxxxxxxxxx Date: Wed, 26 Nov 2003 14:10:52 +0100 |
Thanks, this is exactly what I was looking for. "Kaarle Kaila" <kaarle.kaila@xxxxxx> Sent by: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 26/11/2003 11:17 AM Please respond to xsl-list@xxxxxxxxxxxxxxxxxxxxxx To <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> cc Subject Re: [xsl] XML grouping by attribute using Muenchian method? hi, As I have just recently struggled with the similar task I give you my version of xslt thatr does about that here: ---------------------------------------------- <xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' > <xsl:key name="contacts-by-shelf" match="//book" use="@type" /> <xsl:template match="bookshelf"> <html> <head> <title>Shelfs</title> </head> <body> <h1>Index (fi)</h1> <table border="1"> <tr><td align="left">Shelf</td><td align="left">Book</td></tr> <xsl:for-each select="//book[count(. | key('contacts-by-shelf', @type)[1]) = 1]"> <xsl:sort select="@type" lang="fi"/> <tr><td align="left" valign="top"><xsl:apply-templates select="@type"/> </td><td> <xsl:for-each select="key('contacts-by-shelf',@type)"> <xsl:value-of select="@title" /><br/> </xsl:for-each> </td></tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> -------------------------------------- regards Kaarle Kaila -- Kaarle Kaila email: kaarle dot kaila at iki dot fi www.iki.fi/kaila ----- Original Message ----- From: <nicolas.m@xxxxxxxxxxx> To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx> Sent: Wednesday, November 26, 2003 11:10 AM Subject: [xsl] XML grouping by attribute using Muenchian method? > Hi > > This is my XML > > <bookshelf> > <book type="myshelf" title="some book" /> > <book type="yourshelf" title="some other book" /> > <book type="myshelf" title="yet some other book" /> > </bookshelf> > > I want to group these books by attribute "type" e.g. looking like this > > myshelf > some book > yet some other book > yourshelf > some other book > > I've been messing around with keys but I can't get the desired result... > > Thanks > Nicolas > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XML grouping by attribute, David Carlisle | Thread | RE: [xsl] XML grouping by attribute, Jarno . Elovirta |
Re: [xsl] Insert <options> from XML, David Carlisle | Date | [xsl] XSLT Error message, Gary Cornelius |
Month |