Reputation: 3498
Imagine you have a xml file:
<dictionary>
<row>
<table>log</table>
<entity>Log</entity>
</row>
<row>
<table>mail_macros</table>
<entity>MailMacro</entity>
</row>
</dictionary>
And you want to write a generic template to obtain an element from the row:
<xsl:template name="row">
<xsl:param name="pElement" />
<xsl:value-of select="./dictionary/row/$pElement />
</xsl:template>
So when I call the template with pElement set to string 'table' it returns table values etc.
Is it possible to write such an expression in xslt 1.0? Because this one does not work.
Upvotes: 3
Views: 791
Reputation: 12729
XPATH expressions don't work like that. You need ....
<xsl:value-of select="./dictionary/row/*[local-name()=$pElement] />
Assumes you are not using namespaces. Let us know if otherwise.
Upvotes: 3