XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
L ChatelainSubject: 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?

Thank you!

Posttop
Ivan PedruzziSubject: Arbitrary sorting in XSLT2.0
Author: Ivan Pedruzzi
Date: 18 Dec 2006 11:43 PM

You could use a user defined function to create a dynamic value to use a sort key.

The attached example uses the argument length as key.

Hope this helps
Ivan Pedruzzi
Stylus Studio Team
http://www.stylusstudio.com/xml_download.html


Documentbooks(4).xml


Documentcustomsorting.xsl

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.