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

Document.createAttributeNS() accepts namespaceURI="http://xxxx.xx" for "xmlns"

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1fcs
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description



      Name: inR10064 Date: 10/20/2000



        Invocation of the method createAttributeNS(String namespaceURI, String qualifiedName)
      defined in class org.w3c.dom.Document with arguments

      document.createAttributeNS("http://xxxx.xx", "xmlns");

      doesn't throw DOMException with the NAMESPACE_ERR error code as it sould do
      (See test.java below).

        Definition of the method in p. 1.2 "Fundamental Interfaces" of DOM Level 2 Core
      (http://www.w3.org/TR/DOM-Level-2-Core/core.html#i-Document) says:

      " Exceptions
         DOMException
         ...
                      NAMESPACE_ERR: Raised
                        if the qualifiedName is malformed,
                            
                        if the qualifiedName has a prefix and the namespaceURI is null,
                            
                        if the qualifiedName has a prefix that is "xml" and the namespaceURI
                        is different from "http://www.w3.org/XML/1998/namespace",
                            
                        if the qualifiedName is "xmlns" and the namespaceURI
                        is different from "http://www.w3.org/2000/xmlns/". "

      This bug presents in builds jaxp-1.1ea-b8 and jaxp-1.1fcs-b9 and affects the
      new test in TCK JAXP 1.1
      api/org_w3c_dom/Document/CreateAttributeNSTests.html#createAttributeNSTest009.

      ------------------------------------test.java-----------------------------
      import org.w3c.dom.Document;
      import org.w3c.dom.DOMException;
      import javax.xml.parsers.DocumentBuilderFactory;

      public class test {
          
          public static void main(String argv[]) {
              
              try {
                  Document document = DocumentBuilderFactory.newInstance()
                                      .newDocumentBuilder().newDocument();
                  
                  document.createAttributeNS("http://xxxx.xx", "xmlns");
                  
                  System.out.println("Created an invalid attribute.");
              } catch (DOMException e) {
                  if (e.code == DOMException.NAMESPACE_ERR) {
                      System.out.println("OKEY");
                  } else {
                      System.out.println("Unexpected error code " + e.code);
                  }
              } catch (Throwable e) {
                      e.printStackTrace();
                      System.out.println("Unexpected " + e + " was thrown");
              }
          }
      }
      ---------------------------------------------------------------------------
      ---------------------------------------------------------------------------
      % java -version
      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)

      % java test
      Created an invalid attribute.
      ---------------------------------------------------------------------------

      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              egoei Edwin Goei (Inactive)
              Reporter:
              inevsunw Inev Inev (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: