xsl-list
[Top] [All Lists]

[xsl] generating IE conditional comments, in IE

2010-07-03 00:55:43
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>