Results 1 to 4 of 4

Thread: Possilble Bug? QXmlStreamReader

  1. #1
    Join Date
    Feb 2010
    Posts
    3
    Qt products
    Qt4

    Default Possilble Bug? QXmlStreamReader

    Has anyone noticed any issues when attempting to parse large xml documents with the QXmlStreamReader. We are developing code that reads a stream of data off of a QTcpSocket. We attach the reader to the socket and walk over the content. At a certain point, when using a large data stream, we see errors dealing with the parsing.

    After some digging it looks like the QXmlStreamReader class has an internal buffer of 8192. What we have been able to determine is that once the buffer fills up the reader begins to process that data. The problem seems to happen when the buffer size restriction causes data chopping where the final thing in the buffer might be something like

    <tag attribute="value" /><tag attribute="va

    Since the tag is not complete here a parser error happens. Does this mean that the streamed documents have to be under 8192? I figured the reader, since its an incremental parser, would have reported a premature end of document error where my ready read would have continued to stream in the rest of the data. This however, does not seem to happen.

    The code I'm using is rather involved and for commercial use so I can't post any of it here, hence the no examples.

  2. #2
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: Possilble Bug? QXmlStreamReader

    If you get QXmlStreamReader::PrematureEndOfDocumentError just run QEventLoop and wait more data from socket, when you get data then exit from local QEventLoop and return to while(). If you don't get new data or user abort parsing just quit from QEventLoop with exit code like "QEventLoop::exit(1)", then compare returned value "int errcode = eventLoop.exec();" and just interrupt while().

    So you can't resume parsing without QEventLoop, becouse data not arrived.

  3. #3
    Join Date
    Feb 2010
    Posts
    3
    Qt products
    Qt4

    Default Re: Possilble Bug? QXmlStreamReader

    There is already an event loop running for the thread. That is not the problem. Also, the problem is that I am NOT getting a premature end of document. My code is already structured in a way that looks for this error code and does a waitForReadyRead on the device associated with the xml reader. As per Qt's documentation calling wait for ready read from within a ready read signal handler is permitted. Doing this will NOT recursively emit the readyRead signal.

    Anyway, the end result here seems to be an error in the way that Qt is processes the XML document if the total size of the document exceeds their internal buffer. Since one batch of text I stream over the socket from a test client exceeds that buffer size, the half tag that is at the end of the buffer is then parsed incorrectly. I end up with a parsing error rather than a premature end of document error. Since I can't distinguish between a real parse error and one generated from this apparently code glitch there is no way to take action here.

  4. #4
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: Possilble Bug? QXmlStreamReader

    Wich error you get, QXmlStreamReader::NotWellFormedError? Maybe something wrong with xml data? Restricted characters for example.

    I don't think what problem in buffer, becouse my client/server application work few hours with infinite xml stream.

Similar Threads

  1. QXmlStreamReader
    By sophister in forum Qt Programming
    Replies: 6
    Last Post: 24th August 2011, 17:31
  2. Need help with QXmlStreamReader
    By jknotzke in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2009, 09:26
  3. QXmlStreamReader issue
    By yagabey in forum Qt Programming
    Replies: 11
    Last Post: 31st December 2008, 21:06
  4. QXmlStreamReader problems
    By rishid in forum Newbie
    Replies: 2
    Last Post: 26th June 2008, 11:43
  5. QXmlStreamReader rewind
    By bunjee in forum Qt Programming
    Replies: 3
    Last Post: 13th April 2008, 08:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.