I am trying to create a cross-browser implementation that will take an
XML file, apply a XSL stylesheet to it and return a DOM stack of the
styled XML.
In non-IE browsers I am using something like the following
successfully:
NOTE: value is a global variable and element & url are passed to the
method. Element is the document element that is to contain the parsed
XML DOM and url points to the XSL stylesheet.
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;
}
}
In IE there is no XSLTProcessor, but there is the XMLDOM ActiveX
component. Problem is I don't know how to get it to return me an XML
DOM, just text:
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;
}
}
I've only found the transformNode method which returns a String, but
nothing that will return actual DOM objects.
Thanks in advance.
David Harper - 30 Aug 2006 07:16 GMT
> I am trying to create a cross-browser implementation that will take an
> XML file, apply a XSL stylesheet to it and return a DOM stack of the
> styled XML.
[SNIP]
This is not the appropriate newsgroup for a query about JavaScript.
This newsgroup is for discussions about database programming with Java.
I suggest that you send your query to comp.lang.javascript if you hope
to receive help with your problem.
David Harper
Cambridge, England
Tom Cole - 30 Aug 2006 14:00 GMT
Thank you. I had tried to delete the post (but apparently wasn't fast
enough).
> > I am trying to create a cross-browser implementation that will take an
> > XML file, apply a XSL stylesheet to it and return a DOM stack of the
[quoted text clipped - 9 lines]
> David Harper
> Cambridge, England