(For those just tuning in, QueryPath 3.x is under active dev right
now, with the current emphasis on refactoring code for full PHP 5.3
support, especially namespacing and PSR-0 compliance.)
Regarding #1, I'd like to hear some performance numbers. Many CSS
selectors could be quickly converted to XPath queries. I don't know
how complex it would be, though, to try to build a complete resolver.
For #2, I have looked at some options for this in the past, because I
too think this is a great idea. The biggest difficulty is that a
DOMDocument cannot be serialized, which means it has to be walked. And
walking the DOM tree didn't seem to be noticeably faster than parsing
a DOM document. That said, I'm a HUGE fan of this idea, and if anyone
were to suggest some potential routes to accomplishing it, I'm all for
it.
Another is to change the way the traversal happens.
Right now, when a selector comes in for 'foo > bar', we search
downward through the document for all <foo> elements, and then for
each foo element, we check to see which have <bar> children. Or, for
an even tougher case, 'foo bar' searches first for all <foo> elements,
and then searches all descendants for <bar> elements.
We could drastically improve QueryPath's search performance by
traversing "bottom up":
For 'foo bar', find all 'bar' elements, and then go up the tree to see
which ones have <foo> ancestors. Because each element has only one
parent, and because the ancestors can be traversed very quickly, this
method is considerably faster.
(To visualize this, draw a tree structure and compare strategies for
starting at the top and finding a path to a specific place at the
bottom, and starting at the bottom and finding a path to the top.)
I started on this feature a long time ago, but just couldn't carve out
a block of time. I'd love to come back to it.
The bottom line, though, is that I am 100% in agreement with Ryan: I
would rather improve QueryPath's performance than add more features.
Matt