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

Document.getElementsByTagNameNS() works wrong

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • xml
    • b48
    • generic
    • generic
    • Verified

      FAIL: jdk6.0-b46 PASS: jdk6.0-b45
      Following tests are failed because of wrong Document.getElementsByTagNameNS():

      api/org_w3c/dom/Element/index.html#HasAttributeNS[HasAttributeNS002]
      api/org_w3c/dom/Element/index.html#RemoveAttributeNS[RemoveAttributeNS002]
      api/org_w3c/dom/Element/index.html#RemoveAttributeNode[RemoveAttributeNode004]
      api/org_w3c/dom/Element/index.html#RemoveAttributeNode[RemoveAttributeNode005]
      api/org_w3c/dom/Element/index.html#RemoveAttribute[RemoveAttribute004]
      api/org_w3c/dom/NamedNodeMap/index.html#RemoveNamedItemNS[RemoveNamedItemNS006]
      api/org_w3c/dom/Node/index.html#SetPrefix[SetPrefix014]
      ======================================================================================
      code to reproduce : GetElementNSTest.java
      ======================================================================================
      import java.io.IOException;
      import java.io.PrintWriter;
      import javasoft.sqe.javatest.Status;
      import javasoft.sqe.javatest.lib.MultiTest;
      import javasoft.sqe.tests.api.javax.xml.parsers.DocBuilderWrapper;
      import javax.xml.parsers.DocumentBuilder;
      import javax.xml.parsers.DocumentBuilderFactory;
      import javax.xml.parsers.ParserConfigurationException;
      import org.w3c.dom.Attr;
      import org.w3c.dom.Document;
      import org.w3c.dom.Element;
      import org.xml.sax.SAXException;

      public class GetElementNSTest{

      public static void main(String[] str){
      GetElementNSTest test = new GetElementNSTest();
      test.HasAttributeNS002();
      }

      public void HasAttributeNS002() {
               String data =
      "<?xml version=\"1.0\" ?>"
               + "<!DOCTYPE test:root ["
      + "<!ELEMENT test:root ANY>"
      + "<!ATTLIST test:root test:a CDATA #FIXED \"qqq\">"
      + "]>"
               + "<test:root xmlns:test=\"http://xxxx.xx/\">"
      + "</test:root>";

               Document document = null;
      try {
      DocumentBuilderFactory docBF = DocumentBuilderFactory.newInstance();
      docBF.setNamespaceAware(true);
      DocBuilderWrapper docBuilder = new DocBuilderWrapper(docBF.newDocumentBuilder());
      document = docBuilder.parse(data);
      } catch (ParserConfigurationException e) {
               System.out.println(e.toString());return;
      } catch (IOException e) {
               System.out.println(e.toString());return;
      } catch (SAXException e) {
               System.out.println(e.toString());return;
      }

              Element root = (Element)document.getElementsByTagNameNS("http://xxxx.xx/", "root").item(0);
      //root is null
              if (root.hasAttributeNS("http://xxxx.xx/", "a")) {
                  System.out.println("OKEY");
      return;
              } else {
                  System.out.println("Returned false. Expected true");
      return;
              }
          }
      }

      ======================================================================================
      I checked jck results:
      jdk6.0 build 46: FAIL
      jdk6.0 build 47+: PASS

            duke J. Duke
            dtoporovsunw Denis Toporov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: