Comments: XPath and default namespaces

Breaking the spec is not an option.

Read the xpath spec, it clearly states that the default namespace is the null namespace.

This has nothing to do with the DOM non-spec, too.

(From Alex: Care to point me to the parts of these documents that matter? And this is all about the DOM non-spec; I'm not talking about changing XPath, but our implementation of DOM XPath. Specifically, nsXPathNSResolver.)

Posted by Axel Hecht at September 1, 2005 1:00 AM

I don't really know enough about XPath to understand what you're talking about precisely (althought i'm learning) but I'd suggest you file the bug and see what the people in charge of the XPath section have to say. I've done this numerous times just in case and only once has my bug been invalid.

Just my 0.25

(From Alex: Oh, I've filed lots of bugs in areas where I was venturing into new territory, and thought I knew what I was talking about. Blogs don't crowd the database...)

Posted by Anko at September 1, 2005 1:44 AM

XPath 1.0 has a null namespace by default. XPath 2.0 allows you to specify a different namespace I believe (or at least XSLT 2.0 lets you).

It is most convenient to just be able to change the default namespace. This is e.g. possible in PHP 5’s XPath functions. But as a workaround, you can also just address the elements by a prefix, e.g.:

//xhtml:h1

It is annoying to be forced to prefix all your XPath element selections, but it is usually the easiest solution if changing the default namespace that XPath uses isn’t possible...


~Grauw

Posted by Laurens Holst at September 1, 2005 12:59 PM