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

Element.setAttributeNS() doesn't add a new attribute

    Details

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

      Description



      Name: inR10064 Date: 11/17/2000



        JAXP 1.1 method
              org.w3c.dom.Element.setAttributeNS(String namespaceURI,
                                                 String qualifiedName, String value)
              
      does not add a new attribute, instead of this it throws an exception (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#ID-745549614) says:

      " setAttributeNS introduced in DOM Level 2
                            Adds a new attribute. "

        This bug presents in build jaxp-1.1ea2-b10-03_nov_2000
      and affects the new test in TCK JAXP 1.1

      api/org_w3c_dom/Element/SetAttributeNSTests.html#setAttributeNSTest001

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

      public class test {
          
          public static void main(String argv[]) {
              
              try {
                  DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance()
                                                    .newDocumentBuilder();

                  Document document = documentBuilder.newDocument();

                  Element root = document.createElementNS("http://xxxx.xx/", "test:root");
              
                  root.setAttributeNS("http://xxxx.xx/", "test:a", "1");
                  
                  System.out.println("The attribute was added!");
              } catch (Exception e) {
                  e.printStackTrace();
                  System.out.println("Unexpected exception " + e + " was thrown");
              }
          }
      }
      ---------------------------------------------------------------------------
      ---------------------------------------------------------------------------
      % java -cp .:jaxp1.1/jaxp.jar:jaxp1.1/crimson.jar test
      org.apache.crimson.tree.DomEx: org.apache.crimson.tree/D-003
              at org.apache.crimson.tree.ElementNode.setAttributeNodeNS(ElementNode.java:473)
              at org.apache.crimson.tree.ElementNode.setAttributeNS(ElementNode.java:457)
              at test.main(test.java:18)
      Unexpected exception org.apache.crimson.tree.DomEx: org.apache.crimson.tree/D-003 was thrown
      ---------------------------------------------------------------------------

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

        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: