Re: cliente-side dynamic XSLT transformation with javascript

"..tato.." <[email protected]>fotocontato
Newsgroups gmane.comp.mozilla.devel.layout.xslt
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
"Martin Honnen" <[email protected]> escreveu na mensagem 
news:[email protected]...
>
>
> ..tato.. wrote:
>
>
>> removing the clause so it runs, it shows the images on the 2nd frame
>> but never finishes loading eg. I cannot see the frame´s source and
>> inspecting the DOM it looks like it is growing recursivelly 8-/
>>
>> code--------------
>> xmlDoc = document.implementation.createDocument('', '', null);
>> xslDoc = document.implementation.createDocument('', '', null);
>>
>> xmlDoc.addEventListener('load', xslLoad, false);
>> xmlDoc.load("fcImgList.xml");
>>
>> function xslLoad()
>> { xslDoc.addEventListener('load', xslTransform, false);
>>   xslDoc.load("fcImgList.xsl");
>> }
>>
>> function xslTransform()
>> { proc = new XSLTProcessor();
>>   proc.importStylesheet(xslDoc);
>>   var xmlObj = proc.transformToDocument(xmlDoc);
>>   var xmls = new XMLSerializer();
>>   var output = xmls.serializeToString(xmlObj);
>>   parent.frmBot.document.write(output);
>
> That has nothing to do with XSLT, if you use document.write to write 
> markup to a window or frame you need call
>   document.close()
> at the end e.g. in this case
>   parent.frmBot.document.close();
>
>
> As for the whole attempt to create a document using XSLTProcessor, then 
> serialize it and then use document.write to have the browser parse the 
> serialization, that is not the proper way to do it with Mozilla, you can 
> transform to a document fragement and simply use the DOM then to exchange 
> content as needed e.g.
>   var documentFragment = proc.transformToFragment(xmlDoc, 
> parent.frmBot.document);
>   parent.frmBot.document.documentElement.replaceChild(documentFragment, 
> parent.frmBot.document.body);
>
> Depending on what the transformation creates you might want to replace 
> something else than the body but the approach to create a fragment and 
> insert as needed with the DOM is certainly better than DOM creation, 
> serialization, parsing again.
>
>
>
> -- 
>
> Martin Honnen
> http://JavaScript.FAQTs.com/

THANK YOU!!
I told you it was obvious! ;-)
When I issued document.close() the page finished!
And the transformToFragment also worked!

I tried the fragment approach before but lacked knowledge...
//frmBot is the frame name
//display is an <div id="display">
var target = parent.frmBot.document.getElementById("display");
while (target.hasChildNodes())
{ target.removeChild(target.childNodes[0]);
   target.appendChild(xmlNode);
}

If you bother to help me further, can you point me why I failed to get the 
target this way?
Ans also, when the child clean up, performed in the while clause above, is 
needed?

thank you very much!
now I am back to track, with lots of work to do!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.