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

Subject: Re: [xsl] Re: using format-number() for aligned text output
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 28 Mar 2001 11:58:30 -0500
At 01/03/28 17:42 +0100, Jeni Tennison wrote:
> 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?

That would require non-Java processors to implement bug-emulation mode as I feel quite certain that the Java library failure to recognize the negative pattern grammar of the format pattern syntax wouldn't want to be copied in an implementation:


Consider:

format-number(-12345, '#,###.00;(#)')

The above produces "(12,345)" in Java-based processors and (I'm told) "(12345)" in C++-based processors. I believe the C++-based processors are correct. For all of my tests of negative number syntax in the grammar, they are *all* being ignored and supplanted by the positive number syntax in Java-based processors.

Where does one draw the line between empirical evidence and functional definition? This question is being raised in the OASIS XSLT/XPath conformance committee.

> 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'

Personally, I would have expected a space where the comma is so that my format string dictated the final result length for any number of less than or equal the digits of the uses of the octothorpe character. I acknowledge, though, the '#' would be the only facility to specify the grouping.


Thanks, Jeni!

..................... Ken


-- G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) Web site: XSL/XML/DSSSL/SGML/OmniMark services, training, products. Book: Practical Transformation Using XSLT and XPath ISBN 1-894049-06-3 Article: What is XSLT? http://www.xml.com/pub/2000/08/holman/index.html Next public instructor-led training: 2001-04-06,05-01,05-14,05-15, - 05-16,05-17,05-21,05-22,06-18,06-21,07-20,07-21,09-19

!!Five-day XSLT/XPath/XSLFO Training Blitz June 18-22, 2001 in Ottawa!!


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



Current Thread