Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.2.0
-
None
-
None
-
Operating System: All
Platform: All
-
5528
Description
There are several namespace problems in the DOMBuilder which all result
in DOMs which can have mixed Level 1 and Level 2 objects!
1. If I use the JAXP Interface with a DOMResult object which gets
a Document/Node object in the constructor, the underlying DOMBuilder
does not test whether this Document/Node supports namespaces or not!
This results in DOM trees having DOM Level 1 mixed with DOM Level 2
nodes!
2. The startElement() method tests itself which DOM Level is used by looking
at the namespace parameter.
This test is not correct. The SAX spec states, that if an element has no
namespace (but namespaces are used) the namespace parameter is the empty
string. The startElement() method assumes in this case that DOM Level 1
is used instead!
>>> CODE SNIPPET FROM DOMBUILDER <<<<
public void startElement(
String ns, String localName, String name, Attributes atts)
throws org.xml.sax.SAXException
{
Element elem;
if ((null == ns) || (ns.length() == 0))
elem = m_doc.createElement(name);
else
elem = m_doc.createElementNS(ns, name);
....
>>> END CODE SNIPPET FROM DOMBUILDER <<<<
3. The handling of the attributes of the element in the startElement() does
not reflect the namespace handling for the element. Here again for each
attribute the namespace uri is tested against the empty string. If it is
the empty string, DOM Level 1 methods are used otherwise DOM Level 2.
Again, this results in mixed objects!
Attached is a patch which fixes all these problems. The incoming document is
checked once if it is DOM Level 1 or 2 and from that one the same set of
methods is used