xsl-list
[Top] [All Lists]

RE: Navigating through the document using variables

2005-05-31 14:59:33
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/



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>