Re: [xsl] Eliminating leading zeros

Subject: Re: [xsl] Eliminating leading zeros
From: "andrew welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 21 Aug 2006 15:21:12 +0100
On 8/21/06, Mark Wilson <drmark@xxxxxxxxxxxxxxx> wrote:

Yes I am using XSLT2 (albeit very poorly understood). Will try your suggestion.

Padding leading zero's to sort and then removing them seems like a bad idea when you can just sort twice, once using data-type number and then again using text, extracting the relevant part of the value each time, eg:

<xsl:sort select="replace(., '\s\D*', '')" data-type="number"/>
<xsl:sort select="replace(., '\d*\s', '')" data-type="text"/>

Otherwise you will need to pick a suitably large number of zeros to
pad and hope a longer number never appears, or find the maximum length
for all the numbers up front...


Current Thread