Re: Can I use 'about:blank' as target document?
Jonas Sicking <[email protected]> Wed, 04 Apr 2007 14:29:13 -0700
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Message-ID | <[email protected]> |
Michael Vincent van Rantwijk, MultiZilla wrote:
> Can I use 'about:blank' as 'targetDocument' in the following example:
>
> var newFragment = processor.transformToFragment(xmldoc, targetDocument);
>
> I ask this because I don't see anything in the DOM when I the snippet
> below to insert it into the DOM:
>
> targetDocument = xmldoc;
> _documentElement = targetDocument.documentElement;
> // Remove everything up to the document's <head> element
> while (_documentElement.hasChildNodes()) {
> _documentElement.removeChild(_documentElement.firstChild);
> }
> // Import <head> and <body> elements from the document fragment
> for (var i = 0; i < newFragment.firstChild.childNodes.length; i++) {
> var newNode =
> targetDocument.importNode(newFragment.firstChild.childNodes[i], true);
> _documentElement.appendChild(newNode);
> }
>
> Note: everything I expect (all elements/children) are part of the
> 'newFragment' so that can't be the problem.
First of all, you should use the document that you want to insert the
nodes in as 'targetDocument'. That way you don't need to call
.importNode on each of the nodes in the resulting fragment. That is the
whole point of being able to specify a target document.
To answer your question though, there are some tricky security stuff wrt
about:blank documents, do you see any errors in the error console?
Since it sounds like you are getting the result you are expecting from
the XSLT transform, you're just then having problems displaying those
nodes, this is likely not an XSLT related problem.
It would be good if you could provide a minimal testcase to see what
you're trying to do.
/ Jonas