Takes a map or array as input, and returns a new map or array with the same content, whose implementation tracks downward selections within a JSON-like structure of maps or arrays, so that it is possible to trace from a selected item to the route by which it was selected.
with-pedigree($in as function(*)) ➔ function(*)
The input map or array
Requires Saxon-PE or Saxon-EE. Implemented since Saxon 9.9.
Notes on the Saxon implementation
Available since Saxon 9.9.
If the supplied value is a map or array, the
returns a new map or array with the same content, but having an internal implementation
that tracks downward selections within a tree of maps and arrays, such as might be obtained
by parsing JSON input.
If the supplied argument is a function that is not a map or array, it is returned unchanged.
The functions and operators that constitute "downwards selection" include:
map:get($M, $K)and its equivalents
array:get($A, $I)and its equivalents
$V?*where $V is either a map or an array
Any maps or arrays returned by these functions and operators (but not other values, such as nodes
and atomic values) will have a pedigree that can be obtained using the saxon:pedigree()
function. The pedigree is represented as a map containing a number of entries: the
entry holds the immediately containing map or array; the
"key" entry (where applicable) holds
the key of the value within the containing map; the
"index" entry (where applicable) holds
the 1-based index of the value within the containing array. The container will itself have a pedigree,
so it is possible to navigate upwards through the tree back to the root.