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

Confusing error reporting after parse errors

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Sun, 04 Nov 2012 15:48:01 +0200
Message-ID: <50967211.4030503@cs.tut.fi>
To: www-validator-css@w3.org
2012-11-01 11:52, Dragan Laban wrote under Subject: CSS Validator caching:

> Need to add option 'revalidate'. Wrong caching.
> The error in my css is corrected but validator stil reprting it.
> http://laban.rs/scrap/converters/con_sr_lat
> http://laban.rs/_css/_defs.css

After some email discussion with the poster, I think I understand what 
the issue is. It wasn't really about caching but about constructs like this:

h1 {
   margin-top: 0;}
   margin-bottom: 0.4em;}
h2 {margin-top: 0.4em;}

The real error is the spurious semicolon after the second line. It 
closes the rule prematurely.

The CSS Validator reports an error, but it is somewhat confusing, since 
it is reported as relating to the fourth line, and it says:

Parse Error [: 0.4em;} h2]

It seems that on line 3, "margin-bottom" is parsed as a selector, and 
then ":" is an error, but the validator tries to parse the longest 
possible construct in order to report the error well. It stops when it 
reaches the "{", since that's a symbol that may validly follow a selector.

If you remove the string ": 0.4em;} h2" that appears in the error 
message, then the style sheet validates, though its meaning is of course 
different from what was meant:

h1 {
   margin-top : 0;
margin-bottom {
   margin-top : 0.4em;

(This is valid as CSS, since "margin-bottom" is a perfectly valid 
selector, even though HTML has no element named that way.)

I wonder if the CSS Validator could be modified to report, in case of a 
parse error, the line where the unparseable construct *started*, rather 
than its end. I suppose this is unrealistic, but may a description of 
the issue could be added to the validator's FAQ. Perhaps something like 

What does "Parse error ..." mean?

It usually means that in analyzing the style sheet, the validator 
encountered a construct that is not allowed in the context. In such 
situations, the validator skips characters until it reaches a recovery 
point, such as a brace, where it will try to resume normal processing.

In such cases, the error message contains the string skipped, and the 
message is presented as relating to the line where the string ends.

Received on Sunday, 4 November 2012 13:48:30 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:40:49 UTC