【发布时间】: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