Home > DeveloperSection > Forums > How to IE Conditional Comment in XSLT 1.0 inside tag?
Tanuj Kumar

Total Post:134

Posted on    November-06-2014 1:03 AM

 C# C#  Xslt  Xslt-2.0 

 1 Reply(s)
 781  View(s)
Rate this:

How to display title (not as HTML comment) for IE6 only, if this line of code <a title="" href="#">some text</a> is in xsl file?

The options below don't work:

<a <![CDATA[[if IE 6]>title="hi"<![endif]]]> href="#">some text</a>

<a &lt;![if IE 6]&gt;"title="hi"&lt;![endif]&gt; href="#">some text</a>

Royce Roy
Royce Roy

Total Post:146

Posted on    November-06-2014 3:15 AM

I'm not aware of any conditional IE constructs other than those given in an HTML comment. To insert comments in XSL, you use <xsl:comment>:

<xsl:comment><![CDATA[[if IE 6]>
    Special instructions for IE 6 here

There is a specific reason why the CDATA follows the <xsl:comment on the same line here. IE does not recognize these comments unless the characters <!--[if IE 6]> are contiguous on a single line. The remaining portions, including the endif, can apparently be spread out onto succeeding lines.

However, since you cannot put an HTML comment in the middle of a tag, as you were trying to do. Therefore, you will have to provide alternate versions of the entire <a> tag:

<xsl:comment><![CDATA[[if IE 6]>
    <a title="hi" href="#">some text</a>

<xsl:comment><![CDATA[[if gt IE 6]>
    <a href="#">some text</a>

However, please note this MS link:

Important As of Internet Explorer 10, conditional comments are no longer supported by standards mode.

Modified On Nov-06-2014 03:16:39 AM

Don't want to miss updates? Please click the below button!

Follow MindStick