Subject: RE: [xsl] sorting and grouping From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx> Date: Sat, 3 Jul 2004 06:40:46 -0700 (PDT) |
Hi Mick, Please find below the Muenchian Grouping solution to the problem described by you - <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:key name="by-jan" match="person[birthmonth = 'January']" use="birthday"/> <xsl:template match="/persons"> <xsl:for-each select="person[birthmonth = 'January']"> <xsl:sort select="birthday" data-type="number"/> <xsl:if test="generate-id(.) = generate-id(key('by-jan', birthday)[1])"> <xsl:value-of select="birthday"/><xsl:text>
</xsl:text> <xsl:for-each select="key('by-jan', birthday)"> <xsl:sort select="name"/> <xsl:value-of select="name"/><xsl:text>
</xsl:text> </xsl:for-each> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> Regards, Mukul --- "m.vanrootseler" <m.vanrootseler@xxxxxxxxx> wrote: > Thanks for the link, Michael. I was already afraid > I'd have to use Muenchian > grouping, something that I've never done before. > > Mick > > > -----Oorspronkelijk bericht----- > Van: Michael Kay [mailto:mhk@xxxxxxxxx] > Verzonden: vrijdag 2 juli 2004 14:57 > Aan: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Onderwerp: RE: [xsl] sorting and grouping > > You'll find the answer at > http://www.jenitennison.com/xslt/grouping > > Michael Kay > > > -----Original Message----- > > From: m.vanrootseler > [mailto:m.vanrootseler@xxxxxxxxx] > > Sent: 02 July 2004 13:40 > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > > Subject: [xsl] sorting and grouping > > > > I've got a sorting problem. My XML is as follows: > > > > <person> > > <name>Kermit</name> > > <birthday>3</birthday> > > <birthmonth>January</birthmonth> > > </person> > > etc. > > > > XSLT: > > > > <xsl:for-each > select="person[birthmonth='January']"> > > <xsl:sort select="birthday" > data-type="number"/> > > <xsl:sort select="name"/> > > <xsl:value-of select="birthday"/> > > <xsl:text> - </xsl:text> > > <xsl:value-of select="name"/> > > <br/> > > </xsl:for-each> > > > > With the above code, each birthday number is > repeated. What I > > would like is > > to have the birthday number appear only once > followed by the > > names of people > > whose birthday that is. I suspect it can be done > by testing > > if the birthday > > value is the same as the preceding sibling, but I > can't get > > it right. Does > > anyone have any idea how to solve this? > > > > Mick __________________________________ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] sorting and grouping, m.vanrootseler | Thread | RE: [xsl] sorting and grouping, m.vanrootseler |
Re: [xsl] creating a jsp file using, Robert Koberg | Date | Searching for elements in XML, Nestor Boscan |
Month |