Subject: Re: [xsl] XML grouping by attribute using Muenchian method? From: "M. David Peterson" <m.david@xxxxxxxxxx> Date: Wed, 26 Nov 2003 03:36:29 -0700 |
dont make this harder than it is.. <xsl:variable name="someName" select="book/@type = 'myshelf'"/> Best of luck... M. ----- Original Message ----- From: "Kaarle Kaila" <kaarle.kaila@xxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Wednesday, November 26, 2003 3:17 AM 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, Kaarle Kaila | Thread | Re: [xsl] XML grouping by attribute, David Carlisle |
Re: [xsl] Insert <options> from XML, David Carlisle | Date | Re: [xsl] Build hierarchies, David Carlisle |
Month |