IE Conditional Comments and XSL

Yesterday's post reminded of the following issue with conditional comments for Internet Explorer when you are using XSL as a templating system as we are at Lime Thinking. If you just enter the following into the XSL file:

<!--[if IE 7]>
    <link rel="stylesheet" href="/v9/styles/ie7.css" type="text/css"/>
<![endif]-->

then it will be treated as an XSL comment and will not appear in the processed document. It instead needs to be inserted in the following way:

<xsl:comment>
    <![CDATA[[if IE 7]>
         <link rel="stylesheet" href="/v9/styles/ie7.css" type="text/css"/>
    <![endif]]]>
</xsl:comment>

This will then appear in the output document as the HTML comment in the first example.