Re: Double hyphens ('--') in comments invalid

I'm not sure, but would this work????

] <?xml version="1.0">
]   .
]   .
]   .
] <script>
] <!-- <![ CDATA [
]   .
]   .
]   .
] /* some code with double dashes (--'s) */
]   .
]   .
]   .
] // ]]> -->
]   .
]   .
]   .

---
Jimmy Cerra

---
P.S.  I think I read somewhere that "--" separates comments in SGML, so the
following is three comments:

<!-- comment 1 -- comment 2 -- comment 3 -->

However, a lot of old SGML parsers (read: old web browsers) interpret the above
as a single comment.  That's why XML forbids '--' inside of a comment, I think.
(However, why should we suffer because of some deviant implementations?)



---
Original Message:

Message-Id: <5.1.0.14.0.20020423143517.00a8f0b8@parzival.integretechpub.com>
Date: Tue, 23 Apr 2002 14:46:54 -0600
To: www-html@w3.org
From: Greg Faron <gfaron@integretechpub.com>
Subject: Double hyphens ('--') in comments invalid

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 Sunday, 28 April 2002 00:13:14 UTC