W3C home > Mailing lists > Public > www-validator-css@w3.org > August 2005

XML-based CSS Validation

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Tue, 30 Aug 2005 03:44:51 +0200
To: www-validator-css@w3.org
Message-ID: <a5a7h1dqta57bone7tv7ie1q1vej5mmj46@hive.bjoern.hoehrmann.de>

Hi,

  It seems some people would like to investigate whether and how to
perform CSS Validation through XML validation tools such as RELAX NG
and Schematron, so I've made some ad-hoc tools for that. The code is
based on libcroco [1] the GNOME CSS toolkit used in Inkscape, CSSEd,
Librsvg, Screem, and other tools. The rather incomplete and buggy C
code is a SAC [2] handler that builds a DOM tree (based on libxml2)
that represents libcroco data structures; a style sheet like x{y:z}
would yield in something like

  <stylesheet xmlns="...">
    <ruleset>
      <selectors>
        <selector line="1" column="1">
          ...
        </selector>
      </selectors>
      <property name="y" important="false" line="1" column="3">
        <terms>
          <term line="1" column="5" ... type="4">
            <ident>z</ident>
          </term>
        </terms>
      </property>
    </ruleset>
  </stylesheet>

It's basically limited to properties and property values at the
moment, and some property values like url(...) and rgb(...) are
not really handled by the code... the sample RELAX NG schema has
some basic data types; a property like margin:<length>{1,4} would
be represented by sth like

  properties |= 
    element property {
      property.common-attrs,
      attribute name { "margin" },
      element terms {
        length.type,length.type?,length.type?,length.type?
      }
    }

I've also included http://www.w3.org/StyleSheets/TR/W3C-WD.css in its
XML representation so the output can be tested without libcroco and
its dependencies installed. As obvious from that dump, the code does
not currently handle @-rules either, and selectors improperly and has
other glitches.

The main issues with this approach are limitations of libcroco (see
the libcroco-list gnome.org mailing list and the bug tracker), how
to map the results of some RELAX NG or Schematron validator back to
meaningful messages for a CSS Validator, and performance issues. If
these can be solved, this might indeed be a good way to replace the
4MB of Java source code of the current validator...

http://lists.w3.org/Archives/Public/www-archive/2005Aug/0025 has
the code. As noted above, this is just a quick hack for discussion
purposes, please follow up on www-validator-css if you work on
something like this or have comments on my approach. As noted on
<http://esw.w3.org/topic/QaDev>, the #validator channel on the
freenode network is always a good way to get in touch with the QA
Dev participants.

[1] http://www.freespiders.org/projects/libcroco/
[2] http://www.w3.org/TR/SAC/

regards,
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
Received on Tuesday, 30 August 2005 01:44:33 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 27 June 2012 00:14:16 GMT