You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by xa...@xml.apache.org on 2004/09/04 19:20:36 UTC

[jira] Updated: (XALANJ-745) DOMBuilder mixes DOM Level 1 and 2

The following issue has been updated:

    Updater: Brian Minchau (mailto:minchau@ca.ibm.com)
       Date: Sat, 4 Sep 2004 10:19 AM
    Changes:
             assignee changed from Xalan Developers Mailing List
             description changed from 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 to 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
             environment changed from Operating System: All
Platform: All to Operating System: All
Platform: All
             priority changed to Blocker
             Component changed to DOM
             Component changed from Other
    ---------------------------------------------------------------------
For a full history of the issue, see:

  http://issues.apache.org/jira/browse/XALANJ-745?page=history

---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/XALANJ-745

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: XALANJ-745
    Summary: DOMBuilder mixes DOM Level 1 and 2
       Type: Bug

     Status: Unassigned
   Priority: Blocker

    Project: XalanJ2
 Components: 
             DOM
   Versions:
             CurrentCVS

   Assignee: 
   Reporter: Carsten Ziegeler

    Created: Thu, 20 Dec 2001 12:09 AM
    Updated: Sat, 4 Sep 2004 10:19 AM
Environment: Operating System: All
Platform: All

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


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org