W3C home > Mailing lists > Public > www-xml-query-comments@w3.org > November 2001

string compared to integer

From: Michael Dyck <MichaelDyck@shaw.ca>
Date: Sat, 24 Nov 2001 14:40:54 -0800
To: www-xml-query-comments@w3.org
Message-id: <3C0021F6.FB333C5C@shaw.ca>
Does the expression
    "3" > 1
yield an error, or the value true, or what?

In the Formal Semantics, section 4.5 Operators indicates (in the second
rule) that the expression type-checks. (It has the type xs:boolean.) But
section 5.4 Operators has no rule that would allow us to infer its value.
Presumably this is just an oversight, and the authors meant to include a
rule that basically punted the semantics to the F&O spec (as it does with
many other operators). But the F&O spec doesn't appear to define the
expression's semantics, since a string can't be promoted to an arithmetic
type. So that suggests that expression yields an error.

However, some of the examples in the main XML Query spec and the Use Cases
spec appear to assume implicit coercion of strings to numbers in this sort
of context.

-Michael Dyck
Received on Saturday, 24 November 2001 17:42:41 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:21:14 UTC