xsl-list
[Top] [All Lists]

RE: sorting and grouping

2004-07-02 05:57:14
You'll find the answer at http://www.jenitennison.com/xslt/grouping

Michael Kay 

-----Original Message-----
From: m.vanrootseler [mailto:m(_dot_)vanrootseler(_at_)chello(_dot_)nl] 
Sent: 02 July 2004 13:40
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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



--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--





<Prev in Thread] Current Thread [Next in Thread>