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(如果有帮助的话)。
谢谢。
我假设您是从文件系统加载XML文档,在这种情况下,出于安全原因,Chrome不会应用链接的XSLT,除非您使用降低的安全设置启动它。使用F12打开浏览器控制台,然后检查Chrome是否显示一条消息,说明未应用Xslt的原因。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句