W3C home > Mailing lists > Public > www-validator@w3.org > February 2001

Re: Validator should not be interpreting <SCRIPT> tag contents atall

From: Bryce Nesbitt <bryce@obviously.com>
Date: Thu, 8 Feb 2001 09:05:20 -0500 (EST)
Message-ID: <3A82A574.6267C7FD@obviously.com>
To: Nick Kew <nick@webthing.com>, www-validator@w3.org
Cc: gerald@w3.org, Terje Bless <link@tss.no>
Nick Kew wrote:
> 
> On Tue, 6 Feb 2001, Bryce Nesbitt wrote:
> 
> > I've read the FAQ.  I understand the problem.  But still, why
> > does this validator interpret the contents of a <SCRIPT></SCRIPT> container?
> 
> Because otherwise it wouldn't be a validator at all.  It would therefore
> also be letting down SGML-aware browsers, including very probably Mozilla.
> 
> > The interpreter can't know what type of script is inside
> > the tag, and can't correctly interpret it.
> 
> Yes it can - at the SGML level.  And hence also at the HTML level.
> 
> > I suggest that the validator would be much more useful if it ignored everything inside <SCRIPT></SCRIPT>.  Cluttering the JavaScript code with \, as in:
> >       document.write("<\/P>");
> > To hide it from the validator is not a realistic solution.
> 
> It's a nasty hack, and it arises from the rather ill-considered way
> scripting is embedded into markup.  But in general you should be
> avoiding the problem by putting anything using document.write
> (or more-or-less any non-trivial function) away from the HTML
> in a <script src="...">.

You're not taking to a JavaScript fan here.  JavaScript is a nasty messy hack prone to
flaky implementations and vendor compatibility problems.  I agree that scripting
(and frames :-) are both terrible legacies.

But your suggestion smacks of one made by a person that has never had to use
JavaScript in a web page.  It's impractical.  Real world one needs to embed
scripts, and those scripts need to embed HTML.

Think of it this way.  Right now the validator "cries wolf", and therefore won't
be used to validate real world JavaScript pages.  What's better: intellectual purity or
getting more people to validate more of their pages?

				----------------

And there is a problem just as serious as getting the validator to stop complaining
about non-problems.  Javascript is often used to BUILD html.  What's relevant is not
the syntax rules of the bare document, but the syntax rules of the document after
interpretation.  For example:

	<SELECT>
	<SCRIPT>
	for( i=0; i<foo; i++) {
		if( foo = fum ) {
			document.write("<OPTION SELECTED"> + foo[i] );
		}
		else {
			document.write("<OPTION>" + foo[i] + "</" + "OPTON>");
		}
	}
	document.write("</SELECT>");
	</SCRIPT>

There is no way to validate if the resulting HTML is correct until AFTER the JavaScript
has run.  This requires a validator that actually interprets javascript.  Or, more likely,
a browser that will save the RESULT of the interpreted page for later validation.  Does this exist?

			-Bryce
Received on Sunday, 11 February 2001 23:00:52 GMT

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