Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created December 14, 2009 16:33
Show Gist options
  • Select an option

  • Save cowboy/256183 to your computer and use it in GitHub Desktop.

Select an option

Save cowboy/256183 to your computer and use it in GitHub Desktop.
IE conditional comment <body> tag in XSLT
<!--
IE conditional comment <body> tag in XSLT
5/28/2010 "Cowboy" Ben Alman
http://benalman.com
See:
http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
-->
<xsl:template name="html_body">
<xsl:variable name="body_class" select="'optional classes'"/>
<xsl:value-of select="concat(
'&lt;!--[if lt IE 7]&gt;&lt;body class=&quot;ie ie6 lte9 lte8 lte7 ',$body_class,'&quot;&gt;&lt;![endif]--&gt;&#xa;',
'&lt;!--[if IE 7]&gt;&lt;body class=&quot;ie ie7 lte9 lte8 lte7 ',$body_class,'&quot;&gt;&lt;![endif]--&gt;&#xa;',
'&lt;!--[if IE 8]&gt;&lt;body class=&quot;ie ie8 lte9 lte8 ',$body_class,'&quot;&gt;&lt;![endif]--&gt;&#xa;',
'&lt;!--[if IE 9]&gt;&lt;body class=&quot;ie ie9 lte9 ',$body_class,'&quot;&gt;&lt;![endif]--&gt;&#xa;',
'&lt;!--[if gt IE 9]&gt;&lt;body class=&quot;ie gt9 ',$body_class,'&quot;&gt;&lt;![endif]--&gt;&#xa;',
'&lt;!--[if !IE]&gt;'
)" disable-output-escaping="yes"/>
<body>
<xsl:attribute name="class">
<xsl:value-of select="$body_class"/>
</xsl:attribute>
<xsl:value-of select="'&lt;![endif]--&gt;'" disable-output-escaping="yes"/>
...body...
</body>
</xsl:template>
@Marak
Copy link

Marak commented May 28, 2010

XSD / XSLT - noooooooooooooooooooooooooooo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment