Solved

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

Posted on 2008-10-28
7
2,018 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

751 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