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

Streaming XMLs from reader to writer changes namespace name

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 5.12.0, 5.12.1, 5.12.2, 5.12.3
    • None

    Description

      Scenario: reading an xml file with QXmlStreamReader and writing every (unmodified) token to another file with QXmlStreamWriter.

       

      QString streamXML(QString const& xmlIn)
      {
       QString xmlOut;
      QXmlStreamReader reader(xmlIn);
       QXmlStreamWriter writer(&xmlOut);
      while (!reader.atEnd()) {
       reader.readNext();
       writer.writeCurrentToken(reader);
       }
      return xmlOut;
      }
      streamXML(QString("<?xml version='1.0'?><abc:elem1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:abc='ns1' />"));
      

      The output is:

      <?xml version="1.0"?><n1:elem1 xmlns:n1="ns1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:abc="ns1"/>
      

      Please note, that the namespace is renamed and doubled.

      Instead of:

      <?xml version="1.0"?><abc:elem1 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:abc="ns1"/>
      
      

      This issue was caused by the changes for https://bugreports.qt.io/browse/QTBUG-63434

      I already patched my local qt sources with a fix, but I'm not aware of the check in process, therefore i have appended my patchfile.

      Please review my patch and check it in. The issue will occur with most XML files using namespaces that's why i think it has important priority.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jens_moeller Jens Moeller
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: