W3C home > Mailing lists > Public > www-html@w3.org > April 2002

Double hyphens ('--') in comments invalid

From: Greg Faron <gfaron@integretechpub.com>
Date: Tue, 23 Apr 2002 14:46:54 -0600
Message-Id: <5.1.0.14.0.20020423143517.00a8f0b8@parzival.integretechpub.com>
To: www-html@w3.org
Hello,

   I've been directed to the XML spec in which it states that "for 
compatibility, the string '--' (double-hyphen) must not occur within 
comments."  I assume it refers to the compatibility with SGML (of which I 
know very little).

   I find this to be a great hindrance when creating valid XHTML 
(Transitional) pages that use JavaScript.  Consider the commonly used unary 
decrement operator.  The script below (admittedly contrived) is invalid 
because of this seemingly arbitrary compliance.

<script type="text/javascript">
<!--

for (var i = 100; i > 0; i --)  // FAILURE!
   {
   if (!(someField[i].checked))
     document.write('Question ' + i + ' has not been answered\n');
   } // ends for

-->
</script>

   What is the commonly accepted workaround for this?  Should I not use
<!-- ... --> to envelop my script?  Am I suppose to reverse my logic in the 
case above, and use "i = i - 1" or "i -= 1" as necessary elsewhere?  I 
don't believe I'm allowed to use <![CDATA[ ... ]]> outside of XSLT 
transformations (but I may be wrong here).  Please advise...


Greg Faron
Integre Technical Publishing Co.
Received on Tuesday, 23 April 2002 16:47:47 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:51 GMT