[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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 ________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|