XPath as CSS-selectors?

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 UTC