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

Re: Re: using format-number() for aligned text output

Subject: Re: Re: using format-number() for aligned text output
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 28 Mar 2001 17:42:10 +0100
numbers 12345
Hi Ken,

> I was anticipating format-number(price,'####0.00') to always produce
> a string of 8 characters in length, yet both processors I have (XT
> and Saxon) are Java based and are using the Java library which is
> known to have other problems for this function.

I thought that, since the format-number() function is specifically
based on Java's DecimalFormat class, that using the Java library would
be *more* reliable than copying the functionality in another language?

> Any alternative interpretations out there for the specification
> wording of: "digit specifies the character used for a digit in the
> format pattern; the default value is the number sign character (#)"?
> Would anyone else expect the "#" to produce a space if no digit is
> there? If that isn't the behaviour, then what is the utility of the
> "#"?

In the format pattern, the # stands for an optional digit and the 0
stands for a required digit.  So:

  format-number(12345, '#,##0.00') => '12,345.00'
  format-number(1.5,   '#,##0.00') => '1.50'
  format-number(0.543, '#,##0.00') => '0.54'
  format-number(12345, '#,###.##') => '12,345'
  format-number(1.5,   '#,###.##') => '1.5'
  format-number(0.543, '#,###.##') => '.54'

You need to have #s as well as 0s to allow you to specify the grouping
size in numbers without getting leading 0s all over the place, and to
specify the maximum number of decimal digits without forcing there to
be decimal digits.

Basically, as far as I can tell format-number() can only be used to
pad numbers with zero digits, not with any other character.

Cheers,

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-2013 All Rights Reserved.