Re: W3 Validator XHTML parse error with CGI.pm generated $query->start_html(-script)

At 2003-06-13T13:44-0400, Brock Murch wrote:-

> Basically the XML validator chokes on comments inside the <script> tag with
> xhtml. If there is a open <!-- to hide the script... (placed there via the
> CGI.pm module) and later a decrement is used (ie var this-- ) the parser
> calls it a  "invalid comment declaration" I have saved a copy of the script
> output as a static page here:

> To make the page pass the parse test I only need to do remove the <!--comments
> tags-->:

The validator is correct - you are not allowed to put "--" inside an XML
comment. (Even in (SGML) HTML it would be wrong in this case.) In XHTML
the content of the script element is #PCDATA, not CDATA (since XML doesn't
have the latter), so all markup is treated normally. In particular, you do
indeed want a CDATA section so that you don't need to escape markup
characters all over the place; but you do not want to put the script
inside <!-- -->, because in XHTML's script element that really is a
comment. You may wish to consider using <script src="..." /> instead.


Tim Bagot

Received on Friday, 13 June 2003 15:41:49 UTC