-1

我正在在线教程中学习 XML 和 XSLT中学习 XML 和 XSLT,并且遇到了一个 exampleS 的跨浏览器问题。

XML 文件在 Firefox 19.0 和 IE9 中正常运行,但在 Chrome 版本 25.0.1364.97 中没有。

知道为什么会发生这种情况,或者我应该怎么做才能避免浏览器问题?

这是我的 XML:

<?xml version="1.0" standalone="no" ?>

<?xml-stylesheet type="text/xsl" href="basic.xsl" ?>

<people>
    <husband employed = "Yes" >
        <name>Mark</name>
    <age>45</age>
    <wife>
        <wname>Janet</wname>
        <age>29</age>
    </wife>
    </husband>

    <husband employed = "No" >
        <name>Matt</name>
    <age>42</age>
    <wife>
        <wname>Annie</wname>
        <age>43</age>
    </wife>
    </husband>
</people>

& 这是我的 basic.xsl 文件:

<?xml version="1.0"?>

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

<xsl:template match="/">
    <html>
    <body>
    <table border="2px">
        <tr>
        <xsl:apply-templates/>
        </tr>
    </table>
    </body>
    </html>
</xsl:template>

<xsl:template match="husband">
    <td>
    <xsl:value-of select="name"/>
    </td>
</xsl:template>


</xsl:stylesheet>

Chrome 的控制台读数是:

从带有 URL 文件:///C:/Users/Ross/Desktop/XML%20Demos/people_externalXSL 的框架中加载 URL 文件:///C:/Users/Ross/Desktop/XML%20Demos/basic.xsl 的尝试不安全。 xml。域、协议和端口必须匹配。

4

1 回答 1

0

尝试这个:

<xsl:template match="husband/name">
    <td>
    <xsl:value-of select="text()"/>
    </td>
</xsl:template>
于 2013-02-26T23:21:09.853 回答