Although your suggestion was so tempting that I've almost committed it
to the CVS, I finally realized that the behavior you suggest is not
correct w.r.t DOM data model where belonging to a NS doesn't
necessarily mean a NS declaration to be present on the node.
After createElementNS('','foo'), one indeed obtains an element which
doesn't belong to any namespace, not even to the default one. The fact
that xmlns='' is not present on that node has nothing to do with it,
at least DOM-wise. It even makes no difference if one attaches such a
node to an element which has some default namespace. (But yes, after
serialization and parsing, one would obtain a different infoset).
After calling createElementNS('','foo'), you should use
$element->setNamespace('','') or $element->setNamespace('','',1) to
enforce xmnls='' on a node.
I'm also fixing lookupNamespaceURI(prefix), so that for empty/undef
prefix it returns the default namespace URI as required by the DOM
Layer 3 spec. Hence, after attaching a node to a tree, you can check
if a default namespace decl is in scope and call setNamespace if
needed.