|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Conditional comments in a xsl-stylesheet
I'm creating a html-document with the aid of an xsl-stylesheet. To add dynamical some css-documents I need to add a conditional comment in a html-document, but in the xsl-stylesheet it's considered as ordinary commentary.
1) The file common.xsl contains this sentence: Code:
<xsl:template match="/">
<html><head>
<!--[if IE]>
<style type="text/css"> @import url(ie.css); </style>
<![endif]-->
</head></html>
</xsl:template>
Of course, because it's considered as commentary (<!-- -->) it doesn't make it to the html-document. 2) This doesn't work either, it's still considered as commentary (also within a xsl:text statement): Code:
<xsl:text disable-output-escaping="yes"> <!--[if IE]> <style type="text/css"> @import url(ie.css); </style> <![endif]--> </xsl:text> 3) This doesn't work, because now it's considered as text in the html-file, because &< keeps like that and isn't translated back into the <-sign. And the statement doesn't work, all browsers load the css-file. Code:
&<!--[if IE]&> <style type="text/css"> @import url(ie.css); </style> &<![endif]--&> You can check everything out with this xml-file that uses this stylesheet. 4) At the moment the next is implemented: Code:
<![CDATA[<]]>!--[if IE]> <style type="text/css"> @import url(ie.css); </style> <![CDATA[<]]>![endif]--> That is of course almost the same as point 3) of the post above. And indeed Mozilla doesn't see the commentary as such, but as text and uses the ie.css. 5) To be complete I have to admit that I tried to use a character map: Code:
<xsl:output use-character-maps="charmap"/> <xsl:character-map name="charmap"> <xsl:output-character character="<" string="&<"/> </xsl:character-map> But because the use of the <-sign overhere is just so illegal as elsewhere in the document, it didn't work out (of course). If you can help me, I'll appreciate that very much. Thank you in advance. |
|
#2
|
|||
|
|||
|
I've never worked with it.. but have you tried xsl:comment ?
This generates a comment structure in the resulting tree, check here: http://www.w3schools.com/xsl/el_comment.asp |
|
#3
|
|||
|
|||
|
Quote:
Hi kid23, I just found the same function. It works indeed in this form: Code:
<xsl:comment> <![CDATA[[if IE]> <style type="text/css"> @import url(ie.css); </style> <![endif]]]> </xsl:comment> Thanks a lot! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Conditional comments in a xsl-stylesheet |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|