[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Sorting/grouping question

Subject: Re: Sorting/grouping question
From: Bryan Schnabel <bryan.schnabel@xxxxxxxxxxxxx>
Date: Wed, 29 May 2002 11:31:37 -0700 (PDT)
xslt sorting grouping
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>&#10;</xsl:text>
  <xsl:value-of select="substring(.,1,4)" />
 </xsl:for-each>
</xsl:template>

Bryan


--- Dan Cederholm <dan@xxxxxxxxxxxx> 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@xxxxxxxxxxxx
>  
> 
> 
>  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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.