I'll need to revisit this. Its purpose is to both avoid redundant
namespace declarations as well as avoid internal memory corruption of ns
nodes in documents.
iirc it should only be walking back up the tree to a node that might
have declared the namespace being referenced.
I note that there was some recent discussion about fixing DOMNameSpaceNode
on this list. I'd like to bring up a (perhaps) related issue: the
dom_reconcile_ns() function which is called whenever a new namespaced node
(for example, created with Document#createElementNS) is inserted into the
tree. dom_reconcile_ns() does a full walk up to the root of the DOM (via
the call to xmlSearchNsByHref) which can create a quadratic slowdown for
What is this function doing? Can we do it lazily? Technically HTML
elements should be created in the HTML namespace, but doing so leads to
extreme performance loss -- parsing a 2MB file goes from 0.4s (with
Document#createElement()) to 2.5s (with Document#createElementNS()).