W3C home > Mailing lists > Public > www-ql@w3.org > January to March 2006

question about subtyping and type annotations

From: Per Bothner <per@bothner.com>
Date: Thu, 23 Feb 2006 19:29:50 -0800
Message-ID: <43FE7DAE.5010508@bothner.com>
To: www-ql@w3.org

I'm unclear on the semantic model for type annotations, and I can't
find a clear answer in the specifications or in the test suite.

I gather (and Saxon agrees) that:
   100 instance of xs:byte ==> false
because 100 has "type annotation" xs:integer, which is not a sub-type
of xs:byte.

Using the cast xs:byte creates a value with type annotation xs:byte:
   xs:byte(100) instance of xs:byte ==> true

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.

The formal semantics just refers to chapter 17 of Functions and
Operators, which mainly specifies which conversions are valid.
The formal semantics should probably specify the resulting "formal
values" after a cast.

Either way, this should be tested in the test suite.  I didn't
find it (using a quick grep).
	--Per Bothner
per@bothner.com   http://per.bothner.com/
Received on Friday, 24 February 2006 03:29:42 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:43:44 UTC