HOW TO IE CONDITIONAL COMMENT IN XSLT 1.0 INSIDE TAG?

Tanuj Kumar

Total Post:134

Points:940
Posted by  Tanuj Kumar
C#  Xslt  Xslt-2.0 
C#
 958  View(s)
Ratings:
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>
  1. Royce Roy

    Post:149

    Points:1043
    Re: How to IE Conditional Comment in XSLT 1.0 inside tag?

    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
        <![endif]
        ]]>
    </xsl:comment>

    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>
        <![endif]]]>
    </xsl:comment>
    
    <xsl:comment><![CDATA[[if gt IE 6]>
        <a href="#">some text</a>
        <![endif]]]>
    </xsl:comment>

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!