This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Sorting/grouping question
- From: Bryan Schnabel <bryan dot schnabel at bschnabel dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 29 May 2002 11:31:37 -0700 (PDT)
- Subject: Re: [xsl] Sorting/grouping question
- Reply-to: xsl-list at lists dot mulberrytech dot com
Sure, <xsl:key> would work, I think.
<xsl:output method="text"/>
<xsl:key name="first4digits-are-year" match="date"
use="substring(.,1,4)"/>
<xsl:template match="/">
<xsl:for-each
select="/list/date[generate-id()=generate-id(key('first4digits-are-year',substring(.,1,4))[1])]">
<xsl:sort order="descending" />
<xsl:text> </xsl:text>
<xsl:value-of select="substring(.,1,4)" />
</xsl:for-each>
</xsl:template>
Bryan
--- Dan Cederholm <dan@cederholm.tv> wrote:
>
> I need to turn this XML:
>
> <list>
> <date>200201</date>
> <date>200202</date>
> <date>200101</date>
> <date>200102</date>
> <date>200001</date>
> <date>200002</date>
> </list>
>
> Into ..
>
> 2002
> 2001
> 2000
>
> Basically building a list of years (one instance of
> each year represented in
> the XML)
>
> Should I be using <xsl:key> for something like this?
>
> Thanks,
> Dan
>
> --
> dan@cederholm.tv
>
>
>
> XSL-List info and archive:
> http://www.mulberrytech.com/xsl/xsl-list
>
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list