QXmlSchemaValidator Class
The QXmlSchemaValidator class validates XML instance documents against a W3C XML Schema. More...
| Header: | #include <QXmlSchemaValidator> |
| qmake: | QT += xmlpatterns |
| Since: | Qt 4.6 |
This class was introduced in Qt 4.6.
Note: All functions in this class are reentrant.
Detailed Description
The QXmlSchemaValidator class loads, parses an XML instance document and validates it against a W3C XML Schema that has been compiled with QXmlSchema.
The following example shows how to load a XML Schema from a local file, check whether it is a valid schema document and use it for validation of an XML instance document:
QUrl schemaUrl("file:///home/user/schema.xsd");
QXmlSchema schema;
schema.load(schemaUrl);
if (schema.isValid()) {
QFile file("test.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";
}
XML Schema Version
This class implements schema validation according to the XML Schema 1.0 specification.
See also QXmlSchema and XML Schema Validation Example.