RE: [xsl] Navigating through the document using variables

Subject: RE: [xsl] Navigating through the document using variables
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 31 May 2005 22:59:33 +0100
> I have a variable initialized at runtime with the path to some element
> (something like this /elem1/elem2/elem3). Can I use this variable to
> navigate to the elem3 in another variable that is initialized with the
> document like this:
> <xsl:variable name="doc" select="document('./somedocument.xml')"/>
> 

A number of products including Saxon support an xx:evaluate() extension
which allows you to evaluate an XPath expression that's held in a string (or
in a node in a source document), but it's not part of the standard XSLT 1.0
or 2.0 language. It's a very useful extension though!

You have to be careful with the context for the expression: both the static
context (in-scope variables, namespaces) and the dynamic context (context
item and position). You'll almost certainly find that different products
handle these questions differently.

Michael Kay
http://www.saxonica.com/

Current Thread