How to load XSL in MozillaGecko with Javascript in Mozilla Develop Center we can see the following article: http://developer.mozilla.org/en/docs/The_XSLT/JavaScript_Interface_in_Gecko:Basic_Example
First, you need to understand how to dynamically load xml files. You can use XMLDOM objects, XMLHttpRequest, and responseXML objects. Here I use XMLHttpRequest.
The method for loading xslt with javascript is as follows:
1. Use XMLDOM or XMLHttpRequest to load xml and xslt.
2. Use ttprocessor. importStylesheet to introduce XSLT.
3. Use the effectprocessor. transformToFragment method to convert it to the DOM Fragment. Then, appendChild or insertBefore is used to append or insert the fragment element of the DOM.
Sample Code
Var ownerDocument = document. implementation. createDocument ("", "test", null );
Var newFragment = processor. transformToFragment (domToBeTransformed, ownerDocument );
Of course, you can also use transformToDocument
Var newDocument = processor. transformToDocument (domToBeTransformed );
It should be noted that the converted node is an Element or a segment, so obj. innerHTML = new Document can be used only after the serialization below
4. Serialization.
(New XMLSerializer (). serializeToString (newDocument)
5. In IE, the XMLDOM method and xmldoc. transformNode (document) method can be used for the transformation.
First, we need to create an XML file and An XSLT file to facilitate subsequent explanations.
Foo. xml
Javascript load xslt in ie and mozilla
Never-online
Http://www.never-online.net
Content is here
Foo. xsl
Author: -
Web:
Foo.html
Convert xsl using javascript-http://www.never-online.net