I'm using XSLT 1.1 and I have an external document I am accessing like so:
<xsl:variable name="doc2URI" select="ancestor-or-self::book/@secondDoc"/>
<xsl:variable name="doc2" select="document($doc2URI)"/>
What I'm trying to do is apply the template for a node in this document that is obtained by an XPath expression found in an XSLT variable:
<xsl:variable name="xpath">
<xsl:call-template name="genPath"/>
</xsl:variable>
The $xpath variable for instance, could at one point in the code contain the result of: /book[1]/title[1].
What I'd like to do is:
<xsl:apply-templates select="$doc2/$xpath"/>
But that doesn't work. If I go:
<xsl:apply-templates select="$doc2/book[1]/title[1]"/>
That does work, but there's no way I will know the exact XPath expression beforehand. It'll only be available through that $xpath variable.
My question is, how can I apply the template to that external document through the XPath expression contained in the $xpath variable?