Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4433662

localName is not null for clone of Element/Attr object created by DOM1 methods

XMLWordPrintable

    • 1.1.1
    • generic
    • generic
    • Verified



        Name: eaR10174 Date: 04/04/2001


          The sample below shows that if an Element or Attr object is created with the
        createElement(String) or the createAttribute(String) method then invocation of the method
        org.w3c.dom.Node.cloneNode(deep) for this object returns clone with non-null localName.
          Note: the original object has a null value as its local name.
          
          The bug is detected in all builds since the jaxp-1.1.1-b23-01_mar_2001 till the build till the
        build jaxp-1.1.1-b24-01_apr_2001 and affects following new tests in JCK Merlin (not yet
        integrated)
          
          api/org_w3c_dom/Node/ClonedNodeTests.java#cloneNodeTest03
          api/org_w3c_dom/Node/ClonedNodeTests.java#cloneNodeTest04
          api/org_w3c_dom/Node/ClonedNodeTests.java#cloneNodeTest08
          api/org_w3c_dom/Node/ClonedNodeTests.java#cloneNodeTest09
          api/org_w3c_dom/Node/ClonedNodeTests.java#cloneNodeTest23
          api/org_w3c_dom/Node/ClonedNodeTests.java#cloneNodeTest24
          
          There were bugs
            #4381233 ("Document.createAttribute() returns an attribute with non-null localName")
            #4381234 ("Document.createElement() returns an element with non-null localName")

          in JAXP builds before jaxp-1.1.1-b23-01_mar_2001, which possibly mask the reported bug.
          
          The bug does not appear if the nodes are created by DOM2 methods.
         
        ------------------------------------test.java-----------------------------
        import org.w3c.dom.Document;
        import org.w3c.dom.Element;
        import org.w3c.dom.Attr;
        import javax.xml.parsers.DocumentBuilderFactory;
        import javax.xml.parsers.DocumentBuilder;

        public class test {
            
            public static void main(String argv[]) {
                try {
                    Document document = DocumentBuilderFactory.newInstance()
                                            .newDocumentBuilder().newDocument();
                    
                    /* Create nodes by DOM1 methods */
                    Element element = document.createElement("test");
                    Attr attr = document.createAttribute("test");
                    
                    Element clonedElement = (Element)element.cloneNode(false);
                    Attr clonedAttr = (Attr)attr.cloneNode(false);
                    
                    System.out.println("Nodes created by DOM1 methods.");
                    System.out.println("Element localName: " + element.getLocalName());
                    System.out.println("Cloned element localName: " + clonedElement.getLocalName());
                    System.out.println("Attr localName: " + attr.getLocalName());
                    System.out.println("Cloned attr localName: " + clonedAttr.getLocalName());


                    System.out.println("");
                    System.out.println("");

                    /* Create nodes by DOM2 methods */
                    element = document.createElementNS("http://xxxxx.xxx", "ls:test");
                    attr = document.createAttributeNS("http://xxxxx.xxx", "ls:test");
                    
                    clonedElement = (Element)element.cloneNode(false);
                    clonedAttr = (Attr)attr.cloneNode(false);
                    
                    System.out.println("Nodes created by DOM2 methods.");
                    System.out.println("Element localName: " + element.getLocalName());
                    System.out.println("Cloned element localName: " + clonedElement.getLocalName());
                    System.out.println("Attr localName: " + attr.getLocalName());
                    System.out.println("Cloned attr localName: " + clonedAttr.getLocalName());
                } catch (Exception e) {
                    System.out.println("Exception: " + e);
                }
            }
        }
        ---------------------------------------------------------------------------
        -------------------------- log --------------------------------------------
        JAXP build version: jaxp-1.1.1-b24-01_apr_2001

        % java -showversion -cp .:./jaxp.jar:./crimson.jar test
        java version "1.3.0"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
        Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)

        Nodes created by DOM1 methods.
        Element localName: null
        Cloned element localName: test
        Attr localName: null
        Cloned attr localName: test


        Nodes created by DOM2 methods.
        Element localName: test
        Cloned element localName: test
        Attr localName: test
        Cloned attr localName: test
        --------------------------------------------------------------------------
          
        ======================================================================

              egoei Edwin Goei (Inactive)
              evgsunw Evg Evg (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: