DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5528>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5528

DOMBuilder mixes DOM Level 1 and 2

           Summary: DOMBuilder mixes DOM Level 1 and 2
           Product: XalanJ2
           Version: CurrentCVS
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: org.apache.xml.utils
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


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

Reply via email to