Hi!
Total newbie. Thanks in advance. Here goes:
I'm trying to transform an XML document using an XSL stylesheet, and the XSL stylesheet links to a CSS file. When I open the XML file from my computer in a browser (Chrome), the data is displayed properly following the XSL and CSS files. I also have javascript math functions inside the XSL stylesheet to take an element from the XML file and multiply it by different percentages. This math also works.
But when I try to use Javascript (below) to load/transform the XML document within HTML, the XSL styling comes through but the CSS is off. In Chrome, the page layout from the CSS shows. But the font size is too small and the background image doesn't appear. No matter what I change in the CSS the font is barely readable its so small. In IE, the CSS doesn't show up at all.
Also, the Javascript seems to be hiding the xml data, which I'd guess is bad for SEO.
Anyone have any tips/different approaches? I can't use ASP because my webserver won't allow it, but anything else.
Here's the script from my html document:
<html>
<head>
<script>
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("WORKS.xml");
xsl = loadXMLDoc("WORKS.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>
Merci buckets.
Alan