W3C home > Mailing lists > Public > public-qt-comments@w3.org > February 2005

RE: Removing trailing decimals

From: Michael Kay <mhk@mhk.me.uk>
Date: Mon, 14 Feb 2005 10:16:31 -0000
To: "'Elliotte Harold'" <elharo@metalab.unc.edu>, <public-qt-comments@w3.org>
Message-ID: <E1D0dI1-00036a-1Q@frink.w3.org>

This change was made to the specification because a user discovered that the
algorithm for XSLT 2.0 was outputting "3." in situations where XSLT 1.0
generated "3". We decided that we should retain backwards compatibility in
this case, even though the XSLT 1.0 specification of format-number (based on
JDK 1.1) was not precise on the point.

When we made this decision, we did discuss whether there was a need to
enhance format-number() to provide both options, and decided that this would
be feature-creep. There are higher-priority enhancements, such as supporting
exponential notation, but we're trying quite hard at the moment to enforce a
policy of "no new features". In the use case you mention, it would be
entirely acceptable to use a picture of "0.0#" and produce the output "3.0".


Regards,

Michael Kay


> -----Original Message-----
> From: public-qt-comments-request@w3.org 
> [mailto:public-qt-comments-request@w3.org] On Behalf Of 
> Elliotte Harold
> Sent: 12 February 2005 12:52
> To: public-qt-comments@w3.org
> Subject: Removing trailing decimals 
> 
> 
> The latest XSLT 2 draft says:
> 
> The rules for the format-number function have been changed so 
> that if an 
> integer (say 3) is formatted using the picture 0.##, the 
> result is "3" 
> rather than "3." - that is, a number will never be output with a 
> trailing decimal point.
> 
> The relevant text in the spec seems to be:
> 
> If there is no decimal-separator-sign in the sub-picture, or if there 
> are no digits to the right of the decimal-separator-sign character in 
> the string, then the decimal-separator-sign character is removed from 
> the string (it will be the rightmost character in the string).
> 
> While I accept that most of the time this is what is desired, 
> there are 
> exceptions. It's long been the custom in C and C-like 
> languages to use 
> literals such as 3. to indicate a floating point literal 
> rather than an 
> integer literal. This change could be problematic for XSLT 
> stylesheets 
> that generates C code, and code in similar languages.
> 
> I'm not sure this is worth fixing, but I think it might be. 
> It would be 
> nice if the picture string had some way to indicate that a decimal 
> separator should not be dropped, even if there's non trailing digit.
> 
> Please consider this a comment to be addressed. I doubt I'll 
> register a 
> formal objection if the WG decides this use case is too far out to be 
> catered to, but I would like an official disposition, even if 
> it's just 
>   a decision not to handle this. Thanks.
> 
> -- 
> Elliotte Rusty Harold  elharo@metalab.unc.edu
> XML in a Nutshell 3rd Edition Just Published!
> http://www.cafeconleche.org/books/xian3/
> http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/
> ref=nosim
> 
> 
> 
Received on Monday, 14 February 2005 10:17:13 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:14:37 GMT