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

RE: XPath as CSS-selectors?

From: Asbjørn Ulsberg <asbjorn.ulsberg@nrk.no>
Date: Thu, 19 Jun 2003 13:04:52 +0200
Message-ID: <D186E3C450FED2119AFA00508B08736F06E938BD@MAEXCH05>
To: "'Ian Hickson'" <ian@hixie.ch>
Cc: "'www-style@w3.org'" <www-style@w3.org>

Ian Hickson wrote:

> More to the point, XPath is like CSS selectors (XPath came
> after CSS).

Of course.

> CSS Selectors are currently carefully designed for
> performance. XPath is not.

Well, this is an implementation issue, and not caused by the
design tiself.. Or?

> CSS Selectors also have a terser syntax, and can address
> parts of documents that XPath currently cannot (::selection,
> e.g.).

As you might not have noticed in my examples, is that XPath in
practice can be combined with other selector languages,
including CSS selectors. What you need to combine with XPath
is mainly the pseudo-classes and -elements;

  select('Xpath', '/html/body/p[1]')::selection {
    color: blue;
  }

Ok, this might seem a bit peculiar, but as I didn't express
in my first mail, it's mainly the node-selecting part of CSS
selectors ("node1>node2>node3" or "node1 node2 node3") I'd
like to do with XPath.

> XPath can also do things which don't fit into the CSS syntax
> well, e.g. selecting non-adjacent text ranges.

True. I haven't thought long and hard on this -- it's just a
hunch. :)

> Why not the other way around? Shouldn't XSLT be changed to use
> CSS Selectors rather than using XPath?

Though CSS selectors would be a bit odd to use in XSLT, I
wouldn't mind having it as an alternative to XPath. When XQuery
comes, let's have that as well. The more, the merrier. Right?

>> 1. The language is already well defined and standardized.
> 
> As are CSS selectors.

Well. Not the parts that comes in CSS3..?

>> 2. It is widely used.
> 
> As are CSS selectors.

The same as above.

>> 3. It is isolated as a stand-alone language, outside of
>>    any other standard (which CSS-selectors isn't).
> 
> Yes they are.

Well, OK. I see that you're right. I withdraw that one, then.

>> 4. It is imho more powerful than CSS-selectors.
> 
> It was not designed for use in dynamic environments, which is
> a requirement for the selecting language used in CSS.

As Chris Lilley mentions, XPath is used in XForms, which is a
pretty "dynamic environment". Though XPath wasn't necessarily
designed for use in a dynamic environment, I think it works fine
with XForms. Don't you agree? Why won't it work with CSS?

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

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