为什么此XML文件不显示任何内容? [英] Why does this XML file not display anything?

查看:314
本文介绍了为什么此XML文件不显示任何内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何使XSLT在chrome中工作?

Possible Duplicate:
How can I make XSLT work in chrome?

我有这个XML文件:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="catalog.xsl"?>

<catalog>
    <album>
        <title>Exodus</title>
        <artist>Bob Marley</artist>
        <country>Jamaica</country>
        <price>19,99</price>
    </album>
    <album>
        <title>Black Album</title>
        <artist>Metallica</artist>
        <country>USA</country>
        <price>20,00</price>
    </album>
    <album>
        <title>Nevermind</title>
        <artist>Nirvana</artist>
        <country>USA</country>
        <price>22,00</price>
    </album>
</catalog>

链接到此XSL文件:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">
        <html>
            <body>
                <h2>My Catalog</h2>
                <table border="1">
                    <tr bgcolor="#9ACD32">
                        <th>Title</th>
                        <th>Artist</th>
                    </tr>
                    <xsl:for-each select="catalog/album">
                        <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>

当我在浏览器中打开XML文件时,没有看到任何显示.由于我是按照指示从教程中复制的,因此我不确定这里出了什么问题.关于什么原因导致显示不足,您有任何线索吗?

When I open the XML file in a browser, I don't see anything being displayed. Since I copied from a tutorial as instructed, I'm not sure what went wrong here. Do you have any clue in terms of what may be causing the lack of display?

推荐答案

根据您使用的浏览器的XSLT约束,您可能看不到任何东西.

Depending on XSLT constraints of the browser you use you may see nothing.

我使用Chrome 19.0.1084.46和Firefox 3.6.22在本地测试了文件.

I tested your files locally using Chrome 19.0.1084.46 and Firefox 3.6.22.

在Firefox中,我可以毫无问题地查看它,但是在Chrome中,我什么也没看到.

In Firefox I could view it with no problems, but in Chrome I saw nothing.

当我在Chrome中的开发人员工具上打开控制台标签时,会显示以下消息:

When I opened the console tab at developer tools in Chrome it show this message:

不安全的尝试加载URL 带有URL的文件中的file:///temp/web/catalog.xsl 文件:///temp/web/catalog.xml.域,协议和 端口必须匹配.

Unsafe attempt to load URL file:///temp/web/catalog.xsl from frame with URL file:///temp/web/catalog.xml. Domains, protocols and ports must match.

然后,我启动了Tomcat并部署了2个文件,当我从Chrome voilà访问xml时,它可以按预期显示所有内容.

Then, I started my Tomcat and deployed the 2 files and when I accessed the xml from Chrome voilà, it shows everything as expected.

我猜您正在使用文件:///访问它,并且与此问题有关错误397894

I'm guessing that you are accessing it using file:/// and this is related to this issue Bug 397894

这篇关于为什么此XML文件不显示任何内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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