[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:40:27 GMT
Re:  Natural Sort
I keep forgetting that the sort expression needn't be a single xpath in
xslt2, so in that case you don't need to use the tricky replace regexp
to add the zero, you can do what I had in mind really and use
format-number to express all numbers with teh same number of digits.

This version works up to 6 digits (and without the
restrictions on digit runs being close)

  <xsl:for-each select="server">
      <xsl:sort>
      <xsl:value-of>
      <xsl:analyze-string select="@dn" regex="[0-9]+">
       <xsl:matching-substring>
          <xsl:value-of select="format-number(number(.),'000000')"/>
       </xsl:matching-substring>
       <xsl:non-matching-substring>
	 <xsl:value-of select="."/>
       </xsl:non-matching-substring>
      </xsl:analyze-string>
      </xsl:value-of>
      </xsl:sort>
      <xsl:copy-of select="."/>
    </xsl:for-each>
  

________________________________________________________________________
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.