hash

Usage

$hash := hash expression expression

Description

This command takes two arguments: an expression computing a key from a given node (1st argument) and a node-set (2nd argument). For each node in the node-set, the key value is computed and the node is stored under the given key in the resulting hash. For a given key, the value stored in the hash table is a node-list consisting of all nodes for which the 1st expression evaluated to an object string-wise equal to the key. It is therefore possible to index more than one node under the same key.

The XPath function xsh:lookup(varname,key) can be used to retrieve values from hashes in XPath expressions.

Example 32. Index books by author

my $books_by_author := hash concat(author/firstname," ",author/surname) //book;

Example 33. Lookup books by Jack London.

ls { $books_by_author->{'Jack London'} };
ls xsh:lookup('books_by_author','Jack London');

See Also

xsh:lookup