Solved

XSL: How to output <!--[if lt IE 7.]>

Posted on 2008-10-28
7
2,011 Views
Last Modified: 2013-11-18
How can I output this code:
                  <!--[if lt IE 7.]>
                  <script defer type="text/javascript" src="..."></script>
                  <![endif]-->

I have tried wrapping it in xsl:text, but the <!-- is preventing xsl from outputting it to page because it thinks its a comment.
0
Comment
Question by:qwertq
  • 4
  • 2
7 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 22821888
<xsl:text disable-output-escaping="yes><!--[if lt IE 7.]></xsl:text>
0
 
LVL 18

Accepted Solution

by:
zc2 earned 125 total points
ID: 22821897
Would as shown below be acceptable?
<xsl:comment><![CDATA[[if lt IE 7.]>
<script defer type="text/javascript" src="..."></script>
<![endif]]]></xsl:comment>

Open in new window

0
 
LVL 60

Assisted Solution

by:Geert Bormans
Geert Bormans earned 125 total points
ID: 22821918
I should have pasted in the code snippet pane
<xsl:text disable-output-escaping="yes">&lt;!--[if lt IE 7.]></xsl:text>

Open in new window

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:qwertq
ID: 22821993
           <xsl:text disable-output-escaping="yes><!--[if lt IE 7.]></xsl:text>
                  <script defer type="text/javascript" src="whatever.js"></script>
            <xsl:text disable-output-escaping="yes><![endif]--></xsl:text>

Doesn't work.
Fatal Error 38: Unescaped '<' not allowed in attributes values
Fatal Error 65: attributes construct error

0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 22822034
yes, I already corrected  that in my follow-up. EE screwed up the &amp;lt; and made it a <
putting the solution in the code snippet pane solved that

By the way
you now have two answers, and so you have the two options you would have for this task.

What zc2 proposes is more true to the nature of XSLT... keep it wellformed.
It has the disadvantage that you need to know what comes inside the comment almost beforehand

Mine is a dirty trick (you should avoid using disable-output-escaping as much as possible)
But it leaves you the possibility to dynamically fill in the bit between the comment opening and the comment closing
0
 

Author Comment

by:qwertq
ID: 22822084
I had not seen the follow up response Gertone when I posted my message.

Both solutions work. I am going to split points because they both work for my problem. Not sure which one I will settle on.

Thanks both.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 22822108
welcome
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question