W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2011

Re: XPath and find/findAll methods

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 22 Nov 2011 11:52:06 -0800
Message-ID: <CAAWBYDBzXShWTOoqWUiNnZm=-BED_f_KgMQLFD9Ykzxi=sV_KA@mail.gmail.com>
To: Robin Berjon <robin@berjon.com>
Cc: Boris Zbarsky <bzbarsky@mit.edu>, public-webapps@w3.org
On Tue, Nov 22, 2011 at 11:38 AM, Robin Berjon <robin@berjon.com> wrote:
> On Nov 22, 2011, at 18:31 , Boris Zbarsky wrote:
>> On 11/22/11 12:29 PM, Robin Berjon wrote:
>>>>> d - "//div[parent::*//a]";
>>>>
>>>> (d) can be done with the new subject indicator in the Selectors 4
>>>> draft:   a!>  div  (syntax pending, but that's the general idea)
>>>
>>> I think that the example you show selects the<a>  parent of a<div>, not<div>s that have parents containing an<a>.
>>
>> Yes, that's what Tab's selector selects too.  The '!' after the 'a' is important there.
>
> Wait, I thought I'd grasped the gist of S4 but now you're confusing me :) My reading of Tab's selector is that it
> matches the <a> in <a><div/></a>. What Martin's XPath matches is the <div> in <section><div/><p><a/></p></section> (amongst many other variants). It's "all div's whose parents have an a descendent".

Pretty sure that Boris misunderstood your comment.  I did too, at
first, since I wasn't sure which example you were referring to.  ^_^

You are correct on both counts.  "a! > div" matches <a> elements with
a <div> child.  To match the XPath selector, you need something more
like "*:matches(:scope a) > div", which isn't yet a valid selector,
but is roughly in line with how we want to extend :matches() in the
future.

~TJ
Received on Tuesday, 22 November 2011 19:52:56 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:49 GMT