EXSLT - dyn:evaluate - Implementer Page

Version: 1
Status: new
User Page: index.html
XML Definition: dyn.evaluate.xml
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]

An implementation of this extension function in the EXSLT dyn namespace must conform to the behaviour described in this document.


Built-in support for dyn:evaluate is available in the following XSLT processors:

ProcessorProcessor VersionImplemented Version
Xalan-J from Apache2.4.11
4XSLT, from 4Suite.0.12.0a31
libxslt from Daniel Veillard et al.1.0.191

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

Change History

Submitted: 2001-11-25
Creator: Craeg K. Strong

Evaluates a string as an XPath expression.
1.12002-08-21Craig Stewart

Added 4XSLT and libxslt implementation to the list.

1.22002-11-12Craig Stewart

Updated 4XSLT version to 0.12.0a3.

1.32003-01-30Craig Stewart

Added Xalan-J implementation to the list.

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