This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: sorting text-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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]