This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Sorting date in xsl
- To: narsu at gitanjali dot com
- Subject: [xsl] Re: Sorting date in xsl
- From: Dimitre Novatchev <dnovatchev at yahoo dot com>
- Date: Sat, 9 Jun 2001 06:35:42 -0700 (PDT)
- Cc: xsl-list at lists dot mulberrytech dot com
- Reply-To: xsl-list at lists dot mulberrytech dot com
Sorting in two passes will need much additional memory (O(N)) and therefore is not
practical for long node-sets.
Another approach is to have a sequence of (4 - 5) xsl:sort elements in proper order
of precedence, each specifying the numeric equivalent of a part of the date.
In this case you'll have to reference a lookup variable containing the month names
in their chronological order and to use the position of a specific month as a sort
key.
A third and the most natural approach is to use a generic template for a generic
sort operation. You'll just pass to this generic template a template reference
implementing the "greater than" relation for your format of dates.
The same generic sort template can be used for sorting nodesets, the type of whose
nodes may be different (and not known in advance) at each instantiation of the
template.
You can read more about generic templates at:
http://sources.redhat.com/ml/xsl-list/2001-05/msg00276.html
http://lists.fourthought.com/pipermail/exslt/2001-May/000169.html
http://dpawson.co.uk/xsl/generic.html
Cheers,
Dimitre Novatchev.
---------------------------------------------
Gitanjali <narsu at gitanjali dot com> wrote:
Can any body tell me how to sort in xsl. Do I need to conver the following
format to number and then do sorting..
<root>
<date>Tue, 29 May 2001 22:37:32 -0400</date>
<date>Tue, 25 May 2001 22:37:32 -0400</date>
<date>Tue, 21 May 2001 22:37:32 -0400</date>
<date>Tue, 23 May 2001 22:37:32 -0400</date>
</root>
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list