XML schema validation QXmlSchemaValidator and messagehandler



  • I am writing a test program to check that our xml is working. It a) goes through each element and writes a value which is within range into the in-memory DOM, b) writes the whole DOM out to a test XML file, c) reads the XML file as a text file and checks that the value is correct, d) validates the test XML file against the schema, e) reads the XML file in to a test DOM and compares the original DOM and the test DOM for the specific element.
    At the moment, it tests more than 10 elements, and then gives an error saying that the test XML file is invalid at line -1. The associated MessageHandler::statusMessage() from the validator is simply blank!
    Since the test XML file is written and validated a number of times, it seems likely that my code for writing the XML file is correct. Just before this error, I have checked that the test XML file contains the correct data value, therefore the test XML file exists, it is readable, and it has been closed. I can open the test XML file but I see no problems there.
    Can anyone suggest a possible cause of this error, and/or how to investigate further?



  • I have found the answer myself. The error always occured after the previous test had set a decimal value and found that the value read back was marginally different (to the sixth decimal place). When debugging, I had attempted to stop execution at this point, and had placed a
    QCoreApplication::quit();
    statement line. This did not stop the execution and I had forgotten about it, but it had interfered with the XML processing and was causing this error.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.