Subject: Re: [xsl] XML grouping by attribute using Muenchian method? From: "Kaarle Kaila" <kaarle.kaila@xxxxxx> Date: Wed, 26 Nov 2003 12:17:13 +0200 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XML grouping by attribute usi, nicolas . m | Thread | Re: [xsl] XML grouping by attribute, M. David Peterson |
[xsl] Insert <options> from XML, Fran | Date | [xsl] Build hierarchies, Steven Lloyd |
Month |