internet-explorerxsltcross-browserconditional-commentssymphony-cms

XML/XSLT conditional comment IE stylesheet


I'm having an issue that I just can't seem to figure out. I built a website not too long ago in HTML and have recently integrated Symphony CMS and have had to change everything to XML.

Originally in my head, I had a internet explorer specific stylesheet, the head looked something like this:

<head>
       <link rel="stylesheet" href="../css/master.css" type="text/css" media="screen"></link>
       <!--[if IE]>
             <link rel="stylesheet" type="text/css" href="../css/ie.css"></link>
             <script src="../js/html5shiv.js"></script>
       <![endif]-->
</head>

Since switching, this conditional comment does no longer work, I've changed it to this but unfortunately, my master.css is getting ignored for Chrome/Firefox etc... It is just loading the ie.css stylesheet for all browsers.

<head>
    <link rel="stylesheet" href="../css/master.css" type="text/css" media="screen"></link>                
    <xsl:comment>[if IE]<![CDATA[><!]]></xsl:comment>
          <link rel="stylesheet" type="text/css" href="../css/ie.css"></link>
          <script src="../js/html5shiv.js"></script>
    <xsl:comment><![CDATA[<!]]>[endif]</xsl:comment>    
</head>

Sorry I'm fairly new at this and I'm just not sure what I'm doing wrong, I'm guessing I might need some sort of xsl:if comment but just not sure how to go about it really. I just need something that will make chrome/firefox/opera/safari ignore the ie.css stylesheet.

Any help would be greatly appreciated! Thanks


Solution

  • Just use one xsl:comment and wrap all of the contents in <![CDATA[]]>...

        <head>
            <link rel="stylesheet" href="../css/master.css" type="text/css" media="screen"></link>
            <xsl:comment><![CDATA[[if IE 6]>
             <link rel="stylesheet" type="text/css" href="../css/ie.css"></link>
             <script src="../js/html5shiv.js"></script>
       <![endif]]]></xsl:comment>
        </head>