Re: [PHP-XML-DEV] DomXPath and default XML namespaces

[email protected] (Adam Maccabee Trachtenberg) Mon, 13 Dec 2004 23:34:11 -0500 (EST)
Newsgroups php.general,php.xml.dev
Message-ID <[email protected]>
On Mon, 13 Dec 2004, Dan Phiffer wrote:

> I guess what I would expect to work is to allow for blank values as the
> first argument to registerNamespace, representing the default namespace,
> but that causes the queries to always return no matches. Is there
> something I'm missing with this?

This is an XPath FAQ. Without a ns prefix, XPath doesn't choose
elements living in the default ns, but ones living in no namespace.

Otherwise, you have problems with:

<root>
  <foo/>
  <foo xmlns="bar"/>
</root>

What would /root/foo be, the first, the second, both? And if this
example is resolvable, what happens to:

<root>
  <foo>
    <qxx/>
  </foo>
  <foo xmlns="bar">
   <qxx/>
  </foo>
</root>

And /root/foo/qxx? Do you select qxx in the default ns? Or not?

-adam

-- 
[email protected] | http://www.trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!