XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="biblio.xsl"?>
<bibliography>
<entry type="article">
<title>A History of MOOCs, Open Online Courses</title>
<author>Jane Karr</author>
<year>2014</year>
</entry>
<entry type="article">
<title>Apple Co-Founder Creates Electronic ID Tags</title>
<author>John Markoff</author>
<year>2003</year>
</entry>
</bibliography>
XSL文件:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Bibliography Entries</h2>
<table border="1">
<xsl:for-each select="bibliography/entry">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="author"/></td>
<td><xsl:value-of select="year"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
如果我不将XSLT文件链接到XML文件,我的XML文件将在浏览器的页面中输出树结构,但如果链接XSLT文件,它将显示一个空白页。
我正在使用Chrome,如果有帮助的话。
谢谢。
发布于 2014-10-30 20:08:12
我假设您正在从文件系统加载XML文档,在这种情况下,出于安全原因,Chrome不应用链接的XSLT,除非您以较低的安全设置启动它。使用F12打开浏览器控制台,并检查Chrome是否显示了解释为什么没有应用Xslt的消息。
发布于 2020-12-27 11:21:52
如果有人在启动他们的XML和XSLT文件时仍然有问题--现在Mozzila也是出于安全原因,而不是应用链接的XSLT --您需要将about:config
中的about:config
属性更改为false,如果要应用XSLT样式的话。
对于那些不知道-进入about:config
,你只需要输入它在莫齐拉搜索栏。
发布于 2014-10-30 20:08:38
您的代码运行得很好。只需按以下方式启动Chrome:
Chrome.exe --allow-file-access-from-files
https://stackoverflow.com/questions/26662203
复制相似问题