J
John
I'm new to XSLT and I've been trying to figure out a solution for the
last couple of days. The XML & XSLT stylesheet are below. Basically I
want to declare some language (English, French, etc.) variables at the
beginning of the stylesheet, however I keep getting variable scope errors.
The language strings are specific to this template. There aren't many
since most of the data is coming from an application through XML. Below
is a simplified example. I'm trying to accomodate multiple languages
without having to maintain multiple stylesheets. Any ideas on how to
accomplish this?
XML:
----
<root>
<language>en</language>
</root>
XSL:
----
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html" encoding="UTF-8" indent="yes" />
<xsl:if test="//language = 'en'">
<xsl:variable name="language">English</xsl:variable>
</xsl:if>
<xsl:if test="//language = 'fr'">
<xsl:variable name="language">French</xsl:variable>
</xsl:if>
<xsl:template match="/">
<xsl:value-of select="$language" /> <== variable 'language' not found
</xsl:template>
</xsl:stylesheet>
Thanks!
last couple of days. The XML & XSLT stylesheet are below. Basically I
want to declare some language (English, French, etc.) variables at the
beginning of the stylesheet, however I keep getting variable scope errors.
The language strings are specific to this template. There aren't many
since most of the data is coming from an application through XML. Below
is a simplified example. I'm trying to accomodate multiple languages
without having to maintain multiple stylesheets. Any ideas on how to
accomplish this?
XML:
----
<root>
<language>en</language>
</root>
XSL:
----
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html" encoding="UTF-8" indent="yes" />
<xsl:if test="//language = 'en'">
<xsl:variable name="language">English</xsl:variable>
</xsl:if>
<xsl:if test="//language = 'fr'">
<xsl:variable name="language">French</xsl:variable>
</xsl:if>
<xsl:template match="/">
<xsl:value-of select="$language" /> <== variable 'language' not found
</xsl:template>
</xsl:stylesheet>
Thanks!