Bug #4091
closedFunction with declared argument type of xs:error can be successfully called
100%
Description
Adam Retter reported on xquery-talk:
On 12 Jan 2019, at 09:22, Adam Retter adam.retter@googlemail.com wrote:
Whilst looking for a type which is declarable in XQuery but that cannot be constructed, I wrote a strange query, well to me anyway, which evaluates on Saxon 9.8.0.12 PE, and returns .
declare function local:test1($x as xs:error) {
<hello/>
};
local:test1(())
xs:error is defined in XSD 1.1 part 1:
[Definition:] A special simple type definition, whose name is error in the XSD namespace, is also present in each ·XSD schema·. The XSD error type has no valid instances. It can be used in any place where other types are normally used; in particular, it can be used in conditional type assignment to cause elements which satisfy certain conditions to be invalid.
In §3.16.7.3 it is defined as a union type with no member types.
I think that this call should fail on the grounds that () is not a valid instance of xs:error.
What's happening is apparently that when xs:error
is used as a SequenceType, it is given a required cardinality of 0, and the type matching, when it sees a required cardinality of 0, allows an empty sequence to appear. I think the correct handling would be to have a required cardinality of 1.
Please register to edit this issue