我有下面這段XSLT代碼:XSLT變量不工作
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:variable name="condition">(coasts='Adriatic Sea')or(coasts='Mediterranean Sea')</xsl:variable>
<xsl:template match="cia">
<html>
<head></head>
<body>
<table border="1">
<tr>
<th>Country</th>
<th>Capital</th>
<th>Area</th>
<th>Population</th>
<th>Inflation rate</th>
</tr>
<xsl:for-each select="country">
<xsl:if test="{$condition}">
<tr>
<td>
<xsl:value-of select="@name"/>
</td>
<td>
<xsl:value-of select="@capital"/>
</td>
<td>
<xsl:value-of select="@total_area"/>
</td>
<td>
<xsl:value-of select="@population"/>
</td>
<td>
<xsl:value-of select="@inflation"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
如果直接放在if元素的代碼工作正常條件表達式,但是,我的問題是,當我給你同樣的條件表達式的變量,然後在if元素中引用它不起作用。難道我做錯了什麼?這可能嗎? 謝謝!
@ user734702:如果您在進行某種動態評估之後,您將需要爲您的XSLT處理器查找或實現一些擴展功能。除非您提供可能導致另一種解決方案的表達式構造的細節。 – 2011-05-02 17:51:16