Subject: Re: Arbitrary sorting From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 03 Aug 2000 21:18:05 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Arbitrary sorting, Matthew Bentley | Thread | template matches more than once, Tom Power |
Re: Javascript : from xsl to xml, Jay Sachs | Date | RE: <xsl:stylesheet xmlns..., Heather Lindsay |
Month |