我不明白为什么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