I am developing a Firefox extension that uses XSL transformations. I have been using XSLTProcessor without problems until I needed to do an xsl:include from the XSL stylesheet. When I import the XSL stylesheet that uses an xsl:include, Firefox gives an error:
Error: Component returned failure code: 0x80600001 [nsIXSLTProcessor.importStylesheet] = Source file: chrome://myextension/content/functions.js Line: 632
This only happens when running the code from the Firefox extension, if
I run it in "normal" html page the code works perfectly. I also tried
with xsl:import and got the same result. I also tried with absolute URIs like chrome:\\myextension\content\xsl\test2.xsl
and get the same error.
Does anyone know what could I be doing wrong? Thanks in advance
Here goes the code to reproduce it (all files are in the same folder):
File 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);
}
}
File 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>
File 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>