[英]Keyword xsl:eval may not be used in namespace http://www.w3.org/1999/XSL/Transform
[英]xsl:param namespace error (may not be used in namespace)
我不明白為什么xsl:param給我一個錯誤“關鍵字xsl:param不能在命名空間http://www.w3.org/TR/WD-xsl中使用”的錯誤。 在以下帶有樣式表聲明的xsl代碼中。
<?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聲明為樣式表的子級,並且不必將其放在模板中。
如果您的東西不在命名空間http://www.w3.org/1999/XSL/Transform中,則它不是XSLT樣式表,我也不知道它是什么。 沒有XSLT處理器會對其做任何有用的事情。 命名空間“ uri.xsl”可能存在某種語言,但是如果存在,我從沒碰過它,也不知道它可能是什么。
我在您的xslt中看到三個錯誤:
1)轉換開始時有兩條處理指令。 您應該僅使用一個(如果有)。
2)樣式表元素的名稱空間應為http://www.w3.org./1999/XSL/Transform
3)您缺少樣式表版本屬性
除這些要點外,您的樣式表也可以使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.