xsl-list
[Top] [All Lists]

Re: [xsl] XSL and HTML interaction

2009-05-22 12:03:16
Robert G wrote:
Is there any other way to add to the original html file without using
xsl to create new html and then including that in the original html?
I was looking stuff up online and some sites suggest you can just
"copy and paste" nodes to the original html? Thanks.

It depends on the APIs the browser or its XSLT engine exposes. Mozilla for instance gives you transformToFragment (https://developer.mozilla.org/en/The_XSLT%2f%2fJavaScript_Interface_in_Gecko/JavaScript%2f%2fXSLT_Bindings) and that way you can have the XSLT stylesheet create DOM nodes owned by the target document (e.g. HTML document) which you can then insert using W3C DOM methods like appendChild or insertBefore.
I think Opera and Safari expose the same API by now.

IE uses MSXML for XML and XSLT and that way has two completely separate DOM implementations, the XML DOM of MSXML and the HTML DOM of IE/MSHTML. You can't copy/move/import/adopt nodes between these two DOM implementations so what you do there is have a string result of the transformation (e.g. from transformNode()) and then parse that by setting innerHTML or using insertAdjacentHTML in the HTML DOM.


--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--