Re: Sort

Subject: Re: Sort
From: Oliver Becker <obecker@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 31 Jul 2000 18:19:37 +0200 (MET DST)
Hi Jon,

> I have a sorting question for the group. I have elements like the following:
> 
> <Marquee Class="RIO_container" Expiration_day="Indefinite"
> Expiration_month="Indefinite" Expiration_year="Indefinite"
> Id="vt_182-Virtual_teams-Marquee.xml" Last_modifier="admin"
> Maximum_number="" Modification_date="Thursday, July 20, 2000 10:38:21 AM
> PDT" Owner="admin" Progress="complete" Status="modify" Used_in=" vt">
> 
> I want to sort by the Modification_date attribute. How can I do this
> efficiently with XSLT? Or maybe I just can't? I've tried using a JavaScript
> extension to manipulate the numbers but it just didn't seem to work. I'd
> prefer not to do it with Java but with if I have to.

Use multiple <xsl:sort> statements:

<xsl:sort select="substring(
                     substring-after(
                        substring-after(@Modification_date,','),
                        ','),
                     2, 4)" /> <!-- this should select 2000, not tested ... -->
<!-- sort by month, see below -->
<xsl:sort select="substring ..." /> <!-- select day etc. -->

One problem is the month given with its name.
A solution is in the XSL FAQ - look for "arbitrary sorting":
http://www.dpawson.freeserve.co.uk/xsl/N6461.html#N13098
and
http://www.dpawson.freeserve.co.uk/xsl/N6461.html#N13111

Cheers,
Oliver


/-------------------------------------------------------------------\
|  ob|do        Dipl.Inf. Oliver Becker                             |
|  --+--        E-Mail: obecker@xxxxxxxxxxxxxxxxxxxxxxx             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • Sort
    • Jon Wynacht - Mon, 31 Jul 2000 07:22:27 -0700
      • <Possible follow-ups>
      • Spychalski, Frank - Mon, 31 Jul 2000 18:14:06 +0200
      • Oliver Becker - Mon, 31 Jul 2000 18:19:37 +0200 (MET DST) <=
      • Nate Austin - Mon, 31 Jul 2000 16:26:56 -0500