This function is very similar to EXSLT
dynamic:evaluate
function. The description
below is almost literally taken from the EXSLT
specification.
The xsh:evaluate
function evaluates a string as an XPath expression
and returns the resulting value, which might be a boolean, number,
string, node set, result tree fragment or external object. The sole
argument is the string to be evaluated.
The string is always evaluated exactly as if it had been literally
included in place of the call to the xsh:evaluate
function.
In other words, the context information used when evaluating the
XPath expression passed as the argument to the xsh:evaluate
function is exactly the same as the context information used when
evaluating the xsh:evaluate
function. This context information
includes:
the context node, such that paths are evaluated relative to the
context node at the point where the xsh:evaluate
function is
called
the context position, such that the expression can contain calls to the position function
the context size, such that the expression can contain calls to the last function
variable bindings, such that the expression can contain variable references
function library, such that the expression can contain calls to extension functions
namespace declarations, such that paths can contain prefixes the current node, such that the expression can contain calls to the current function
If the expression string passed as the second argument is an invalid XPath expression (including an empty string), this function returns an empty node set.
You should only use this function if the expression must be constructed dynamically - otherwise it is much more efficient to use the expression literally. For expressions that simply give an element or attribute's name (to select a child element or attribute), it is more efficient to use an expression in the style:
*[name() = $expression]