load xml+xsl in html
-
i have loaded xml+xsl in html. but it only works for simple xml and xsl.when i have a large xml and slightly cmplex xsl and have dtd the code dosen't work. here is the code for loading:: function loadXMLDoc(fname) { var xmlDoc; // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); } else { alert('Your browser cannot handle this script'); } xmlDoc.async=false; xmlDoc.load(fname); return(xmlDoc); } function displayResult() { ///////////////LOAD XML & XSL///////////////// xml=loadXMLDoc("Book2006_Overview.xml"); xsl=loadXMLDoc("book2006.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); } } can anyone send me the code works for all xml and xsl pls?
-
i have loaded xml+xsl in html. but it only works for simple xml and xsl.when i have a large xml and slightly cmplex xsl and have dtd the code dosen't work. here is the code for loading:: function loadXMLDoc(fname) { var xmlDoc; // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); } else { alert('Your browser cannot handle this script'); } xmlDoc.async=false; xmlDoc.load(fname); return(xmlDoc); } function displayResult() { ///////////////LOAD XML & XSL///////////////// xml=loadXMLDoc("Book2006_Overview.xml"); xsl=loadXMLDoc("book2006.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); } } can anyone send me the code works for all xml and xsl pls?
-
i have loaded xml+xsl in html. but it only works for simple xml and xsl.when i have a large xml and slightly cmplex xsl and have dtd the code dosen't work. here is the code for loading:: function loadXMLDoc(fname) { var xmlDoc; // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); } else { alert('Your browser cannot handle this script'); } xmlDoc.async=false; xmlDoc.load(fname); return(xmlDoc); } function displayResult() { ///////////////LOAD XML & XSL///////////////// xml=loadXMLDoc("Book2006_Overview.xml"); xsl=loadXMLDoc("book2006.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); } } can anyone send me the code works for all xml and xsl pls?
Do the xml namespaces in the more complex xml and those in the more complex xslt match? This often happens when moving from a test document to a real live one. We can't see the problem unless you want to put up an example of the simple xml/xslt and then the more complex failing ones.
-
Do the xml namespaces in the more complex xml and those in the more complex xslt match? This often happens when moving from a test document to a real live one. We can't see the problem unless you want to put up an example of the simple xml/xslt and then the more complex failing ones.
Hi, the problem of loading xml+xsl is solved for mozilla.the problem was i ddin't know mozilla doesn't support external dtd.it works fine for internal dtd.But IE cannot load either external or internal.i used several alerts in several position.all are showed in output.but the transformed xml page does not show. function loadXMLDoc(fname) { var xmlDoc; // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); alert("LoadXML"); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); } else { alert('Your browser cannot handle this script'); } xmlDoc.async=false; xmlDoc.load(fname); return(xmlDoc); } function displayResult() { xml=loadXMLDoc("Book2006_Overview.xml"); xsl=loadXMLDoc("Book2006_manee.xsl"); // code for IE if (window.ActiveXObject) { ex=xml.transformNode(xsl); document.getElementById("example").innerHTML=ex; alert("after innerHTML"); alert(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); } }