summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/qxmlschemavalidator
diff options
context:
space:
mode:
authorTobias Koenig <tokoe@kde.org>2009-06-03 15:40:41 (GMT)
committerTobias Koenig <tokoe@kde.org>2009-06-03 15:40:41 (GMT)
commitf7741b78c90abcb272345810d55e446a7f390032 (patch)
tree7aa360dbd0d59bb2a6bd0205020693adb169bf93 /doc/src/snippets/qxmlschemavalidator
parent4785ed9b76104c272476f62780dde086e21b20ce (diff)
downloadQt-f7741b78c90abcb272345810d55e446a7f390032.zip
Qt-f7741b78c90abcb272345810d55e446a7f390032.tar.gz
Qt-f7741b78c90abcb272345810d55e446a7f390032.tar.bz2
Fixed typo in apidocs and extended example code
Diffstat (limited to 'doc/src/snippets/qxmlschemavalidator')
-rw-r--r--doc/src/snippets/qxmlschemavalidator/main.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/doc/src/snippets/qxmlschemavalidator/main.cpp b/doc/src/snippets/qxmlschemavalidator/main.cpp
index 13cd45f..0803380 100644
--- a/doc/src/snippets/qxmlschemavalidator/main.cpp
+++ b/doc/src/snippets/qxmlschemavalidator/main.cpp
@@ -48,6 +48,7 @@ class SchemaValidator
void validateFromUrl() const;
void validateFromFile() const;
void validateFromData() const;
+ void validateComplete() const;
private:
QXmlSchema getSchema() const;
@@ -123,6 +124,27 @@ QXmlSchema SchemaValidator::getSchema() const
return schema;
}
+void SchemaValidator::validateComplete() const
+{
+//! [3]
+ 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";
+ }
+//! [3]
+}
+
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
@@ -132,6 +154,7 @@ int main(int argc, char **argv)
validator.validateFromUrl();
validator.validateFromFile();
validator.validateFromData();
+ validator.validateComplete();
return 0;
}