xsl-list
[Top] [All Lists]

RE: Netscape7.1 bug or bad code?

2003-07-02 07:03:05
From: David Carlisle [mailto:davidc(_at_)nag(_dot_)co(_dot_)uk]
Sent: Wednesday, July 02, 2003 3:52 AM
Subject: Re: [xsl] Netscape7.1 bug or bad code?



the JavaScript isn't ignored in  Netscape Version 7.02.

I don't know but maybe market forces of keeping users happy 
outweighed the
logically correct behaviour of treating a comment as a comment...

This is OT, but the original reason for wrapping comment tags around
JavaScript (the code, not the script tags) was so that older browsers that
didn't understand <script/> wouldn't output the code as literal text.  Now
that every browser released over the past six or seven years is at least
script-aware, the need for comment tags has been eliminated.  Some
old-timers insist on using them, however.

BTW, this will cause problems in output:

<script>
  <xsl:comment>
    alert("This is a script");
  </xsl:comment>
</script>

This will be output as:

<script>
  <!--
    alert("This is a script");
  -->
</script>

which will break most JS interpreters because they will parse the close
comment tag as a decrement operator, then get confused by the right angle
bracket.  If you do this in XSLT, you have to add a JS comment delimiter
before closing the comment:

// </xsl:comment>

cheers,
b.

| brian martinez                           
brian(_dot_)martinez(_at_)cendant(_dot_)com |
| lead gui programmer                                    303.357.3548 |
| cheap tickets, part of trip network                fax 303.357.3380 |
| 6560 greenwood plaza blvd., suite 400           englewood, co 80111 |
| cendant travel distribution services   http://www.cheaptickets.com/ |

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>