Re: [xslt] XPath number formatting



On 2006-04-08 14:09:03 -0400, Liam R E Quin wrote:
> Whoever tries to write such a patch might find it helpful to look at
> the latest XPath 2.0 and XSLT 2.0 documents, as we tried to clarify
> such issues; the 2.0 versions are clearly based on the types defined
> by W3C XML Schema, with the acceptable implementation limits also
> defined.

However in 2.0, the problems are different, and one wouldn't write
an XSLT file in the same way in 1.0 and in 2.0. In 1.0, if I want
to represent an integer (that fits in a double-precision number,
since this is the value space for numbers in 1.0) as a string of
decimal digits, I can convert it to a string; this is guaranteed
by the 1.0 spec. In 2.0, with casting from xs:double to xs:string,
there's a limit (1000000) above which the scientific representation
is used (this is the canonical representation for xs:double data).
However, I could first convert the value to xs:decimal in order to
get a sequence of decimal digits as I wanted. But this solution is
*not* possible in 1.0. So, the 1.0 and 2.0 specs must not be mixed
in an XPath implementation.

> Of course, this doesn't, strictly speaking, apply to
> XPath 1.0 and XSLT 1.0, although the 2.0 specs do try to note
> any incompatibilities.  But it may help to see the direction
> in which the specs have moved.

Things have changed because new datatypes have been introduced
(in particular xs:decimal, allowing to reproduce more or less
the XPath 1.0 number -> string behavior), not because it was
too difficult to implement.

Concerning the implementation-defined limits, the limit for decimal
numbers must be at least 18 decimal digits. FYI, 2^53 (the integer
below the first non-representable positive integer in IEEE double
precision) has only 16 decimal digits.

-- 
Vincent Lefèvre <vincent vinc17 org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]