Project

Profile

Help

Bug #4091

closed

Function with declared argument type of xs:error can be successfully called

Added by Michael Kay almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XQuery conformance
Sprint/Milestone:
-
Start date:
2019-01-13
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.9, trunk
Fix Committed on Branch:
9.9, trunk
Fixed in Maintenance Release:
Platforms:

Description

Adam Retter reported on xquery-talk:

On 12 Jan 2019, at 09:22, Adam Retter 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

Also available in: Atom PDF