W3C home > Mailing lists > Public > www-style@w3.org > June 2003

XPath as CSS-selectors?

From: Asbjørn Ulsberg <asbjorn.ulsberg@nrk.no>
Date: Wed, 18 Jun 2003 14:05:43 +0200
Message-ID: <D186E3C450FED2119AFA00508B08736F06E938B4@MAEXCH05>
To: "'www-style@w3.org'" <www-style@w3.org>

I've been reading the CSS3 specification the last days, and
particularly about the new additions to the CSS-selectors.
What I notice, clearer than with CSS1 and 2, is that the CSS-
selectors just is a way of selecting nodes, exactly like
XPath.

In the former versions of CSS I can understand the need of
creating a syntax for selecting nodes, as there weren't many
alternatives in those days. Now, however, there are alternatives.
We have XPath.

I can't really see why XPath can't be incorporated into CSS
as an alternative, or instead of, CSS-selectors. Why do we need
different syntaxes for doing the same thing?

A way of doing this, could be:

  xpath(/html/body/p) {
    color: blue;
  }

Or a more generic one:

  select('xpath', '/html/body/p') {
    color: blue;
  }

"select()" returns a set of nodes, and can be viewed as any other
CSS selector, like:

  html>body>p {
    color: blue;
  }

Many would say that "XPath si too heavy for CSS" and such, but
why settle for the topping when you can have the whole cake?
There are many arguments for incorporating XPath in CSS;

  1. The language is already well defined and standardized.

  2. It is widely used.

  3. It is isolated as a stand-alone language, outside of any
     other standard (which CSS-selectors isn't). XPath can,
     without any major problems, be used to select nodes in
     an Enamel[1] document.

     This isolation makes the language more focused on it's
     task, which is to select nodes.

  4. It is imho more powerful than CSS-selectors.

____
[1] <URL: http://groups.google.com/groups?selm=3207626455633924%40naggum.net

-- 
Asbjørn Ulsberg           -=|=-          X-No-Archive: No
"He's a loathsome offensive brute, yet I can't look away"
Received on Wednesday, 18 June 2003 08:05:53 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:22 GMT