TD; LR:
无论XSL和XML文件如何,XSL转换似乎都不能在Chrome 71上运行,但可以在Firefox上运行。
举例来说,我有两个文件(是我从W3School借来的):
simple.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="simple.xsl"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
和simple.xsl
:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd"
/>
<xsl:template match="/">
<html>
<body>
<h1>Music Collection:</h1>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<tr>
<td><xsl:value-of select="catalog/cd/title" /></td>
<td><xsl:value-of select="catalog/cd/artist" /></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
当我在Firefox上运行时,它可以正常工作,但是在Chrome上,我在控制台上有一个空白页面,出现此错误(我在Firefox上没有得到):
从URL文件:/// [...] /simple.xml的框架中加载URL文件:/// [...] /simple.xsl的不安全尝试。 “文件:” URL被视为唯一的安全来源。
Chrome甚至能够运行XSL转换吗?我觉得很奇怪,因为W3School片段在此浏览器上能很好地工作,但是当我复制并粘贴代码并在计算机上运行代码时,它就无法工作。我该怎么办?
谢谢您的帮助。