Hallo @all
my problem is XMLHTTP by Mozilla Browser
is an example W3SCHOOL
http://www.w3schools.com/xsl/xsl_client.asp

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>html work with xml and xsl</title>
<meta content="text/html; charset=us-ascii" http-equiv="Content-Type">
<script type="text/javascript">
var xsltProcessor;
var xml;
var xsl;
var xhttp;
var ex;
function checkBrowserName(name){
    var agent = navigator.userAgent.toLowerCase();
    if (agent.indexOf(name.toLowerCase())>-1) {
      return true;
    }
    return false;
}
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
  {
  alert('mozilla ie7 ie8');
  xhttp=new XMLHttpRequest();
  }
else
  {
  alert(' <= ie6');	
  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xhttp.open("GET",dname,false);
xhttp.send("");

return xhttp.responseXML;
}

function displayResult()
{
//xml=loadXMLDoc("http://localhost/catalog.xml");
//xsl=loadXMLDoc("http://localhost/catalog.xsl");

// code for IE
if (window.ActiveXObject)
 {
 	xml=loadXMLDoc("http://localhost/catalog.xml");
	xsl=loadXMLDoc("http://localhost/catalog.xsl");
   alert("IE 1");
   alert("IE 12" + xml);
   alert("IE 13" + xsl);
  ex=xml.transformNode(xsl);
  alert("IE 2");
  document.getElementById("example").innerHTML=ex;
  alert("IE 3");
  }
else if (document.implementation && document.implementation.createDocument)
  {  	
  alert("moz1");
  xml=loadXMLDoc("http://localhost/catalog.xml");//failt
  //xml=loadXMLDoc("file:///D:/forum/catalog.xml");//works
  //xml=loadXMLDoc("catalog.xml");//works 
  alert("moz12" + xml );	
  xsl=loadXMLDoc("file:///D:/forum/catalog.xsl");//works
  //xsl=loadXMLDoc("catalog.xsl");//works
  alert("moz13"+ xsl);
  xsltProcessor=new XSLTProcessor();
  alert("moz2"+ xsl);
  xsltProcessor.importStylesheet(xsl);
  xsltProcessor.setParameter(null, "sort", "ascending");
  xsltProcessor.setParameter(null, "datatyp", "text");
  xsltProcessor.setParameter(null, "kn", "title");
  alert("moz3");
  resultDocument = xsltProcessor.transformToFragment(xml,document);
  document.getElementById("example").appendChild(resultDocument);
  }
}
</script>
</head>
<body onload="displayResult()">
<div><input type="button" value="sort" id="txtSearch" onclick="displayResult();"></div>
<div id="example" />
</body>
</html>

why failt mozilla by this "http://localhost/catalog.xml"

Member Avatar for rakhi4110

Are you sure about your catalog.xml file residing in the WEB-INF folder of your tomcat installation. What server are you using. If you are using tomcat make sure your catalog.xml file resides in the WEB-INF folder. If there is any other folder inside your WEB-INF folder then use http://localhost:<port number>/<folder name>/<file name>.xml

Kindly see if this helps in any kind and inform me. And also provide little more details regarding the problem

Thanks and regards,
RAKHI

The false in xhttp.open("GET",dname,false); makes the request synchronous. Most browsers' javascript only handle asynchronous requests (ie AJAX).

The code pattern will need to be modified. It's more involved than just changing false to true (though not unduly complex). I'm sure W3Schools must cover this.

Airshow

Another thing ....

Just about all current browsers (anything other than IE 5/6) won't handle cross-domain AJAX (at least not without taking special measures).

"http://localhost/catalog.xml" may be OK but only if your main page is also served from localhost. Even so, it would be safer to use a relative URL eg. "catalog.xml".

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.