Author jkloth
Recipients Alexander.Tobias.Heinrich, jkloth
Date 2013-06-10.18:07:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1370887647.5.0.0867914979336.issue18182@psf.upfronthosting.co.za>
In-reply-to
Content
This really is not a bug, but more of a (common) misunderstanding of how the mixing of namespace-aware (createElementNS) and namespace-ignorant (createElement) methods work.

From DOM3 Core [http://www.w3.org/TR/DOM-Level-3-Core/core.html#Namespaces-Considerations]:

  Elements and attributes created by the DOM Level 1 methods do not
  have a namespace prefix, namespace URI or local name.

DOM4 updates this to say that the namespace URI and prefix are null if not explicitly given at creation.

To use your example, adding a Chimp-element to the existing document is really:

<?xml version="1.0" encoding="utf-8"?>
<Zoo xmlns='http://foo.bar/zoo'>
  <Compound><Chimp/><Chimp xmlns=""/></Compound>
</Zoo>

The fact that serializing and re-parsing it works is really a bug in the serializing code not honoring the null-namespace.

So in short, always use create*NS() methods when dealing with namespace-aware XML (like XPath).
History
Date User Action Args
2013-06-10 18:07:27jklothsetrecipients: + jkloth, Alexander.Tobias.Heinrich
2013-06-10 18:07:27jklothsetmessageid: <1370887647.5.0.0867914979336.issue18182@psf.upfronthosting.co.za>
2013-06-10 18:07:27jklothlinkissue18182 messages
2013-06-10 18:07:27jklothcreate