I am quite new to XSL and I would like to use my variable $language
inside my XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="data">
<xsl:value-of select="concat(//text-, $language)"/>
</xsl:template>
</xsl:stylesheet>
How can this be done?
This is my XML:
<data>
<params>
<language>en</language>
</params>
<static>
<entry id="1">
<text-en>Hello</text-en>
</entry>
<entry id="2">
<text-fr>Boujour</text-fr>
</entry>
</static>
</data>
Thanks for any help!
You should change the structure of the input XML and use e.g. <text xml:lang="en">Hello</text>
if you can, then you can write <xsl:value-of select="//text[lang($language)]"/>
.
If you can't change the structure of the input XML, use <xsl:value-of select="//*[local-name() = concat('text-', $language)]"/>
.