Hi,

after heavy searching I have found some namespace problems with
the DOMBuilder!

1. If I use the JAXP Interface with a DOMResult object which gets
   a Document/Node objects 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!

I'm not that familiar with the Xalan code, but I think the DOMBuilder should
test
somehow if the document which is used to append the new nodes uses DOM Level
1
or DOM LEvel 2 in the constructor and from that one stick to this setting
instead
of doing tests everywhere.

If someone can tell me a reliable method to test whether a Document/Node
uses
DOM Level 1 or DOM Level 2 I can make a patch for the DOMBuilder!

Regards,
Carsten

Reply via email to