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

RE: format decimal numbers issue

Subject: RE: format decimal numbers issue
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 22 Mar 2008 15:53:19 -0000
RE:  format decimal numbers issue
> <xsl:variable name="tput">
>       <xsl:call-template name="display-dec-sec">
>                <xsl:with-param name="value" select="$count 
> div $timeSpan * 1000" />
>       </xsl:call-template>
>  </xsl:variable>

So you call display-dec-sec supplying a number, and you get back a string
representation such as "5.894 s"
> 
> <td>
>        <xsl:call-template name="display-dec-sec">
>                <xsl:with-param name="value" select="$tput" />
>        </xsl:call-template>
> </td>

Now you're calling display-dec-sec again, only this time you don't supply a
number, you supply a string like "5.894 s".
> 
> <xsl:template name="display-dec-sec">
>      <xsl:param name="value" />
>              <xsl:value-of 
> select="format-number($value,'#,.000 s')" />
>      </xsl:template>
> 
> [xslt] C:\detail.xsl:153: Fatal Error! Cannot convert string "5.894 s"
> to a double

format-number will try to convert the supplied value to a number before
formatting it. But it can't convert "5.894 s" to a number because it is
already formatted.

Note: the " s" in the picture is in fact legal. I'm less sure about the
adjacent "," and ".". It's definitely NOT allowed in XSLT 2.0: "A
sub-picture must not contain a grouping-separator-sign adjacent to a
decimal-separator-sign.". In 1.0, it's defined by reference to the JDK 1.1
specification, and there's no copy of that available online any more.

Michael Kay
http://www.saxonica.com/

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.