w3c / qtspecs

XSLT and XQuery Specifications - the source used to build the specs, and the errata
Other
30 stars 25 forks source link

[xpath3.1] Lookup operator: restriction to maps and arrays #46

Open michaelhkay opened 1 year ago

michaelhkay commented 1 year ago

The title of section §3.11.3 ("The Lookup Operator ("?") for Maps and Arrays") strongly suggests that the operator is intended only to apply to maps and arrays. The rules for unary lookup state this explicitly, in §3.11.3.1. The rules for postfix lookup in §3.11.3.2 impose the same rule in the case where the the KeySpecifier is an NCName, IntegerLiteral, or Wildcard ("*"). But where the RHS is a parenthesised expression, the rules say

the expression E?(S) is equivalent to for $e in E, $s in fn:data(S) return $e($s)

with no explicit check that $e is a map or array. The rules could therefore be interpreted as allowing the LHS to be a function item other than a map or array.