Re: [CSS3] selectors to use xpath syntax

Manuel Strehl schreef:
> It is true that much will be possible in CSS3, but why invent the 
> wheel 2 times?

This question has been answered already:

"there are things that can be done with Xpath that are deliberately not 
in CSS because they are too expensive to implement." (David Woolley)

And (as mentioned at the link in my previous reply) because XPath 
doesn’t handle incremental rendering well at all, because XPath is not 
designed to be resolved from an element point-of-view (XPath is a 
targeting language, CSS selectors is a matching language), and because 
it is easy to write XPath expressions that take a long time to evaluate.

E.g. the CSS selector ‘a b’ is a very cheap operation, while the XPath 
equivalent ‘a//b’ is a very expensive one. These don’t mix very well, 
e.g. if you imagine the following selector: html div:xpath(../../c//b), 
the fastest way to run this would be that for every element b it has to 
see whether it has an ancestor c, whose parent has a div as 
great-grandchild, which is the descendant of an html element. Do this 
for every element in your document, and see how it’ll perform.

One might think ‘but then what about a subset of XPath’, but that will 
create confusion over what can be used and what can’t (this is already 
the case in XML Schema), and you’ll loose much of the power of XPath 
that would be really useful (again, see Schema).

If you then also consider that XPath can’t do many of the things that 
are a basic part of CSS, such as class selectors for example (especially 
not things like multi-class selectors), and that the two languages have 
entirely different design goals, you can see this with simple things 
like that in CSS ‘a b’ is the most basic expression, while in XPath it’s 
‘a/b’ (‘a > b’) and ‘a//b’ is actually recommended not to be used too 
often, it just doesn’t make sense to try and force them together.

XPath cannot be used in CSS for those reasons.


~Grauw

-- 
Ushiko-san! Kimi wa doushite, Ushiko-san!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Laurens Holst, student, university of Utrecht, the Netherlands.
Website: www.grauw.nl. Backbase employee; www.backbase.com.

Received on Friday, 9 December 2005 21:20:39 UTC