XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 14th, 2004, 07:51 AM
Saviourmachine Saviourmachine is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 5 Saviourmachine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old August 15th, 2004, 03:58 AM
kid23 kid23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 62 kid23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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

Reply With Quote
  #3  
Old August 16th, 2004, 04:24 AM
Saviourmachine Saviourmachine is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 5 Saviourmachine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by kid23
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

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!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Conditional comments in a xsl-stylesheet


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT