I think that considering your data's schema, you would be better off
using JSON as the transport. JSON works easily in every browser that
supports XmlHttpRequest, unlike XML. Instead of messing with the DOM
tree of responseXML (as you would have to with XML), you can simply use
one line of code to turn your JSON data (from responseText) into an
array of Objects, and use much less code to generate your table using DOM.
I agree that JSON might be easier, but he's already got XML coming from
his server. If you've got the option to provide JSON text output, you
may want to consider it. It's no harder then pumping out an XML file.
If you want to stick with XML, you may want to look at Google's
heavyweight "AJAXSLT" library: <
http://goog-ajaxslt.sourceforge.net/> -
I have never used it and am not vouching for it, but if you want to
reliably do XSLT from Javascript you're going to have to use a fairly
heavy library to do it.
How heavyweight is XSLTProcessor (non-IE) or Microsoft.XMLDOM (IE)?
Doesn't seem that cumbersome to me. I do something similar (you'd have
to hack at this code a bit but for your purposes, but)...
if (typeof XSLTProcessor != 'undefined') {
var processor = new XSLTProcessor();
var request = getXMLHttpRequest();
if (request) {
request.open("GET", url, false);
request.send(null);
var xsl = request.responseXML;
processor.importStylesheet(xsl);
var fragment = processor.transformToFragment(value, document);
if (element)
element.appendChild(fragment);
}
else {
return;
}
}
else {
var processor = new ActiveXObject("Microsoft.XMLDOM");
if (processor) {
processor.async = false;
processor.load(url);
var xmlString = value.transformNode(processor);
if (element)
element.innerHTML = xmlString;
}
else {
return;
}
}