Re: format-number problems with MSXML

Subject: Re: format-number problems with MSXML
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 22 Aug 2000 19:24:59 +0100
Jonas,

>I tried
><xsl:value-of select="translate(format-number($accountno div 10,
>'#,##0.0),',.', '.-')"/>
>and that worked just fine when I used saxon.
>But MSXML uses the language settings of the computer (it seems) and doesn't
>yet support <xsl:decimal-format>
>Does anybody know how to tell MSXML to use a specific format and make the
>parser obey you? ;o)

I can't see any good way to do it, assuming that you want to be able to use
the same thing on computers with different language settings?

You're probably using format-number() precisely because you want to avoid
using templates for it, but here's a recursive template that you can use
with this example instead [it doesn't do precisely what you want (doesn't
force 5 digits), but hopefully it'll get you part of the way there].

<xsl:template match="x:row">
  <xsl:text>Formatted number: </xsl:text>
  <xsl:call-template name="format-number">
    <xsl:with-param name="number" select="@ACCOUNTNO div 10"/>
    <xsl:with-param name="decimal-separator" select="'-'" />
    <xsl:with-param name="grouping-separator" select="'.'" />
  </xsl:call-template>
</xsl:template>

<xsl:template name="format-number">
  <xsl:param name="number" />
  <xsl:param name="decimal-separator" select="'.'" />
  <xsl:param name="grouping-separator" select="','" />
  <xsl:if test="$number">
    <xsl:call-template name="format-number">
      <xsl:with-param name="number" select="floor($number div 1000)" />
      <xsl:with-param name="grouping-separator"
select="$grouping-separator" />
    </xsl:call-template>
    <xsl:if test="$number > 1000">
      <xsl:value-of select="$grouping-separator" />
    </xsl:if>
    <xsl:value-of select="floor($number mod 1000)" />
    <xsl:variable name="decimals" select="substring-after($number, '.')" />
    <xsl:if test="$decimals">
      <xsl:value-of select="$decimal-separator" />
      <xsl:value-of select="$decimals" />
    </xsl:if>
  </xsl:if>
</xsl:template>

Sorry I can't be of more help,

Jeni

Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread