Lookup expressions
XPath 3.1 introduces the lookup operator ?, which is used to
access entries in maps or arrays.
For maps, if the key to be accessed is known statically, and if it takes the form of an
NCName, then a lookup expression of the form $employee?name
can be used. A unary form of this operator is also available, allowing
$employee[?name='John'].
A member of an array can be accessed using the syntax $A?3 (equivalent to
$A(3)).
From XPath 4.0, the lookup operator "?" (in both its unary and binary forms) can now be followed by:
- A literal, for example
$person?'date of birth' - A variable reference, for example
$array?$index
The effect is the same as if the string literal or variable were written in parentheses. (Implemented from Saxon 10.)
Method call operator
XPath 4.0 introduces the method call operator =?>. In simple cases,
$map =?> method(X) is essentially an abbreviation for
($map ? method)($map, X). Here $map is a map (or sequence of maps),
such that method is the key of an entry in the map, and the value of that entry is
a function item, which takes the map as its implicit first argument. The method call
$map =?> method(X) first performs a map lookup ($map?method) to
select the function item, and then calls the function item, supplying the containing map as the
first argument.