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 .
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");
QXmlSchema schema;
schema.
load(&file,
QUrl::fromLocalFile(schemaFile.
fileName()));
if (schema.isValid()) {
QFile file("document.xml");
QXmlSchemaValidator validator(schema);
if (validator.
validate(&file,
QUrl::fromLocalFile(file.
fileName()))) qDebug() << "instance document is valid";
else
qDebug() << "instance document is invalid";
}
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";
}
To copy to clipboard, switch view to plain text mode
Bookmarks