This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: left zero pad digit string
- To: xsl-list at mulberrytech dot com
- Subject: Re: left zero pad digit string
- From: Miloslav Nic <nicmila at idoox dot com>
- Date: Fri, 01 Sep 2000 14:03:01 +0200
- References: <003601c0136f$3b09ced0$62c80318@etntwn1.nj.home.com>
- Reply-To: xsl-list at mulberrytech dot com
"Robert C. Lyons" wrote:
>
> Joel writes:
> > Padding a number:
> > Requirement: zero pad a digit string
> > Example: 456 --> 000456
> > Where the new string length is a passed parameter to the
> > padding template.
>
Try:
http://www.zvon.org/cgi-bin/xlab/bin/formatNumber.py
with parameters:
from: 456
step: 10
count:10
format-number: 000000
The test agrees :)
> Joel,
>
> I believe that format-number( "456", "000000" )
> would return "000456". The 2nd arg is the format
> pattern.
>
> In your case, the number of zeroes in the format
> pattern must be equal to the "new string length."
> You can use the substring function to construct
> a format pattern with the appropriate number of
> zeroes as follows:
>
> substring( $long_string_of_zeroes, 1, $new_string_length )
>
> Note that I haven't tested any of this.
> Hope it helps.
>
> Bob
>
> <sig name = 'Bob Lyons'
> title = 'E-Commerce Consultant'
> company = 'Unidex, Inc.'
> phone = '+1-732-975-9877'
> email = 'boblyons@unidex.com'
> url = 'http://www.unidex.com/'
> plug = 'Home of XML Convert' />
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
--
******************************************
<firstName> Miloslav </firstName>
<surname> Nic </surname>
<mail> nicmila@idoox.com </mail>
<support> http://www.zvon.org </support>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list