Search code examples
validationcontinuous-integrationreportingw3c

Processing W3C css validator output with Violations


There are a lot more output formats for linters and validators than there are tools to parse them. I haven't been able to find any tools that can parse the output of the canonical CSS and HTML validators provided by the W3C themselves. The output formats provided by the W3C CSS validator are documented in the User Guide (including one undocumented output format enabled with just --format=xml). Are there any tools (such as a Jenkins plugin) that can process any of the formats output by the W3C CSS Validator into a graph or other human-consumable report format?


Solution

  • I don't know. But I did write an XSLT that converts the output of java -jar css-validator --format=soap12 into the same format as csslint, which Violations can process.

    The validator itself always outputs its options above the XML, so you have to trim that off before you can transform it:

    java -jar css-validator --format=soap12 "$someFile.css" |
        tail -n +1 | # GNU tail, or use some other way of trimming the first line
        xsltproc css-validator-to-csslint.xsl -
    

    I hope someone finds this useful.