EXSLT - dyn:evaluate

Implementer Page: dyn.evaluate.html
Function Package: dyn.evaluate.zip

Function Syntax

object dyn:evaluate(string)

The dyn: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 dyn:evaluate function. For example:

<xsl:value-of select="dyn:evaluate('my:extension(. * $variable)')" />

Creates a text node with exactly the same value as:

<xsl:value-of select="my:extension(. * $variable)" />

In other words, the context information used when evaluating the XPath expression passed as the argument to the dyn:evaluate function is exactly the same as the context information used when evaluating the dyn:evaluate function. This context information includes:

  • the context node, such that paths are evaluated relative to the context node at the point where the dyn: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
  • key definitions, such that the expression can contain calls to the key function
  • decimal formats, such that the expression can contain calls to the format-number 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]

Implementations

The following XSLT processors support dyn:evaluate:

There are currently no third-party implementations of dyn:evaluate.

http://www.exslt.org/dyn/functions/evaluate/index.html last modified 2003-01-30