Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-59932

QDomNamedNodeMap::namedItemNS() and QDomNamedNodeMap::namedItem() not working as expected

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.6.2
    • XML: DOM
    • None
    • Windows, Linux and macOS
    • macOS

    Description

      Let's say that we have the following XML code where the xlink namespace is listed before the xlink:href attribute:

      <main>
          <sub xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="href_value" />
      </main>
      

      Now, say that I want to retrieve the value of xlink:href. For this, I would use QDomNamedNodeMap::namedItemNS() and, as expected, it returns href_value.

      On the other hand, if I was to use QDomNamedNodeMap::namedItem(), I would expect the value to be empty, yet I am also getting href_value...

      Now, let's say that we have the following XML code where the xlink namespace is listed after the xlink:href attribute:

      <main>
          <sub xlink:href="href_value" xmlns:xlink="http://www.w3.org/1999/xlink" />
      </main>
      

      Using QDomNamedNodeMap::namedItemNS(), I would expect to get href_value, but instead I am getting an empty string...

      When it comes QDomNamedNodeMap::namedItem(), I would still expect an empty string, but once again I am getting href_value...

      Here is the output of the attached program:

      Namespace defined BEFORE the attribute:
      ---------------------------------------
      
      Retrieve the attribute value using QDomNamedNodeMap::namedItemNS():
       - Expected value: [href_value]
       - Actual value:   [href_value]
      
      Retrieve the attribute value using QDomNamedNodeMap::namedItem():
       - Expected value: []
       - Actual value:   [href_value]
      
      
      
      Namespace defined AFTER the attribute:
      --------------------------------------
      
      Retrieve the attribute value using QDomNamedNodeMap::namedItemNS():
       - Expected value: [href_value]
       - Actual value:   []
      
      Retrieve the attribute value using QDomNamedNodeMap::namedItem():
       - Expected value: []
       - Actual value:   [my_href_value]
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            agarny Alan Garny
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes