Inserting Internet Explorer specific scripts from XSLT

If you are working with generating an html page through xslt, you might be interested in loading some scripts just when the page is browsed from Internet Explorer (IE).

You can use the following XSLT section to include a IE specific script. In this case it will be for IE versions less than 9.

<xsl:text disable-output-escaping="yes">&lt;!--[if lt IE 9]&gt;&lt;script language="javascript" type="text/javascript" src="js/excanvas.min.js"&gt;&lt;/script&gt;&lt;![endif]--&gt;</xsl:text>

Your output will look like this:

<!--[if lt IE 9]><script language="javascript" type="text/javascript" src="js/excanvas.min.js"></script><![endif]-->

Adding CData tags through XSLT

CData tags are usually swallowed up by an XSLT transformation. If they are important to your output document, you can use the following method to include CData tags.

<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>

<!-- text between CData tags here -->

<xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>

The output will look like: