This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Sorting/grouping question


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@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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]