W3C home > Mailing lists > Public > www-validator@w3.org > October 2005

Re: BUG - Reading Java variable as an invalid comment declartion

From: David Dorward <david@dorward.me.uk>
Date: Tue, 4 Oct 2005 17:24:47 +0100
To: David Hirst <cepeleon@yahoo.com>
Cc: www-validator@w3.org
Message-ID: <20051004162447.GD29900@us-lot.org>

On Mon, Oct 03, 2005 at 03:05:46PM -0700, David Hirst wrote:
> Hi I am trying to validate a document at,
> www.cos-one.com/nthread.htm
 
> However I am getting a single error incorrectly about
> an invalid comment declaration.

> The validator does not appear to realise that the java
> variable is just a variable and not a closing tag.

Short answer: It is a comment. It is not a variable. The validator is
right.

Long answer:

First: Its JavaScript, not Java. Java and JavaScript have about as
much in common as Cars and Carpets.

In XHTML <script> blocks contain PCDATA, not CDATA (XML DTDs don't
have the ability to mark text as CDATA), so markup et al is treated as
such.

The result is that you absolutely MUST NOT wrap your scripts with HTML
comments in XHTML documents. You might not notice why if you serve
your XHTML as text/html (which is one reason many people consider
XHTML as text/html to be harmful - http://www.hixie.ch/advocacy/xhtml
). A browser parsing your XHTML as XML will treat the comment as such
and act as if the content of the script block was not there.

http://www.w3.org/TR/xhtml1/#h-4.8


-- 
David Dorward                                      http://dorward.me.uk
Received on Tuesday, 4 October 2005 16:25:04 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:20 GMT