W3C home > Mailing lists > Public > www-style@w3.org > December 2005

Re: [CSS3] selectors to use xpath syntax

From: Christoph Wieser <wieser@cip.ifi.lmu.de>
Date: Mon, 12 Dec 2005 09:29:48 +0100
Message-ID: <439D34FC.1040602@cip.ifi.lmu.de>
To: www-style@w3.org

Laurens Holst wrote:
> E.g. the CSS selector 'a b' is a very cheap operation, while the XPath
> equivalent 'a//b' is a very expensive one.

Sorry for splitting hairs but the CSS selector 'a b' translated to XPath
is '//a//b'. Each CSS 2.1 selector has this implicit descendant axis
('//') in front of the expression.

Laurens Holst wrote:
> because XPath is not designed to be resolved from an element
> point-of-view

Hmm, maybe that is not the original intent of XPath but it is possible.
You can translate 'a b'[CSS 2.1] to 'descendant::a/descendant::b'[XPath]
('//' is short for '/descendant'). From an element point-of-view this
expression is equivalent to 'self::b/parent::a'[XPath]. Checking this
expression for each element simulates the first '//' of '//a//b'[XPath].
This kind of query rewriting is possible for all XPath expressions (cf.
"XPath: Looking Forward", Dan Olteanu, Holger Meuss, Tim Furche,
Francois Bry;
http://www.pms.ifi.lmu.de/publikationen/PMS-FB/PMS-FB-2002-4.pdf)

Laurens Holst wrote:
> ...it is easy to write XPath expressions that take a long time to
> evaluate.

Right but that's life. From my point of view decidability of selections
is all we need. It should be the programmers decision whether evaluation
is rather cheap or not.

Regards,
Christoph

Received on Monday, 12 December 2005 08:29:42 GMT

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