I've been working on a Firefox extension that utilizes XSL transformations with no issues. However, I encountered a problem when trying to perform an xsl:include from the XSL stylesheet. Upon importing the XSL stylesheet containing an xsl:include statement, Firefox throws an error:
Error: Component returned failure code: 0x80600001 [nsIXSLTProcessor.importStylesheet] = Source file: chrome://myextension/content/functions.js Line: 632
This issue only arises when executing the code from within the Firefox extension. Running it on a regular HTML page functions perfectly fine. I experimented with xsl:import and absolute URIs like
chrome:\\myextension\content\xsl\test2.xsl
, but still faced the same error.
Any insights on what mistake I might be making? Appreciate any help in advance.
Below is the sample code to replicate the problem (all files located 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>