Permission denied to call method XMLDocument.load
"Daniel Frechette" <daniel_@_treknowledge_._com>
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Organization | TreKnowledge Inc. |
| Message-ID | <[email protected]> |
Hi,
For testing purposes, I am trying to build a XSLT viewer that takes 2 files
as input and displays the transformation results in the second half of the
screen. The problem is that I keep getting the following javascript
exception: "Permission denied to call method XMLDocument.load". I have a
similar script for IE and it works fine.
Also, does anyone know how to catch and interpret exceptions thrown by
importStylesheet() and transformToDocument().
Here is the code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Firefox XSLT Viewer</title>
<script type="text/javascript">
function ApplyStylesheet(xml, xsl) {
var xsltProc = new XSLTProcessor();
var xmlDoc = document.implementation.createDocument("", "", null);
var xslDoc = document.implementation.createDocument("", "", null);
xmlDoc.load(xml);
xslDoc.load(xsl);
var resultDoc = xsltProc.transformToDocument(xmlDoc);
var xmlSerial = new XMLSerializer;
html = xmlSerial.serializeToString(resultDoc);
document.getElementById("result").innerHTML = html;
}
</script>
</head>
<body style="font-family:arial; font-size:0.85em;">
<div style="padding:2px;">Fichier XML <input type="file" size="30"
id="xmlFile"/></div>
<div style="padding:2px;">Fichier XSL <input type="file" size="30"
id="xslFile"/></div>
<div style="padding:2px;"><input type="button" value="Apply Stylesheet"
onclick="javascript:ApplyStylesheet(document.getElementById('xmlFile').value,
document.getElementById('xslFile').value);"/></div>
<div
style="padding:2px;">--- --- --- --- --- --- --- --- --- --- --- --- --- ---
--- --- --- --- ---</div>
<div style="padding:2px;" id="result"></div>
</body>
</html>