Bugzilla – Bug 19257
[XQ3.0] Context item must be a singleton
Last modified: 2013-06-19 09:31:53 UTC
In 4.17, Context item declaration, the specification does not make it clear what happens if the initial value of the context item evaluates to (a) an empty sequence, or (b) a sequence containing more than one item.
The second case is clearly an error, and we need to say so.
The first case is either an error, or results in the context item being "absent" and therefore unusable.
I agree. I would prefer to make both cases errors.
It must surely be XPTY0004 since the context item type can only be specified as an item (not sequence) type by virtue of the grammar
 ContextItemDecl ::= "declare" "context" "item" ("as" ItemType)? ((":=" VarValue) | ("external" (":=" VarDefaultValue)?))
and is effectively
declare context item as item() external;
when not explicitly declared.
I tend to agree with Tim. I think it can be logically inferred from the current specification that a type error will be raised in both cases. Perhaps a note saying so might make this clearer though?
The Working Group agrees. I will make the changes in comments 0, 1, and 2.