summaryrefslogtreecommitdiffstats
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
parent4785ed9b76104c272476f62780dde086e21b20ce (diff)
downloadQt-f7741b78c90abcb272345810d55e446a7f390032.zip
Qt-f7741b78c90abcb272345810d55e446a7f390032.tar.gz
Qt-f7741b78c90abcb272345810d55e446a7f390032.tar.bz2
Fixed typo in apidocs and extended example code
-rw-r--r--doc/src/snippets/qxmlschemavalidator/main.cpp23
-rw-r--r--src/xmlpatterns/api/qxmlschema.cpp5
-rw-r--r--src/xmlpatterns/api/qxmlschemavalidator.cpp12
3 files changed, 37 insertions, 3 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;
}
diff --git a/src/xmlpatterns/api/qxmlschema.cpp b/src/xmlpatterns/api/qxmlschema.cpp
index ec370ca..c6dc9b2 100644
--- a/src/xmlpatterns/api/qxmlschema.cpp
+++ b/src/xmlpatterns/api/qxmlschema.cpp
@@ -58,6 +58,11 @@
that can be used further for validation of XML instance documents via
\l{QXmlSchemaValidator}.
+ The following example shows how to load a XML Schema file from the network
+ and test whether it is a valid schema document:
+
+ \snippet doc/src/snippets/qxmlschema/main.cpp 0
+
\sa QXmlSchemaValidator, {xmlpatterns/schema}{XML Schema Validation Example}
*/
diff --git a/src/xmlpatterns/api/qxmlschemavalidator.cpp b/src/xmlpatterns/api/qxmlschemavalidator.cpp
index dc8e55d..d5596c5 100644
--- a/src/xmlpatterns/api/qxmlschemavalidator.cpp
+++ b/src/xmlpatterns/api/qxmlschemavalidator.cpp
@@ -63,6 +63,12 @@
The QXmlSchemaValidator class loads, parses an XML instance document and validates it
against a W3C XML Schema that has been compiled with \l{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:
+
+ \snippet doc/src/snippets/qxmlschemavalidator/main.cpp 3
+
\sa QXmlSchema, {xmlpatterns/schema}{XML Schema Validation Example}
*/
@@ -110,7 +116,7 @@ void QXmlSchemaValidator::setSchema(const QXmlSchema &schema)
Validates the XML instance document read from \a data with the
given \a documentUri against the schema.
- Returns \c true if the XML instance document is valid according the
+ Returns \c true if the XML instance document is valid according to the
schema, \c false otherwise.
Example:
@@ -130,7 +136,7 @@ bool QXmlSchemaValidator::validate(const QByteArray &data, const QUrl &documentU
/*!
Validates the XML instance document read from \a source against the schema.
- Returns \c true if the XML instance document is valid according the
+ Returns \c true if the XML instance document is valid according to the
schema, \c false otherwise.
Example:
@@ -155,7 +161,7 @@ bool QXmlSchemaValidator::validate(const QUrl &source) const
Validates the XML instance document read from \a source with the
given \a documentUri against the schema.
- Returns \c true if the XML instance document is valid according the
+ Returns \c true if the XML instance document is valid according to the
schema, \c false otherwise.
Example: