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

getNodeValue should return 'null' value for Element nodes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 7u80, 8u40, 9
    • Fix Version/s: 9
    • Component/s: xml
    • Subcomponent:
    • Resolved In Build:
      b68
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        Node.getNodeValue() should return NULL values for Element node type [1].
        8032908 fix changed that behavior incorrectly. The JDK-8032908 fix should be revisited.
        getTextContent() calls getNodeValue() which is incorrect:
        java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeProxy.java
        @@ -2116,7 +2116,7 @@
              */
             @Override
             public String getTextContent() throws DOMException {
        - return getNodeValue(); // overriden in some subclasses
        + return dtm.getStringValue(node).toString();
             }
         
              /**

        8032908 fix should be reverted:
        java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java
        --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java Thu May 21 16:21:00 2015 -0700
        +++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java Thu May 28 15:36:38 2015 +0300
        @@ -3145,11 +3145,7 @@
                                           m_data.elementAt(-dataIndex+1));
               }
             }
        - else if (DTM.ELEMENT_NODE == type)
        - {
        - return getStringValueX(nodeHandle);
        - }
        - else if (DTM.DOCUMENT_FRAGMENT_NODE == type
        + else if (DTM.ELEMENT_NODE == type || DTM.DOCUMENT_FRAGMENT_NODE == type
                      || DTM.DOCUMENT_NODE == type)
             {
               return null;

        Few tests should be updated to use the proper functions: 8032908 and 8062518

        [1] Table in "Interface Node->Definition group NodeType" section: http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                aefimov Aleksej Efimov
                Reporter:
                aefimov Aleksej Efimov
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: