This transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="my:my" exclude-result-prefixes="my">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="pUrl" select="'www.mysite/es/home.htm '"/>
<my:headings>
<h lang="en">
<description>Description</description>
<gameType>Game Type</gameType>
</h>
<h lang="es">
<description>Descripción</description>
<gameType>Tipo De Juego</gameType>
</h>
</my:headings>
<xsl:variable name="vHeadings" select="document('')/*/my:headings/*"/>
<xsl:template match="/">
<xsl:variable name="vLang" select=
"substring-before(substring-after($pUrl, '/'), '/')"/>
<table>
<thead>
<td><xsl:value-of select="$vHeadings[@lang=$vLang]/description"/></td>
<td><xsl:value-of select="$vHeadings[@lang=$vLang]/gameType"/></td>
</thead>
</table>
</xsl:template>
</xsl:stylesheet>
when applied on any XML document (not used), produces the wanted headings:
<table>
<thead>
<td>Descripción</td>
<td>Tipo De Juego</td>
</thead>
</table>
Note: In a real-world app you may want to put the language-specific data in a separate XML file (or even in files -- one per language) -- in such a case you only need to slightly change the call to the document()
function in this code.
UPDATE:
The OP has indicated in a comment that the use of document()
is forbidden in his environment.
Here is the same solution with a slight modification to work without using document()
:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ext="http://exslt.org/common" exclude-result-prefixes="ext">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="pUrl" select="'www.mysite/es/home.htm '"/>
<xsl:variable name="vrtfHeadings">
<h lang="en">
<description>Description</description>
<gameType>Game Type</gameType>
</h>
<h lang="es">
<description>Descripción</description>
<gameType>Tipo De Juego</gameType>
</h>
</xsl:variable>
<xsl:variable name="vHeadings" select="ext:node-set($vrtfHeadings)/*"/>
<xsl:template match="/">
<xsl:variable name="vLang" select=
"substring-before(substring-after($pUrl, '/'), '/')"/>
<table>
<thead>
<td><xsl:value-of select="$vHeadings[@lang=$vLang]/description"/></td>
<td><xsl:value-of select="$vHeadings[@lang=$vLang]/gameType"/></td>
</thead>
</table>
</xsl:template>
</xsl:stylesheet>