[Bug 5223] [XQuery] Casting rules in 3.5.2 General Comparisons (editorial)

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





------- Comment #1 from mike@saxonica.com  2007-10-23 21:19 -------
I think "A is an instance of T" definitely includes the case where A is an
instance of a subtype of T. I haven't looked to see whether we say that clearly
anywhere, but it is undoubtedly the intent.

The interesting thing about your example is that it sheds new light on the
phrase "is cast to the dynamic type of the other value". I had always assumed
that it was intended that one should cast to the primitive type of the other
value, that is, in your example, to cast to xs:string. In fact it never
occurred to me that casting to xs:Name could give a different result for the
comparison, but your example clearly shows that because of whitespace
normalization, it can.

I find it hard to believe that we really intended to require casting to the
derived type, because that would cause a large number of errors in places where
a false result is surely more reasonable. Also, instead of optimization using
indexes or hash tables being difficult, it becomes virtually impossible. It
would also defy expectations on substitutability: if a developer writes
//a[.=1000] in the knowledge and belief that a is typed as xs:int, it's
unreasonable that this should fail at run-time because someone has created a
subtype in which a is an xs:byte.

Michael Kay

Received on Tuesday, 23 October 2007 21:19:42 UTC