I have some JavaScript that needs to apply an xslt to the result of an ajax request. The xslt is defined in a separate file "transform.xslt" - whats the best way of including the xslt in my page?
Is it possible to use some sort of <link...
element, or will I need to make a separate http request myself for the xslt?
I think you need to use XMLHttpRequest to load the stylesheet from the server, then you have the responseXML and you can use that with the XSLT transformation APIs the browsers expose to Javascript (e.g. importStylesheet with Mozilla and transformNode with IE).
Unless you target IE only where you could use an XML data island with e.g.
<xml id="sheet1" src="sheet.xslt></xml>
in the head section of your HTML document. Then your script could use e.g. someResponseXML.transformNode(sheet1.XMLDocument)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With