MozillaZine

Client XSLT not working unless the files are in local

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
alex.jangam
 
Posts: 2
Joined: March 21st, 2011, 12:18 am

Post Posted March 21st, 2011, 12:27 am

Hi,

<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" >

<script>
function loadXMLDoc(dname)
{
var browserName=navigator.appName;

if (browserName=="Microsoft Internet Explorer")
{ xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
xhttp=new XMLHttpRequest();
}

xhttp.open("GET",dname,false);
xhttp.send("");
return xhttp.responseXML;
}

function displayResult()
{
xml=loadXMLDoc("http://www.w3schools.com/xsl/cdcatalog.xml");
xsl=loadXMLDoc("http://www.w3schools.com/xsl/cdcatalog.xsl");
// code for IE
if (window.ActiveXObject)
{
ex=xml.transformNode(xsl);
document.getElementById("example").innerHTML=ex;
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml,document);
document.getElementById("example").appendChild(resultDocument);
}
}
</script>
</head>
<body onload="displayResult()">
<div id="example" />
</body>
</html>

This code is showing an error in Firefox but is fine in IE.

if I download these files and give the local paths to these files the page is fine in Firefox but IE gives Access denied :D
Pls solve the issue ](*,)

Grumpus

User avatar
 
Posts: 11521
Joined: October 19th, 2007, 4:23 am
Location: ... Da' Swamp

Post Posted March 21st, 2011, 2:25 pm

According to this Wiki XSLT
As of 2010, however, XSLT 1.0[5] is still widely used, as there are no products that support XSLT 2.0 running in the browser, nor on some important server environments such as LAMP.

Are you using the later version?

jscher2000

User avatar
 
Posts: 10077
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA

Post Posted March 21st, 2011, 3:57 pm

alex.jangam wrote:This code is showing an error in Firefox but is fine in IE.

What is the error?

alex.jangam
 
Posts: 2
Joined: March 21st, 2011, 12:18 am

Post Posted March 23rd, 2011, 10:09 pm

uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///C:/Users/alex/Desktop/somefolder/htmlpage.html :: loadXMLDoc :: line 19" data: no]

jscher2000

User avatar
 
Posts: 10077
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA

Post Posted March 26th, 2011, 9:16 am

alex.jangam wrote:uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///C:/Users/alex/Desktop/somefolder/htmlpage.html :: loadXMLDoc :: line 19" data: no]

This is a little confusing. Originally, you referred to an error accessing a third party web site (usually a cross-site security issue) but the above error is for a local file. I don't know whether you can use XMLHttpRequest with a file; I think it requires a web server.

Return to Web Development / Standards Evangelism


Who is online

Users browsing this forum: No registered users and 0 guests