我想知道,在XML文档中,xmlns URL是否有任何实际意义?
我参考了链接。现在当我将xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
更改为其他内容时,它停止工作了。W3C说命名空间名称(或URL)只是用于区分XML标记。那么为什么更改URL后它不起作用了呢?
所以我想,可能与该URL有关,因此尝试在本地(没有互联网)上进行..请参见以下示例..
XML文档。(first.xml)
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="first.xsl"?>
<!-- Edited by XMLSpy® -->
<catalog>
<cd>
<title>Unchain my heart</title>
<artist>Joe Cocker</artist>
<country>USA</country>
<company>EMI</company>
<price>8.20</price>
<year>1987</year>
</cd>
<cd>
<title>Pavarotti Gala Concert</title>
<artist>Luciano Pavarotti</artist>
<country>UK</country>
<company>DECCA</company>
<price>9.90</price>
<year>1991</year>
</cd>
<cd>
<title>The dock of the bay</title>
<artist>Otis Redding</artist>
<country>USA</country>
<company>Atlantic</company>
<price>7.90</price>
<year>1987</year>
</cd>
</catalog>
XSLT文档(first.xsl)
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<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">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
所以,在本地工作正常。但是,如果我更改xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
为其他内容,例如xmlns:xsl="http://www.abc.com"
,则会在浏览器中出现错误。
Error loading stylesheet: Parsing an XSLT stylesheet failed.
所以,唯一的问题是,在xmlns中是否有任何真正的意义。如果有的话,为什么在没有互联网的情况下它可以工作,而在改变xsl中的url后却不能工作。