[Bug 2631] [XPath] Numeric Promotion

http://www.w3.org/Bugs/Public/show_bug.cgi?id=2631





------- Additional Comments From mike@saxonica.com  2006-01-03 15:15 -------
Proposal to resolve issue 2631: under action A-278-02 I was asked to propose
wording to resolve this issue editorially.

The first difficulty is a lack of uniformity in the operator mapping table:
numeric operations are handled using a generic type "numeric" than embraces
decimal, integer, float, and double, but there is no corresponding generic type
for anyURI and string. I think it would be rather disruptive to try and fix that
now, so the solution below is a little bit asymmetric.

Proposal
========

1. In 3.5.1 Value Comparisons, add a step 5 as follows:

   5. If both the operands are numeric, or if one is of type xs:string and the
other of type xs:anyURI, apply type promotion to one of the operands as
described in B.1 Type Promotion, so that the two operands have the same
primitive type.

2. In Appendix B.2, there is explanatory text for numeric promotion applied to
arithmetic operators, but no similar explanation for comparison operators. 

2a. Add a new fourth paragraph to B.2:

   Before looking up an entry in the table below, type promotion is applied
   to the operands as described in B.1 Type Promotion. 

2b. To the paragraph starting "A numeric operator may be validly applied to an
operand of type...", add the following:

   "Where the entry for an operator with numeric operands gives a result type
other than numeric (for example idiv, which has a result type of xs:integer, or
eq, which has a result type of xs:boolean), then the result is a value of that
type, regardless of the types of the operands. For example, the result of
comparing an integer to a decimal using the eq operator is a boolean". 

Michael Kay

Received on Tuesday, 3 January 2006 15:15:47 UTC