This is interesting.
I tried this in a couple XQuery parsers and they all report an error

   1 treat as xs: untypedAtomic

Reading up on "treat as" is a bit confusing to me.  "cast as" works as defined
  1 cast as xs: untypedAtomic

And there is a lot of verbage in XQuery 3 about casting to untypedAtomic but I 
cant find a thing about treat as.
And in the XSD type system described here :
http://www.w3.org/TR/xmlschema-2/

I cant find xs:untypedAtomic anywhere which makes me think it is not a type 
anything is actually derived from...
thus reading about 'treat as'   " Unlike cast, however, treat does not change 
the dynamic 
type<http://www.w3.org/TR/2013/CR-xquery-30-20130108/#dt-dynamic-type> or value 
of its operand. Instead, the purpose of treat is to ensure that an expression 
has an expected dynamic type at evaluation time."

So if xs:untypedAtomic is not the base type of anything then it makes sense 
that treat as will fail


----------------------------------------
David A. Lee
[email protected]<mailto:[email protected]>
http://www.xmlsh.org

From: [email protected] [mailto:[email protected]] On Behalf Of 
Michael Kay
Sent: Sunday, January 20, 2013 7:29 PM
To: [email protected]
Subject: Re: [xquery-talk] treat as


On 20/01/2013 21:47, Michael Sokolov wrote:
I'm not sure what the following expression ought to return:

declare namespace local="http://localhost/";<http://localhost/>;
declare function local:minus($x){ -($x treat as xs:untypedAtomic?) };
local:minus(local:minus(1))

At first I naively *thought* it would return 1

Saxon 9.4.0.3 returns the empty sequence
I haven't tried 9.4.0.3, but 9.4.0.6 says:

Error on line 3 of test.xq:
  XPDY0050: Required item type of value in 'treat as' expression is 
xs:untypedAtomic
Query processing failed: Run-time errors were reported

Michael Kay
Saxonica
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk

Reply via email to