Re: appendChild(newFragment) problem
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:
>> Axel Hecht wrote:
>>> Michael Vincent van Rantwijk wrote:
>>>> Hi,
>>>>
>>>> I finally managed to get my source code running, but I have a little
>>>> problem which can be seen in the attached image (that shows the
>>>> duplicated elements).
>>>>
>>>> I use something like this:
>>>>
>>>> var targetDocument = gBrowser.contentDocument
>>>> var newFragment = processor.transformToFragment(xmldoc,
>>>> targetDocument);
>>>> var _documentElement = targetDocument.documentElement;
>>>>
>>>> // remove HEAD and BODY elements
>>>> while (_documentElement.hasChildNodes()) {
>>>> _documentElement.firstChild.localName);
>>>> }
>>>>
>>>> _documentElement.appendChild(newFragment);
>>>>
>>>> and that works, except that I end up with two HTML elements, one in
>>>> uppercase, and one in lowercase, so how do I prevent this?
>>>>
>>>
>>> You need to skip the html element in your output fragment as well.
>>
>> Another problem is that all elements are in XHTML namespace but the
>> HTML element of the target document not. Should I also set that myself?
>
> Make sure that the output of your XSLT matches your dummy doc in
> doctype. Everything else will go wrong easily.
I just wish I could replace the document, without reloading about:blank
to get a new document. Is that somehow possible with
xsltprocessor.transformToDocument() ?
> You shouldn't rely on Quirks mode either.
I guess that you want me to change the output and set something I've
seen at devmoz, which was something about forcing XHTML output if I'm
correct.
> Using DOM Inspector, I can delete the head element, btw. Not sure what's
> your problem there. You can't remove the document element (HTML), but
> everything else should be fine.
Yep, that also works for me. I guess I was just doing something wrong
while I was learning all this new stuff.
Michael