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

Attr.getSpecified() returns false for an attribute assigned with a value

    Details

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

      Description



      Name: eaR10174 Date: 01/23/2001


        Invocation of the getSpecified() method defined in interface org.w3c.dom.Attr
      returns false when the Attr object has a value explicitly assigned in the document.
      (See test.java below)
                                                        
        Definition in p. 1.2 "Fundamental Interfaces" of DOM Level 2 Core
      (http://www.w3.org/TR/2000/PR-DOM-Level-2-Core-20000927/core.html#ID-637646024)
      reads:
        " Attributes
               specified of type boolean, readonly
                    If this attribute was explicitly given a value in the original document,
                    this is true; otherwise, it is false. "

        This bug appears in the build jaxp-1.1ea2-b18-22_jan_2001 and affects the test in TCK JAXP 1.1

      api/com/sun/xml/tests/dom/AttributeTest.html#positiveGetSpecifiedTrue

      introduced in the TCK JAXP 1.0.1 .


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

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

                  String data =
                      "<?xml version=\"1.0\" ?>" +
                      "<root c=\"xxx\" />";
              
                  ByteArrayInputStream in = new ByteArrayInputStream(data.getBytes());

                  Document document = documentBuilder.parse(in);
                  
                  Element root = document.getDocumentElement();
                  
                  Attr attr = root.getAttributeNode("c");
                  
                  System.out.println("Attr implementation: " + attr.getClass().getName());
                  
                  System.out.println("specified: " + attr.getSpecified());
                  
              } catch (Exception e) {
                  System.out.println("Unexpected " + e + " was thrown");
              }
          }
      }
      ---------------------------------------------------------------------------
      ---------------------------------------------------------------------------
      % java -showversion -cp .:jaxp1.1/jaxp.jar:jaxp1.1/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)

      Attr implementation: org.apache.crimson.tree.AttributeNode
      specified: false

      % java -showversion -cp .:jaxp1.0.1/jaxp.jar:jaxp1.0.1/parser.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)

      Attr implementation: com.sun.xml.tree.AttributeNode
      specified: true
      ---------------------------------------------------------------------------

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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: