xsl样式表在浏览器中对于xml文件不可见

时间:2017-06-23 07:44:35

标签: xml xslt

在看到许多类似的问题后,我能够解决所看到的错误,现在内容在浏览器上可见。但我无法看到样式表或样式的使用未被观察到,它只是显示为纯文本。请协助。

[xml file = content.xml]

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet content-type="text/xsl" href="xslcontent.xsl"?>
<catalog>
<cd>
<title>Ram Sailee</title>
<artist>Bipul Chhetri</artist>
<country>Nepal</country>
<company>Songs Nepal</company>
<price>300</price>
<year>2014</year>
</cd>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>

[xsl file = xslcontent.xsl]

<xml version="1.0" encoding="UTF-8"?>
<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 style="text-align:left" >Title</th>
<th style="text-align:left" >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>

以下是输出: output seen in browser

1 个答案:

答案 0 :(得分:0)

尝试在XML中更改此部分:

<?xml-stylesheet content-type="text/xsl" href="xslcontent.xsl"?>

为:

<?xml-stylesheet type="text/xsl" href="xslcontent.xsl"?>