This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Sort
- To: xsl-list at mulberrytech dot com
- Subject: Re: Sort
- From: Oliver Becker <obecker at informatik dot hu-berlin dot de>
- Date: Mon, 31 Jul 2000 18:19:37 +0200 (MET DST)
- Reply-To: xsl-list at mulberrytech dot com
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@informatik.hu-berlin.de |
| op|qo WWW: http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list