Subject:Arbitrary sorting in XSLT2.0 Author:L Chatelain Date:18 Dec 2006 05:51 PM
Hi all,
I want to sort text elements according to an arbitrary order which is not alphabetical. These elements can only have a finite number of different fixed (known) values.
I have been looking at the collations because I thought it could help me but from what I have understood this is not what I am looking for.
So by looking in different places I come up with the following possibilities:
1. use translate(value, 'abc..', 'bca..') in the sort key
2. create a temporary tree like :
<temp>
<element value="value1" order="1"/>
...
</temp>
and use document('') to access it (haven't tried it yet)
3. use the number conversion of boolean in the sort key:
select="number(element='value1') * 1 + number(element='value2') * 2 ..."
My question is the following: does anyone see a nicer way of doing this, maybe by using some functionality of XSLT2.0 I haven't thought about?