I am using Javascript to load XML and transform it with XSLT. Everything works until I try to use <xsl:include>
. Is it possible to include files this way?
Here is the relevant XSLT code.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
...
<xsl:include href="another_xslt.xsl"/>
</xsl:stylesheet>
And here is the javascript code:
var xmlRequest = new XMLHttpRequest();
xmlRequest.open("GET", "data.xml", false);
xmlRequest.send(null);
var xsltRequest = new XMLHttpRequest();
xsltRequest.open("GET", "https://hostname.com/directory/xslt/transform.xsl", false);
xsltRequest.send(null);
var xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsltRequest.responseXML);
return xsltProcessor.transformToDocument(xmlRequest.responseXML);
I am using Firefox 3.5 and the script fails on the xsltProcessor.importStylesheet
line without any error messages.
Update:
Tamper Data shows a request for another_xslt.xsl but in the parent directory so it is getting a 404.
All the xslt files are in https://hostname.edu/directory/xslt/ but Firefox is requesting http://hostname.edu/directory/another%5Fxslt.xsl instead. Why would it be requesting the file from the parent directory and without the https? The html file is in /directory/admin/edit
Using the full URL fixes the problem, but I need it to work on the server, so I would prefer to use the relative path like it is now.