Re: [xsl] Formatting numbers

Subject: Re: [xsl] Formatting numbers
From: Zak McGregor <zak@xxxxxxxxxxxx>
Date: Tue, 10 Apr 2001 14:49:31 +0200
On Tue, 10 Apr 2001 12:47:18 +0200
Zak McGregor <zak@xxxxxxxxxxxx> wrote:

> Hi all
> I need to get numbers in a format that would be suitable for currency
> (eg:
> 5.00 or 3.50 or 1.99 etc), which is simple enough, but I am using
> Sablotron 0.51 which lists format-number() as currently unimplemented.
> Any
> kind peeps out there with an idea of how I could acieve the same effect
> please?
Well, I have a solution, but it isn't pretty...


     <xsl:call-template name="number-pad">
     <xsl:with-param name="number-to-format" select="floor(amount*100+0.5)
div 100"/>


<xsl:template name="number-pad">
<xsl:param name="number-to-format" />
  <xsl:variable name="zpad"
select="string-length(substring-after($number-to-format,'.'))" />
    <xsl:when test="$zpad=0"><xsl:value-of
    <xsl:when test="$zpad=1"><xsl:value-of


I hope this helps someone else out there...



 XSL-List info and archive:

Current Thread