链接 XSL 时 XML 显示空白页 [英] XML shows blank page when linking XSL

查看:67
本文介绍了链接 XSL 时 XML 显示空白页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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 文件,它将显示一个空白页面.

If I don't link the XSLT file to the XML file, my XML file will output the tree structure in my browser's page but if I do link the XSLT file, it will show a blank page.

我正在使用 Chrome,如果有帮助的话.

I am using Chrome, if it helps to know.

谢谢.

推荐答案

我假设您正在从文件系统加载 XML 文档,在这种情况下,Chrome 出于安全原因不会应用链接的 XSLT,除非您以降低的方式启动它安全设定.使用 F12 打开浏览器控制台并检查 Chrome 是否显示一条消息,说明未应用 Xslt 的原因.

I assume you are loading the XML document from the file system and in that case Chrome for security reasons does not apply the linked XSLT, unless you start it with lowered security settings. Use F12 to open the browser console and check whether Chrome shows a message explaining why the Xslt was not applied.

这篇关于链接 XSL 时 XML 显示空白页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆