PDA

View Full Version : QXmlSchemaValidator validate hanging



alendamadzic
24th August 2015, 11:42
Using the example in the documentation of the QXmlSchemaValidator Class, I am attempting to validate a simple xml document against a very simple schema (See attached files).
Once calling the validate() method on the validator, my application hangs for a while before exiting out :mad:.

Is this an issue with Qt's validation, or am I doing something obviously stupid in my schema that I have missed.




QFile schemaFile("schema.xsd");
schemaFile.open(QIODevice::ReadOnly);

QXmlSchema schema;
schema.load(&file, QUrl::fromLocalFile(schemaFile.fileName()));

if (schema.isValid()) {
QFile file("document.xml");
file.open(QIODevice::ReadOnly);

QXmlSchemaValidator validator(schema);
if (validator.validate(&file, QUrl::fromLocalFile(file.fileName())))
qDebug() << "instance document is valid";
else
qDebug() << "instance document is invalid";
}