Re: XSLT Conversion not quite there
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <[email protected]> |
Hello.
Having tried again from scratch I am hitting the same problem.
The code I have is
function handleHttpResponse() {
if (http.readyState == 4) {
if (http.responseText.indexOf('invalid') == -1) {
// Use the XML DOM to unpack the city and state data
var xmlDocument = http.responseXML;
var city =
xmlDocument.getElementsByTagName('city').item(0).firstChild.data;
var state =
xmlDocument.getElementsByTagName('state').item(0).firstChild.data;
document.getElementById('city').value = city;
document.getElementById('state').value = state;
document.getElementById("dataArea").innerHTML = getHtml();
isWorking = false;
}
}
}
function getHtml () {
//create an xml document object
var xmldoc = document.implementation.createDocument("", "", null);
xmldoc.async = false;
//create an xsl document object
var xsldoc = document.implementation.createDocument("", "", null);
//load the objects with xswl and xml
if (xmldoc.load("books.xml")) { }
else {
alert("error");
}
if (xsldoc.load("books.xsl")) { }
else {
alert("xslerror");
}
var xsltProcessor = new XSLTProcessor();
//here is an error xsltProcessor.importStylesheet is not a function
xsltProcessor.importStylesheet(xsldoc);
var myDocument = xsltProcessor.transformToDocument(xmldoc);
var author =
xmldoc.getElementsByTagName('author').item(1).firstChild.data;
return myDocument.documentElement.innerHTML;
}
If I return bookname it prints out the author fine no problem (So there
is xml there). But as soon as I get into the XSLTProcessor code things
dont seem to work. This code returns nothing whereas the code I took it
from works fine. The only difference is that rather than writing the
page as it loads I am keeping the page as it is, not reloading and just
changing the div with an id of dataArea on the return of an
XMLHTTPRequest.
Any ideas, hints, places to look. Or is what I am trying to do not
possible ?