[xsl] Dynamic XPath expression (I know it doesnt work in XSLT1.0)

Subject: [xsl] Dynamic XPath expression (I know it doesnt work in XSLT1.0)
From: Matt Dittbenner <mbditt@xxxxxxxxxxxxxxxxx>
Date: Thu, 26 Aug 2004 12:38:47 -0500
Hello,

After some pretty exhaustive searching on the web, I have decided to join the list. I have noticed in the archives that more than one person has had the same issue as I have...how to create an XPath expression dynamically (from a variable, etc). The answer to these questions was to use any of the available *:evaluate functions. I would like to try to avoid that, since it increases the parse time so much....and that is not acceptable.

My question is if there is any other way to accomplish this, for example using XSLT2.0. I have found little information about the newer XSLT recommendation, and the information I have found is fairly cryptic (at least to me). Here is a more detailed example of what I am trying to do:

===================================
doc.xml
<tag2>Data I want...</tag2>

template.xhtml
<p>
   <getContent path="tag2/text()"/>
</p>

stylesheet.xsl
<xsl:variable name="path" select="/p/getContent/@path" />
<xsl:value-of select="document('doc.xml')/$path"/>
===================================

In an ideal world, stylesheet.xsl would use the XPath expression from the attribute in template.xhtml to access another document (doc.xml) and then grab the data located there. How do I do this?!

Thanks in advance,
Matt Dittbenner

Current Thread