Hi, I'm trying to perform client-side XSL transformation in various browsers and found this code snippet from W3 Schools:
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
xhttp.send("");
return xhttp.responseXML;
}
function displayResult()
{
xml=loadXMLDoc("cdcatalog.xml");
xsl=loadXMLDoc("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);
}
}
I used it with minimal modifications, e.g. only variables and transformation target. It doesn't work in Chrome and Internet Explorer 8, the latter being my priority for now.
The code in IE fails at the "ex = xml.transformNode(xsl);" complaining about a "missing parameter" ("order") which I have no idea where to look for. I'm at a loss... I already checked that both xml and xsl are well-formed and loaded, but still the transformation fails. The code works perfectly on Firefox.
Thanks