Include the xslt stylesheet in the html page.

I have JavaScript that should apply xslt to the result of an ajax request. Xslt is defined in a separate "transform.xslt" file - what is the way to include xslt in my page?

Is it possible to use some element <link..., or do I need to make a separate HTTP request for xslt?

+5
source share
1 answer

I think you need to use XMLHttpRequest to load the stylesheet from the server, then you have responseXML, and you can use this with the XSLT transform APIs that browsers open for Javascript (like importStylesheet with Mozilla and transformNode with IE).

IE , XML, ,

<xml id="sheet1" src="sheet.xslt></xml>

HTML. script , . someResponseXML.transformNode(sheet1.XMLDocument).

+2

All Articles