Re: 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]> |
Here is a new version of my viewer. With this new version I no longer get
the "Permission denied" message; however, I still cannot get a valid result.
The code hangs when it reaches "xslDoc.load(xslFile)". You can try it
yourself at http://treknowledge.com/dmsxpert/foxyXSLTViewer.htm.
Thank you,
Daniel
The javascript (foxyXSLTViewer.htm):
<?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(xmlFile, xslFile) {
var html = null;
try {
var xmlDoc = document.implementation.createDocument("",
"test", null);
xmlDoc.load(xmlFile);
var xslDoc = document.implementation.createDocument("",
"test", null);
xslDoc.async = false;
xslDoc.load(xslFile);
var xsltProc = new XSLTProcessor();
xsltProc.importStylesheet(xslDoc);
var resultDoc = xsltProc.transformToDocument(xmlDoc);
var xmlSerial = new XMLSerializer;
html = xmlSerial.serializeToString(resultDoc);
} catch (e) {
// Do nothing
} finally {
document.getElementById("result").innerHTML = (html != null) ?
html : "XSLT Failed!"
}
}
</script>
</head>
<body style="font-family:arial; font-size:0.85em;">
<div style="padding:2px;">XML File <input type="text" size="50"
id="xmlFile" value="http://treknowledge.com/dmsxpert/test.xml"/></div>
<div style="padding:2px;">XSL File <input type="text" size="50"
id="xslFile" value="http://treknowledge.com/dmsxpert/test.xsl"/></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>
The XSL file (test.xsl):
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<h1>It WORKS!</h1>
</xsl:template>
</xsl:stylesheet>
The XML file (text.xml):
<?xml version="1.0" encoding="UTF-8"?>
<main>
<context>
<session sessionId="123456789" langCode="en" contextId="test"/>
</context>
<model id="i99999">
</model>
<literals>
<entry id="5001">Save</entry>
<entry id="5002">Reset</entry>
</literals>
</main>