[xsl] Re: Ask for examples of using Dimitre's generic sort function

Subject: [xsl] Re: Ask for examples of using Dimitre's generic sort function
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Sat, 7 Jul 2001 22:50:21 -0700 (PDT)
Sun-fu Yang wrote:

> I try very hard to understand the results from your example of using
> genericSearchSort.sort.data.1.xml with genericSearchSort.sort.1.xsl.
> I do not have idea what does two-digit number shown in  each result stand
> for.
> for example, Result: 01 10 03 09 06 ...   Could you please give some words
> on it?

Hi Sun-fu,

The result is a space-delimited string representation of the nodelist resulting from
the sort operation.

In the example above the result means that the "smallest node" has position 1,
the next one has position 10, the next one has position 3,... etc.

All positions have exactly the same number of digits (the same as 
string-length(count(theNodeSet))). So, in case the node-set to be sorted had only 9
elements, the above result would be:

1 3 9 6 ...   

This is by design, so that picking an individual position from this string should
not be difficult -- the k-th position will be:

substring(theResult, ($k - 1)*($posLength + 1) + 1, $posLength), where $posLength is
defined as above:

<xsl:variable name="posLength" select="string-length(count(theNodeSet))"/>

I realise though, that even this may be difficult for subsequent processing of the
results of the sort (e.g. one will have to use a recursive template in order to
process the sorted sequence of nodes).

I could create a nodeset of positions (or their respective nodes' generate-id()-s),
so that it can be processed immediately with an xsl:for-each ? 
Do you think this would be useful?

I would be happy to further assist you in using this template, do not hesitate to
contact me.

Dimitre Novatchev.

Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail

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

Current Thread