Hello!
I'm not sure whether this is a question relevant to BaseX or more generally to the XQuery community. Since I don't use other XQuery systems and it might be specific to the BaseX parser, I post it here first.
Why can't I specify xs:positiveIntegers as literals? Or why can't I treat xs:integers as xs:positiveIntegers? Consider a simple function that takes a xs:positiveInteger as input:
<code> xquery version "3.0" encoding "UTF-8"; declare namespace local = "local";
declare function local:positive( $input as xs:positiveInteger ) as xs:positiveInteger { $input }; </code>
I get an error XPTY0004 Cannot treat xs:integer as xs:positiveInteger if I run it with a literal input, like this: <code> local:positive(2) </code>
I get no error if I specify the type explicitly, like this: <code> local:positive(xs:positiveInteger(2)) </code>
This feel very odd, since the type system is hierarchical and xs:positiveInteger is a subcase of xs:integer, I don't really see a problem of this kind of automatic casting of integer literals if they qualify the cast.
Can you give any reflection on this?
Best regards Kristian Kankainen