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

Re: Natural Sort

Subject: Re: Natural Sort
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 25 Jan 2006 14:31:34 GMT
natural sorting 0 9
> It only works if all the numeric parts are one or two digits.
> I can't think of an easy way of generalizing it, however.


er yes, Also it fails if there are groups of digits too close to each
other (as xpath regexp's don't have non-capturing groups so I need to
pick up the non-digit either side of the number, so if there were two
digit runs separated by a single letter it wouldn't match as the
separating letter can't match twice.

It's hard (or perhaps impossible) to to have a completely general rule
but in any constrained case it's usually possible to come up with some
regexp or other.

For example if the example was as before, with just a single digit run,
but extended to allow 1 2 or 3 digits then...

      <xsl:sort
   select="replace(replace(@dn,'([^0-9])([0-9][^0-9])','$10$2'),'([^0-9])([0-9]{2}[^0-9])','$10$2')"/>


David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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-2013 All Rights Reserved.