Subject: [xsl] generating IE conditional comments, in IE From: "Eric J. Bowman" <eric@xxxxxxxxxxxxxxxx> Date: Fri, 2 Jul 2010 23:55:07 -0600 |
I want my IE-resident XSLT transformation to add IE "conditional comments" in the <head> output. Using system-property('xsl:vendor') tells me when the browser is IE, but it doesn't distinguish versions -- conditional comments do this, so I'd like to use them. I can make this work, by including the conditional-comment code in my source files and copying it to the output. This is undesirable, as I'm trying to save those bytes by caching them in my XSLT, and if at all possible I'd like to avoid conditional comments in my output *unless* the browser is IE. First, I tried wrapping the code in an xsl:text element, but IE won't write xsl:text content to <head>. Next, I tried using xsl:comment and trimming the leading <!-- and trailing --> from the block of conditional comment code... this seems straightforward, but fails even when '<' is escaped. So I stuck with xsl:comment and tried wrapping the code in CDATA. This didn't work either -- since conditional-comment syntax starts with '[' and ends with ']' when the leading <!-- and trailing --> are stripped, <!-- and --> must be replaced with spaces. Unfortunately, IE's conditional comments require a specific syntax with no spaces, so '<!-- [...' and '...] -->' won't work. This syntax is also intolerant of '- -' instead of '--', which is a problem as well, which I'll get to. I tricked IE by making the first condition [if IE] and using CDATA with xsl:comment. For some reason, this first conditional comment renders out as only the contained <link/> element. The rest of the conditional comments render out almost exactly as expected -- except the CDATA- wrapped '<!--' and '-->' strings are changed to '<!- -' and '- ->', so the entire conditional-comment code block is ignored as one big, normal comment. Can anyone actually make this work, or am I on a wild goose chase? -Eric
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: debugging document() call, Lars Huttar | Thread | Re: [xsl] generating IE conditional, Eric J. Bowman |
[xsl] Re: debugging document() call, Lars Huttar | Date | Re: [xsl] generating IE conditional, Eric J. Bowman |
Month |