G
Guest
We have preffered language set as variable in xslt:
<xsl:variable name="preferred_language">
zh
</xsl:variable>
Data:
<name xml:lang="de">Raw Materials (Mining incl.)</name>
<name xml:lang="zh">原æ料(包括采矿业) </name>
This works:
<h2><xsl:value-of select="name[@xml:lang='zh']"/></h2>
This will not work (produce result looks like "<h2></h2>"):
<h2><xsl:value-of select="name[@xml:lang=$preferred_language]"/></h2>
For me it's no problem if I have to use <choose> and <when> to do the same
task (for each <name>, output <h2>xx</h2> only if the xml:lang equal to
$preferred_language). Just I wish to confirm that is it "in all places
variable cannot be used in xpath" or "I have used xpath with variable in
wrong format".
another question: is it possible to use URI parameter in xslt? I am
developing in php so I can write:
<xsl:variable name="preferred_language">
<?= $_GET['lang'] ?>
</xsl:variable>
but I am stupid to do this if XSLT itself can use URI parameter. By URI
parameter I mean the "?lang=zh" section in following URI:
http://www.mysite.com/businessCategory.xml?lang=zh
<xsl:variable name="preferred_language">
zh
</xsl:variable>
Data:
<name xml:lang="de">Raw Materials (Mining incl.)</name>
<name xml:lang="zh">原æ料(包括采矿业) </name>
This works:
<h2><xsl:value-of select="name[@xml:lang='zh']"/></h2>
This will not work (produce result looks like "<h2></h2>"):
<h2><xsl:value-of select="name[@xml:lang=$preferred_language]"/></h2>
For me it's no problem if I have to use <choose> and <when> to do the same
task (for each <name>, output <h2>xx</h2> only if the xml:lang equal to
$preferred_language). Just I wish to confirm that is it "in all places
variable cannot be used in xpath" or "I have used xpath with variable in
wrong format".
another question: is it possible to use URI parameter in xslt? I am
developing in php so I can write:
<xsl:variable name="preferred_language">
<?= $_GET['lang'] ?>
</xsl:variable>
but I am stupid to do this if XSLT itself can use URI parameter. By URI
parameter I mean the "?lang=zh" section in following URI:
http://www.mysite.com/businessCategory.xml?lang=zh