Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么这个XML文件不显示任何内容?_Xml_Xslt_Google Chrome - Fatal编程技术网

为什么这个XML文件不显示任何内容?

为什么这个XML文件不显示任何内容?,xml,xslt,google-chrome,Xml,Xslt,Google 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&g

可能重复:

我有一个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>

离去
鲍勃·马利
牙买加
19,99
黑色相册
金属
美国
20,00
没有关系
涅槃
美国
22,00
指向此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文件时,我看不到任何显示。因为我是按照指示从教程中复制的,所以我不确定这里出了什么问题。您是否知道是什么原因导致缺少显示?

根据您使用的浏览器的XSLT约束,您可能什么也看不到

我使用Chrome19.0.1084.46和Firefox3.6.22在本地测试了您的文件

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

当我在Chrome中的developer tools上打开控制台选项卡时,它显示以下消息:

加载URL的尝试不安全 file:///temp/web/catalog.xsl 从带有URL的框架 file:///temp/web/catalog.xml. 域、协议和 端口必须匹配

然后,我启动了我的Tomcat并部署了这2个文件,当我从Chrome voilá访问xml时,它显示了一切


我猜您正在使用file:///访问它,这与这个问题有关

它实际上对我有用。浏览器问题?@Keyser:我在Chrome上试过这个。你在什么地方试过这个?它在InternetExplorer8和Firefox3.6中都能正常浏览,这是我目前唯一可用的浏览器。您确定您的xsl文件命名正确吗?它的名字,根据XML文件必须是“catalog.xsl”,你确定你做到了吗?firefox for ubuntu canonical 1.0(上面也提到12.0),即使有一个名称不正确的xsl文件,他也会看到XML文件中的一些文本