Re: XPath and find/findAll methods

On Nov 29, 2011, at 17:09 , Henri Sivonen wrote:
>>    /html/body/div/p[@id = /html/head/link[@rel = 'me']/@src]/strong
> 
> This example depends on unprefixed name expressions matching the
> (X)HTML namespace when tested against an element and no namespace when
> tested against attributes. And that trick only works with (X)HTML
> nodes.
> 
> Selectors have the advantage that they wildcard the namespace by
> default, so it's feasible to define APIs that don't even have
> namespace binding mechanisms.

That's a candidate for fixing or, as Anne put it, "DOM4-ification". If you look at Opera's implementation, you see:

>>> document.selectSingleNode("//p").namespaceURI
"http://www.w3.org/1999/xhtml"

and

>>> document.selectSingleNode("//html:p", function () { return "http://www.w3.org/1999/xhtml"; }).namespaceURI
"http://www.w3.org/1999/xhtml"

I'm not sure that it would break much existing content — would be useful to look further though.

-- 
Robin Berjon - http://berjon.com/ - @robinberjon

Received on Tuesday, 29 November 2011 16:35:17 UTC