- From: Michael Kay <mhk@mhk.me.uk>
- Date: Fri, 24 Feb 2006 09:17:27 -0000
- To: "'Per Bothner'" <per@bothner.com>, <www-ql@w3.org>
> > What about xs:integer(xs:byte(100))? I would expect this to return > a value with type annotation xs:integer, but Saxon (b8-6-1) disagrees: > xs:integer(xs:byte(100)) instance of xs:byte ==> true ???? > > This implies that if the argument already conforms to the > casted-to-type > then it it returned changed. That is certainly a possible behavior, > but another behavior is that casting to xs:integer returns a value > with annotation xs:integer. That seems more consistent to me. There's some dispute about whether the Saxon behaviour here is acceptable. The specification says that xs:integer(xs:byte(100)) returns an xs:integer. My reading of the spec is that any expression that is defined to return an xs:integer is also allowed to return a subtype of xs:integer: for example it would be valid here for Saxon to return a value of type saxon:seven-bit-integer, provided that the resulting value can be used anywhere that an xs:integer can be used, and that (EXPR instance of xs:integer) returns true. Logically this means that it is also acceptable to return an xs:byte. This is one reason that we don't have a function that tells you the actual type annotation on a value, the only thing you can do is test whether a value is an instance of some candidate type. Others have disagreed with this reading of the spec; in particular I have heard it suggested that although the principle above applies to most kinds of XQuery expression, cast and constructor expressions are an exception. But I have also heard it suggested that it would be wrong say for the position() function to return a value that is an xs:int as well as being an xs:integer. I can't agree with that interpretation. Michael Kay http://www.saxonica.com/
Received on Friday, 24 February 2006 09:19:47 UTC