W3C home > Mailing lists > Public > www-style@w3.org > November 2007

Validating media queries in Java

From: Henri Sivonen <hsivonen@iki.fi>
Date: Fri, 16 Nov 2007 16:42:56 +0200
Message-Id: <6F238E2F-B58A-465C-920A-1D464AFE03B9@iki.fi>
To: W3C Style List <www-style@w3.org>

I'm trying to validate CSS Media Queries as HTML5 attribute values.  
I'm using Java.

I first thought that media queries would be syntactically very simple-- 
something for which importing the W3C CSS Validator or a parser  
generator as a project dependency would be and overkill. I have since  
learned that most of the complications are hiding inside <value> and  
the language is nowhere near as simple as the pseudo-BNF in the Media  
Queries spec makes it appear. In particular, even traditional CSS  
lengths make the states in the parser balloon and support for calc()  
would make things much, much more complex.

I'm now considering abandoning my hand-rolled code in favor of either  
a customized generated parser or a generic CSS parser that someone has  
already written. I checked out the W3C CSS Validator source today.  
Unfortunately, it seems that it doesn't have an entry point for  
parsing media queries in isolation and the JavaCC grammar it uses is  
tightly coupled with the program internals.

I'd appreciate advice:
Is there some Open Source work that I'm missing but could use? Other  
recommendations on how to proceed?

Henri Sivonen
Received on Friday, 16 November 2007 14:43:20 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:31 UTC