[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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
format number xsl
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.