W3C home > Mailing lists > Public > www-validator@w3.org > November 2003

First two bytes of a file

From: David Edwards <dave@revlob.com>
Date: Fri, 21 Nov 2003 13:51:31 +0000
To: www-validator@w3.org
Message-ID: <20031121135131.GA28936@muse.19inch.net>

I've noticed what might be classified as an error in the www validator
(http://validator.w3.org/). I discovered this when trying to validate
a page for XHTML and CSS standard conformance. The page returned valid
XHTML, but the jigsaw CSS validator
(http://jigsaw.w3.org/css-validator/validator-uri.html)
said otherwise. When validating a page for valid CSS, I think the
jigsaw validator checks the first two bytes of the file for the file
type definition (which will be "<?" in the case of valid XML). I
noticed that my perl code which was generating the offending  XHTML
was inserting three newlines instead of two after the "Content-type:"
declaration. The third newline was then being included in the file,
and threw the CSS validator off, but not the XHTML validator.

Perhaps the XHTML validator should provide a warning if it discovers
this situation? I'm not quite sure how serious an issue it is.

I've provided two perl scripts which may help illustrate this better.
You may need to provide a "default.css" file though.

--BEGIN PERL CODE--

#!/usr/bin/perl -w

#please note that the total number of newlines in the following first two lines is three

print qq|Content-type: text/html\n\n
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<title>No CSS Validation</title>
	<link rel="StyleSheet" href="default.css" type="text/css"
		title=default media="screen" />
</head>
<body><p>The Jigsaw CSS validator will refuse to validate the generated
XHTML, due to "bad" XHTML, even though the XHTML validator reports conformance.</p></body>
</html>|;

--END PERL CODE--


--BEGIN PERL CODE--

#!/usr/bin/perl -w

#now we have just two newlines...

print qq|Content-type: text/html

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<title>No CSS Validation</title>
	<link rel="StyleSheet" href="default.css" type="text/css"
		title=default media="screen" />
</head>
<body><p>Both the Jigsaw CSS validator and the XHTML validator report conformance.</p></body>
</html>|;

--END PERL CODE--

Thanks for reading,

Dave Edwards.
Received on Saturday, 22 November 2003 14:05:30 GMT

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