Running the W3C CSS Validator locally from the command line
Posted on February 18th, 2009 by Neil Crosby. Filed under Blog Posts.
One of the things I’m currently working on is being able to run automated tests of FrontEnd Web Systems. In order to carry out the first phase of this testing I need local installations of the HTML Validator, CSS Validator and JsLint (when automatically running these tests many times a day it’s not fair to put that load on these free services).
I’m currently working on the CSS portion of the First Phase, so I’ve been looking at getting the W3C CSS Validator running locally on my machine. Since there was a tiny bit more to it than there seemed from the W3C’s setup instructions, I thought I’d better write down how I did it.
Download the Jigsaw web server and unzip it to a location of your choice. We’ll be needing the servlet.jar file from it later (it’s in
Jigsaw 2/classes/servlet.jar)Open a terminal window, and change directory to somewhere you’re happy to put the CSS Validator. The CVS password, when prompted, is “anonymous”.
CVSROOT=:pserver:anonymous@dev.w3.org:/sources/public cvs login CVSROOT=:pserver:anonymous@dev.w3.org:/sources/public cvs checkout \ 2002/css-validator cd 2002/css-validator mkdir lib cp {your servelet.jar location} lib ant jarAssuming nothing goes wrong, you’ve got yourself a self-contained, offline CSS Validator. Awesome.
Test the validator by running the following:
java -jar css-validator.jar --output=soap12 http://www.w3.org/By running the following, you can see the options available to you from the validator:
java -jar css-validator.jarThese options are explained in the CSS Validator User Manual.
And that, as they say, is all there is to it. From this, it shouldn’t be too difficult to set the validator up to run as a website if you want to, but that wasn’t necessary for me right now, so I didn’t do it myself.
If you enjoyed this post, subscribe to The Code Train and read more when I write more.