29164
2015-09-30 17:41:55 +0000
[FO31] format-number() with first argument 0
2016-03-22 10:09:41 +0000
1
1
1
Unclassified
XPath / XQuery / XSLT
Functions and Operators 3.1
Candidate Recommendation
PC
Windows NT
CLOSED
FIXED
P2
normal
---
1
debbie
mike
public-qt-comments
oldest_to_newest
123382
0
debbie
2015-09-30 17:41:55 +0000
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.
123414
1
mike
2015-10-01 09:09:35 +0000
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>
123531
2
mike
2015-10-06 17:22:42 +0000
The WG accepted the changes and they have been applied to the spec.