We have preffered language set as variable in xslt:
<xsl:variable name="preferred _language">
zh
</xsl:variable>
Data:
<name xml:lang="de">R aw Materials (Mining incl.)</name>
<name xml:lang="zh"> 材料(包 采矿业) </name>
This works:
<h2><xsl:valu e-of select="name[@xml:lang='zh']"/></h2>
This will not work (produce result looks like "<h2></h2>"):
<h2><xsl:valu e-of select="name[@xml:lang=$pref erred_language]"/></h2>
For me it's no problem if I have to use <chooseand <whento do the same
task (for each <name>, output <h2>xx</h2only if the xml:lang equal to
$preferred_lang uage). 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