HTML Comments in XSLT not rendered Options
ascendinternet
Posted: Wednesday, June 04, 2008 10:27:18 PM
Rank: Devotee

Joined: 11/16/2007
Posts: 51
I am creating a XSLT file to produce a menu. The menu needs to add "comments" to force IE6/7 to behave. I have entered them into the XSLT but they do not appear in the resulting HTML!?

A section of the code is
Code:

<li class="sub"> 
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
<!--[if IE 7]><!--></a><!--<![endif]-->
    <!--[if lte IE 6]><table><tr><td><![endif]-->
    <ul>
    <xsl:call-template name="drawNodes">   
    <xsl:with-param name="parent" select="."/>   
    </xsl:call-template> 
    </ul>
    <!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li>


All the bits within <!-- and --> are not rendered. Is there a way to make this stuff appear in the HTML?

Gordon Saxby | Ascend Internet Limited | Web Site Development, Hosting & Domain Names
neehouse
Posted: Thursday, June 05, 2008 2:40:31 AM

Rank: Umbracoholic

Joined: 7/20/2006
Posts: 1,066
Location: Charleston, West Virginia, United States
yes, comments are skipped in xsl.

you can use xsl:text to render the tag, or check out xsl:comment. It may render what you want.

Code:

<xsl:text disable-output-escaping="yes">
    &lt;--[if lte IE 6]&gt;</xsl:text>...&lt;![endif]--&gt;
</xsl:text>


• 2007/2008 MVP • 2008/2009 MVP • Core Developer • Certified Professional Level I & II •
dawoe
Posted: Thursday, June 05, 2008 9:57:30 AM

Rank: Aficionado

Joined: 1/19/2008
Posts: 147
Location: Belgium
neehouse wrote:
yes, comments are skipped in xsl.

you can use xsl:text to render the tag, or check out xsl:comment. It may render what you want.

Code:

<xsl:text disable-output-escaping="yes">
    &lt;--[if lte IE 6]&gt;</xsl:text>...&lt;![endif]--&gt;
</xsl:text>


xsl:comment will do the trick

Converting a DotNetNuke site to Umbraco : Follow it here
ascendinternet
Posted: Thursday, June 05, 2008 11:20:26 AM
Rank: Devotee

Joined: 11/16/2007
Posts: 51
Neither xsl:comment or xsl:text work!

I tried this
Code:

<xsl:comment><!--[if IE 7]><!--></xsl:comment>
</a>
<xsl:comment><!--<![endif]--></xsl:comment>


but it produces this
Code:

<!----></a><!----><!---->


i.e. the [if IE 7] bit is missing.

<xsl:text> does not produce anything.

Gordon Saxby | Ascend Internet Limited | Web Site Development, Hosting & Domain Names
jMosbech
Posted: Thursday, June 05, 2008 11:30:27 AM
Rank: Newbie

Joined: 6/5/2008
Posts: 4
Location: Copenhagen
xsl:comment and proper escaping of < and > should do it, but if you cannot make it work, try the following:

Code:
<xsl:text disable-output-escaping="yes"><![CDATA[
<!--[if lte IE 6]><table><tr><td><![endif]-->
]]></xsl:text>
ascendinternet
Posted: Thursday, June 05, 2008 12:34:42 PM
Rank: Devotee

Joined: 11/16/2007
Posts: 51
After a lot of fiddling about, I finally got it working!

Code:

            <li class="sub"> 
            <a href="{umbraco.library:NiceUrl(@id)}">
            <xsl:value-of select="@nodeName"/>
           
            <xsl:text disable-output-escaping="yes"><![CDATA[<!--[if IE 7]><!-->]]></xsl:text>
            </a>
            <xsl:text disable-output-escaping="yes"><![CDATA[<!--<![endif]-->]]></xsl:text>

            <xsl:text disable-output-escaping="yes"><![CDATA[<!--[if lte IE 6]>
            <table><tr><td>
            <![endif]-->]]></xsl:text>

            <ul>
                <xsl:call-template name="drawNodes">   
                <xsl:with-param name="parent" select="."/>   
                </xsl:call-template> 
            </ul>

            <xsl:text disable-output-escaping="yes"><![CDATA[<!--[if lte IE 6]>
            </td></tr></table></a>
            <![endif]-->]]></xsl:text>
           
            </li>


Thanks everyone for your help!

Gordon Saxby | Ascend Internet Limited | Web Site Development, Hosting & Domain Names
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.