Re: How to get XSLTProcessor.transformToDocument output in a tab/document?
Michael Vincent van Rantwijk <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Organization | Another Netscape Collabra Server User |
| Message-ID | <[email protected]> |
Axel Hecht wrote:
> Michael Vincent van Rantwijk wrote:
>> Hi,
>>
>> How do I display a XSL Transformed XMLDocument(fragment) after
>> reading it in with XMLHttpRequest.open("GET", aURL) ???
>>
>> Something like this works when I first load the XML uri into a tab:
>>
>> var ownerDocument = document.implementation.createDocument("", "", null);
>> var newFragment = processor.transformToFragment(doc, ownerDocument);
>> var _documentElement = doc.documentElement;
>>
>> while (_documentElement.hasChildNodes())
>> _documentElement.removeChild(_documentElement.firstChild);
>> _documentElement.appendChild(newFragment);
>>
>> But I don't want to load it into a tab.
>> I just want to load it, transform it and put the output into a tab.
>> I use this:
>>
>> var newDocument =
>> processor.transformToDocument(XMLHttpRequest.responseXML);
>>
>> instead of method transformToFragment (I hope that's the right thing use)
>> without any warnings and errors, so it seems to be fine but...there's no
>> output. Or when I change it a little, the complete window is overwritten
>> replaced with the backgkround of my XSL stylesheet and a text for empty
>> sidebar is displayed, so I must be doing something very wrong.
>>
>> Again, everything works when I call my function *after* entering the
>> URL into
>> the locationbar, but that's not what I want!
>>
>> Uhg, I hope I made myself clear.
>> I whish my English was a little better--maybe next year ;)
>>
>> p.s I've accidentally asked the same question in another newsgroup,
>> sorry for that mistake!
>>
>
> Sorry, we need a testcase here.
>
> I do expect that you should call transformToFragment with the right
> owner document (probably just document, which is the one you're seeing
> and want to modify).
What do you mean with 'owner document'? Is that my target (output)
document? FYI: document points to
chrome://navigator/content/navigator.xul and that's not the one I want,
I want browser.docShell.document right?
> Axel
I use the following code to read the XML file:
var request = new XMLHttpRequest()
var handler = this;
request.overrideMimeType("application/xml");
request.open("GET", aURL);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var channel =
request.channel.QueryInterface(Components.interfaces.nsIHttpChannel);
handler._XMLDocument = (channel.responseStatus == 200) ?
request.responseXML : null;
}
}
request.send(null);
but how do I get it to parse 'handler._XMLDocument'?
I found nsIDOMParser.idl and I wonder if I can/should use method
parseFromBuffer to parse my XSLTransformed XML document to make it
visible in a tab (document).
Michael