W3C home > Mailing lists > Public > www-style@w3.org > November 2012

Re: nth descendent selector

From: Liam R E Quin <liam@w3.org>
Date: Tue, 13 Nov 2012 16:56:36 -0500
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: Dave Smith <da__smith@hotmail.com>, www-style w3 <www-style@w3.org>
Message-ID: <1352843796.30647.13.camel@localhost.localdomain>
On Tue, 2012-11-13 at 11:27 -0800, Tab Atkins Jr. wrote:
> On Fri, Nov 9, 2012 at 2:33 AM, Dave Smith <da__smith@hotmail.com> wrote:
> > For example
> > li:nth(7)
> > would be equivalent to document.getElementsByTagName('li')[6]
> The XQuery language (cousin to Selectors) has this functionality.
(as does XPath)

> Unfortunately, it's difficult to do in Selectors, because all browsers
> (and most JS-based selector engines, too) optimize selectors by
> evaluating them right-to-left, rather than the left-to-right that you
> probably expect.

For what it's worth, XQuery engines do this too - or sometimes evaluate
from the middle, too - for performance reasons.

There were papers on this at various VLDB conferences.

Early on in XQuery develpment there were concerns about performance of
the XPath "full axis feature", but it turned out that the workarounds
users found for missing axis support were massively slower and harder to
optimize than native support; the same is probably true of some of the
CSS selector proposals. It also turned out that the "full axis feature"
could be optimized heavily - e.g., again, there was a paper I think at
VLDB, showing how to turn backwards-looking expressions into
forwards-looking ones, so that you could implement preceding-sibling and
friends as efficiently as following-sibilng even in a streaming


Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml
The barefoot typographer - http://www.holoweb.net/~liam/
Received on Tuesday, 13 November 2012 21:57:32 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:23 UTC