This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: xsl sorting on derived values
- From: Trevor Nash <tcn at melvaig dot co dot uk>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 18 Sep 2002 15:48:37 +0100
- Subject: Re: [xsl] xsl sorting on derived values
- Organization: Melvaig Software Engineering Limited
- References: <E562FCEE3A42D61192880002A5FB4333294E31@kite.pigroup.co.uk>
- Reply-to: xsl-list at lists dot mulberrytech dot com
On Mon, 16 Sep 2002 15:08:30 +0100, you wrote:
>Hi,
>
>I need to sort a list based on a value derived from a doubly recursive loop.
>It is a table for cumulative time and I current generate the times using a
>template to perform the recursive steps but I need to sort on these for
>display. Does anyone know if this is possible and, if so, how it can be
>done.
>
Hi Mike
Without knowing exactly what your algorithm is, its hard to tell...
but in principle you can sort on anything that you can calculate in an
XPath expression. There are tricks you can use to get the effect of
conditionals, but recursion is probably out of the question.
There are a number of approaches:
1. Can you use sum() instead of recursion?
2. Do the processing in two passes (either separate transforms or
using node-set), so the first calculates the value you want to sort on
(see the identity transform).
3. Use an extension, assuming you do not mind being tied to one
processor (for example, saxon:function does a good job)
4. Use XSLT 2.0 / XPath 2.0 (currently that means Saxon 7.2). XPath
2.0 has more facilities which might be enough to implement your time
calculation purely in XPath.
HTH
Trevor Nash
--
Traditional training & distance learning,
Consultancy by email
Melvaig Software Engineering Limited
voice: +44 (0) 1445 771 271
email: tcn@melvaig.co.uk
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list