Re: xsl:comment problem
Jonas Sicking <[email protected]> Fri, 09 Mar 2007 09:50:52 -0800
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Message-ID | <[email protected]> |
Thomas Comiotto wrote:
> Hi all,
>
> Seems like document fragments enclosed by xsl:comment directives are not
> being output correctly (as commented output fragments) but instead as CDATA
>
> e.g.
>
> <style type="text/css">
> <xsl:comment>
> @import url("<xsl:value-of select="$aVariable"/>/foo/bar.css");
> </xsl:comment>
> </style>
First of all, why are you doing this? The
<style>
<!--
...
-->
</style>
construct was invented to make browsers that didn't support stylesheets
not display the stylesheet as text. However to my knowledge there are no
browsers that support XSLT but does not support stylesheets.
Second, comments in the DOM are always ignored. Even inside stylesheets
and scripts. The reason that the above construct works in HTML is that
the contents of the <style> tag is not actually markup, but rather
always treated as text. If you look at the DOM you'll see that there is
not a comment, but rather a textnode, inside the style element.
If you try the above in XHTML you'll find that the comment is ignored.
Same thing if you insert a comment in a HTML document using the DOM.
/ Jonas