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

Re: sorting text-number strings?

Subject: Re: sorting text-number strings?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 14 Apr 2000 15:48:11 +0100 (BST)
number strings
> Is there a way to achieve a sort with results?:
> title 1, title2, title 3,..., title 9, title 10, title 11

XSL isn't especially good (actually it's normally hopeless) at infering
structure from character data, so it would have had a much easier time
if the characters and numbers had been separated in the input 
<title
  name="this string"
  number="42"/> 
or some such.

Actually I don't understand your description of the input

"title 1, title2, some other name, title 3, ..., title 9, title 10, title 11"

especially as your suggested output is

title 1, title2, title 3,..., title 9, title 10, title 11

what happened to `some other name' and why didn't that have a number,

so I'll ignore that and just give an example that sorts strings
or the form "abc 123" ie characters, space, numbers, 
first on the first word, then numerically on the digits.

<xsl:for-each select="whatever">
<xsl:sort data-type="text" select="substring-before(.,' ')"/>
<xsl:sort data-type="number" select="substring-after(.,' ')"/>

...

David


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