This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29164 - [FO31] format-number() with first argument 0
Summary: [FO31] format-number() with first argument 0
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.1 (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-30 17:41 UTC by Debbie Lockett
Modified: 2016-03-22 10:09 UTC (History)
0 users

See Also:


Attachments

Description Debbie Lockett 2015-09-30 17:41:55 UTC
Consider format-number(0, '.#'), and format-number(0,'#.#'). 

Currently the formatting rules give the result (in both cases) as an empty string, which is surely wrong. Here's the current working:

In both cases, the first argument of format-number() is the value zero; and by the rules of 4.7.4, the minimum-integer-part-size and minimum-fractional-part-size are both zero, while the maximum-fractional-part-size is non-zero. No adjustments are made.

In 4.7.5 (Formatting the number), we get to rule 7 which says "The value zero will at this stage be represented by an decimal-separator on its own." In the following rules, no padding zeroes are added (since minimum-integer-part-size and minimum-fractional-part-size are both zero), and then by rule 12 the decimal separator itself is removed to leave the empty string.
Comment 1 Michael Kay 2015-10-01 09:09:35 UTC
For what it's worth, I think this bug has been present since the XSLT 2.0 specification of the function.

I think the fix is to add a rule (as the 10th bullet of 4.7.4:

* If (after making the above adjustments) the minimum integer part size and the minimum fractional part size are both zero, then the minimum fractional part size is set to 1 (one).

After discussing the wording of the rules with Debbie, I think it would also be clearer if we changed rule 7 of 4.7.5 from

<quote>
The absolute value of the rounded number is converted to a string in decimal notation, with no insignificant leading or trailing zeroes, using the digits in the ·decimal digit family· to represent the ten decimal digits, and the decimal-separatorXP31 character to separate the integer part and the fractional part. (The value zero will at this stage be represented by an decimal-separatorXP31 on its own.)
</quote>

to

<quote>
The absolute value of the rounded number is converted to a string in decimal notation using the digits in the ·decimal digit family· to represent the ten decimal digits, and the decimal-separator character to separate the integer part and the fractional part. This string must always contain a decimal separator, and it must contain no leading zeroes and no trailing zeroes. The value zero will at this stage be represented by a decimal-separator on its own.
</quote>

Debbie also points out that the Note in the 8th bullet of 4.7.4, specifically

<quote>
This has the effect that with the picture .#e9, the value 0.123 is formatted as .1e0
</quote>

fails to illustrate the effect intended, because the maximum fractional part size is not zero. Replace it by:

<quote>
This has the effect that with the picture #.e9, the value 0.123 is formatted as 0.1e0
</quote>
Comment 2 Michael Kay 2015-10-06 17:22:42 UTC
The WG accepted the changes and they have been applied to the spec.