palanikumark Posted May 7, 2009 Share Posted May 7, 2009 This code works fine in IE but mozilla and safari throws error. <html><head><script src="sarissa.js" type="text/javascript" charset="utf-8"></script><script src="sarissa_ieemu_xpath.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript">function parseXML(){try //Internet Explorer { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xslDoc=new ActiveXObject("Microsoft.XMLDOM"); ie(); }catch(e) { try //Firefox, Mozilla, Opera, etc. { setXML(); setXSL();other(); } catch(e) { alert(e.message); return; }}}function setXML(){ xmlHttp=new XMLHttpRequest();var url="sample.xml";xmlHttp.onreadystatechange=function() {if (xmlHttp.readyState==4){ xmlDoc=xmlHttp.responseXML;return;}}xmlHttp.open("GET",url,true);xmlHttp.send(null);}function setXSL(){ xmlHttp1=new XMLHttpRequest();var url="sample.xsl";xmlHttp1.onreadystatechange=function() {if (xmlHttp1.readyState==4){ xslDoc=xmlHttp1.responseXML;return;}}xmlHttp1.open("GET",url,true);xmlHttp1.send(null);}//document.write(xmlDoc.transformNode(xsl));function ie(){xmlDoc = Sarissa.getDomDocument();xmlDoc.async = false;xmlDoc.load("sample.xml"); // get the stylesheet document xslDoc = Sarissa.getDomDocument(); xslDoc.async = false; xslDoc.load("sample.xsl"); // instantiate the result document var oResult = Sarissa.getDomDocument(); // transform and store the results to oResult xmlDoc.transformNodeToObject(xslDoc, oResult); // transform and store the results to a string sResult var sResult = xmlDoc.transformNode(xslDoc); //alert(sResult); document.write(sResult); } function other(){ var xmlDoc = Sarissa.getDomDocument(); // get the stylesheet document var xslDoc = Sarissa.getDomDocument(); // instantiate the result document var oResult = Sarissa.getDomDocument(); // transform and store the results to oResult xmlDoc.transformNodeToObject(xslDoc, oResult); // transform and store the results to a string sResult var sResult = xmlDoc.transformNode(xslDoc); document.write(sResult); }</script></head><body onload="parseXML()"><h1>Sorting</h1></body></html> Here is the xml file http://www.w3schools.com/xsl/cdcatalog.xml and xsl here http://www.w3schools.com/xsl/xsl_sort.asp Link to comment Share on other sites More sharing options...
palanikumark Posted May 11, 2009 Author Share Posted May 11, 2009 Finally I found the solution here http://johannburkard.de/software/xsltjs/ Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.