Re: XPath & CSS, again

* Laurens Holst wrote:
>Werner Donné wrote:
>> I would welcome XPath in CSS, but then the XPath specification
>> should introduce the notion of specificity, otherwise the cascading
>> mechanism can't work. Look at how XSLT works around that problem
>> to see how valuable cascading is.

In XSLT you have a different problem as templates cannot easily be
merged. CSS declarations on the other hand can easily be merged.

>The problem with XPath in selectors is that you cannot determine their 
>outcome in O(1) or a reasonable O(n) case. With the amount of elements 
>documents can have, this could very quickly result in unacceptable 
>browser rendering times.

That depends... Again, the case is rather made that dynamically re-
evaluating them might have negative impact on resources and certain
expressions don't play well with progressive rendering (and further
that this is more important for constrained devices).

>Imagine the case where you have just one style rule which has an 
>//div[1]/following-sibling::*//input selector. When for every element in 
>the document tree that rule is evaluated, perhaps you can see why that 
>would be undesireable. Obviously as more style rules like this are 
>added, the case becomes worse.

The first thing to note would be that matching the XPath expression
is no different from matching the |input selector for all non-input
elements. And the CSS selector '|div:first-of-type ~ * |input' you
might use instead (they are of course not identical) has similar
"poor" performance.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

Received on Sunday, 10 April 2005 15:03:32 UTC