|
next
|
 Subject: Using variables in a select attribute Author: (Deleted User) Date: 30 Nov 2005 01:22 PM
|
John,
The local-name(.)=$nodename idea didn't work because $nodename does not contain a node name, it contains an entire xpath expression, in this case /boiler_plate/branch_name.
So, what you need is something which will dynamically compile and evaluate that xpath expression. Lucky for you, the Saxon processor has that. It you are willing and able to use Saxon (select the saxon processor in the scenario processor tab), then the attached fragment does what you need. I tried this and it worked in saxon 8.6.1. If you use saxon 6, you should change the xmlns:saxon= to "http://icl.com/saxon". Remove the <var>....</var> when you are happy that it works ok.
<xsl:template match="tp_header">
<xsl:variable name="filename" select="@file_id"/>
<xsl:variable name="nodename" select="@element"/>
<xsl:variable name="xpathexpr" select="concat('document("', $filename, '")', $nodename)"/>
<var><xsl:value-of select="$xpathexpr"/></var>
<xsl:copy-of select="saxon:evaluate($xpathexpr)" xmlns:saxon="http://saxon.sf.net/"/>
</xsl:template>
If you can't use saxon, then I would suggest you write a java extension which does the same thing as saxon:evaluate. This is not as hard as it seems, just invoke an xslt processor.
Good luck,
Clyde
|
|
|