我不明白爲什麼xsl:param給了我一個錯誤'Keyword xsl:param可能不會用在命名空間http://www.w3.org/TR/WD-xsl中。在下面的樣式表聲明的xsl代碼中。xsl:param命名空間錯誤(可能不會在名稱空間中使用)
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="uri:xsl">
由於XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd n="a">
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
和XSL代碼
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="uri:xsl">
<xsl:param name="test" select="'a'"/>
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<xsl:choose>
<xsl:when match=".[@n = $test]">
<tr>
<td><xsl:value-of select="title" /></td>
<td><xsl:value-of select="artist" /></td>
</tr>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我不能改變樣式表聲明。仔細查看w3c文檔,我可以將param聲明爲樣式表的子代,並且不需要在模板中。
查看w3c文檔,您首先不會使用XSL(附加到'xsl'前綴的名稱空間很重要)。 – Lucero