【问题标题】:xsl:include not working from a Firefox extensionxsl:include 在 Firefox 扩展中不起作用
【发布时间】:2010-01-20 12:30:56
【问题描述】:

我正在开发一个使用 XSL 转换的 Firefox 扩展。一世 一直在使用 XSLTProcessor 没有问题,直到我需要做一个 xsl:include 来自 XSL 样式表。当我导入 XSL 样式表时 使用 xsl:include,Firefox 会报错:

错误:组件返回失败 代码:0x80600001 [nsIXSLTProcessor.importStylesheet] = 源文件: chrome://myextension/content/functions.js 线路:632

这只发生在从 Firefox 扩展运行代码时,如果 我在“正常” html 页面中运行它,代码运行良好。我也试过 使用 xsl:import 并得到相同的结果。我还尝试使用像 chrome:\\myextension\content\xsl\test2.xsl 这样的绝对 URI 并得到相同的错误。

有谁知道我做错了什么?提前致谢

这里是重现它的代码(所有文件都在同一个文件夹中):

文件functions.js

function testXSL(){
        var processor = new XSLTProcessor();
        var xsl = document.implementation.createDocument("", "test", null);
        xsl.addEventListener("load", onXSLLoaded, false);

        xsl.load("test1.xsl");
        function onXSLLoaded() {
           processor.importStylesheet(xsl);
        }
}

文件test1.xsl

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xlink="http://www.w3.org/1999/xlink">

<xsl:include href="test2.xsl" />

</xsl:stylesheet>

文件test2.xsl

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xlink="http://www.w3.org/1999/xlink">

    <xsl:template match="/">
                <h1>Included!!</h1>
        </xsl:template>

</xsl:stylesheet>

【问题讨论】:

    标签: javascript xslt firefox-addon


    【解决方案1】:

    这似乎是一个 Firefox 回归错误。我找到了this one on Mozilla bugzilla。 恐怕没有人可以在这里帮助您,除非该错误已被修补,而且味道不好... 2 年前打开,6 个月以来没有更新。

    【讨论】:

    • 谢谢,我应该在发帖前检查 bugzilla。让我们希望这个错误得到一些关注。
    猜你喜欢
    • 2011-08-18
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多