- From: Rob Larsen <rob@drunkenfist.com>
- Date: Tue, 23 Apr 2002 16:54:52 -0400
- To: <www-html@w3.org>
---- Original Message ----- From: "Greg Faron" gfaron@integretechpub.com > 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... from: http://www.w3.org/TR/xhtml1/#guidelines C.4 Embedded Style Sheets and Scripts Use external style sheets if your style sheet uses < or & or ]]> or --. Use external scripts if your script uses < or & or ]]> or --. Note that XML parsers are permitted to silently remove the contents of comments. Therefore, the historical practice of "hiding" scripts and style sheets within comments to make the documents backward compatible is likely to not work as expected in XML-based implementations. Rob Larsen http://drunkenfist.com ==================>
Received on Tuesday, 23 April 2002 16:54:57 UTC