Re: [CSS3] selectors to use xpath syntax

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 UTC