[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Arbitrary sorting

Subject: Re: Arbitrary sorting
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 03 Aug 2000 21:18:05 +0100
arbitrary sorting
Matt,

>	Is it possible to do arbitrary sorting after alphabetical sorting,
>in XSLT?

It's certainly possible to have several sorts, and there aren't any
limitations on the types of sorts that you can have following other sorts.
Here is a solution given your example (though perhaps it's not
demonstrating the abitrariness that you're after - perhaps you can provide
another example to show the breadth of problems you're talking about).

First, sort on the first letter in the string:

  <xsl:sort select="substring-before(., ' ')" />

Then sort so that any string containing 'v' is before those that do not:
with a data-type of 'number', booleans should be translated automatically
to 1 if true and 0 if false.  It looks as though SAXON 5.4 isn't doing
this, so I've included an explicit call to number() which you may be able
to take out with your processor:

  <xsl:sort select="number(contains(., 'v'))"
            data-type="number"
            order="descending" />

Finally, sort alphabetically.

  <xsl:sort select="." />

I hope this helps,

Jeni

Dr Jeni Tennison
Epistemics Ltd * Strelley Hall * Nottingham * NG8 6PE
tel: 0115 906 1301 * fax: 0115 906 1304 * email: jeni.tennison@xxxxxxxxxxxxxxxx


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.