Subject: Re: [xsl] Natural Sort From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 25 Jan 2006 14:40:27 GMT |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Natural Sort, David Carlisle | Thread | [xsl] Selecting an element by a dyn, Rupert Parson |
Re: [xsl] Natural Sort, David Carlisle | Date | RE: RE: [xsl] html tables with XSL, cknell |
Month |