summaryrefslogtreecommitdiff
path: root/examples/xmlpatterns/schema
diff options
context:
space:
mode:
Diffstat (limited to 'examples/xmlpatterns/schema')
-rw-r--r--examples/xmlpatterns/schema/files/contact.xsd25
-rw-r--r--examples/xmlpatterns/schema/files/invalid_contact.xml11
-rw-r--r--examples/xmlpatterns/schema/files/invalid_order.xml13
-rw-r--r--examples/xmlpatterns/schema/files/invalid_recipe.xml14
-rw-r--r--examples/xmlpatterns/schema/files/order.xsd23
-rw-r--r--examples/xmlpatterns/schema/files/recipe.xsd40
-rw-r--r--examples/xmlpatterns/schema/files/valid_contact.xml11
-rw-r--r--examples/xmlpatterns/schema/files/valid_order.xml18
-rw-r--r--examples/xmlpatterns/schema/files/valid_recipe.xml13
-rw-r--r--examples/xmlpatterns/schema/main.cpp53
-rw-r--r--examples/xmlpatterns/schema/mainwindow.cpp217
-rw-r--r--examples/xmlpatterns/schema/mainwindow.h67
-rw-r--r--examples/xmlpatterns/schema/schema.pro16
-rw-r--r--examples/xmlpatterns/schema/schema.qrc13
-rw-r--r--examples/xmlpatterns/schema/schema.ui71
15 files changed, 605 insertions, 0 deletions
diff --git a/examples/xmlpatterns/schema/files/contact.xsd b/examples/xmlpatterns/schema/files/contact.xsd
new file mode 100644
index 0000000..3e1b570
--- /dev/null
+++ b/examples/xmlpatterns/schema/files/contact.xsd
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="contact">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="givenName" type="xsd:string"/>
+ <xsd:element name="familyName" type="xsd:string"/>
+ <xsd:element name="birthdate" type="xsd:date" minOccurs="0"/>
+ <xsd:element name="homeAddress" type="address"/>
+ <xsd:element name="workAddress" type="address" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="address">
+ <xsd:sequence>
+ <xsd:element name="street" type="xsd:string"/>
+ <xsd:element name="zipCode" type="xsd:string"/>
+ <xsd:element name="city" type="xsd:string"/>
+ <xsd:element name="country" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+</xsd:schema>
diff --git a/examples/xmlpatterns/schema/files/invalid_contact.xml b/examples/xmlpatterns/schema/files/invalid_contact.xml
new file mode 100644
index 0000000..42f1edd
--- /dev/null
+++ b/examples/xmlpatterns/schema/files/invalid_contact.xml
@@ -0,0 +1,11 @@
+<contact>
+ <givenName>John</givenName>
+ <familyName>Doe</familyName>
+ <title>Prof.</title>
+ <workAddress>
+ <street>Sandakerveien 116</street>
+ <zipCode>N-0550</zipCode>
+ <city>Oslo</city>
+ <country>Norway</country>
+ </workAddress>
+</contact>
diff --git a/examples/xmlpatterns/schema/files/invalid_order.xml b/examples/xmlpatterns/schema/files/invalid_order.xml
new file mode 100644
index 0000000..8ffc5fd
--- /dev/null
+++ b/examples/xmlpatterns/schema/files/invalid_order.xml
@@ -0,0 +1,13 @@
+<order>
+ <customerId>234219</customerId>
+ <article>
+ <articleId>21692</articleId>
+ <count>3</count>
+ </article>
+ <article>
+ <articleId>24749</articleId>
+ <count>9</count>
+ </article>
+ <deliveryDate>2009-01-23</deliveryDate>
+ <payed>yes</payed>
+</order>
diff --git a/examples/xmlpatterns/schema/files/invalid_recipe.xml b/examples/xmlpatterns/schema/files/invalid_recipe.xml
new file mode 100644
index 0000000..4d75af6
--- /dev/null
+++ b/examples/xmlpatterns/schema/files/invalid_recipe.xml
@@ -0,0 +1,14 @@
+<recipe>
+ <title>Cheese on Toast</title>
+ <ingredient name="Bread" quantity="2" unit="slices"/>
+ <ingredient name="Cheese" quantity="2" unit="slices"/>
+ <time quantity="3" unit="days"/>
+ <method>
+ <step>1. Slice the bread and cheese.</step>
+ <step>2. Grill one side of each slice of bread.</step>
+ <step>3. Turn over the bread and place a slice of cheese on each piece.</step>
+ <step>4. Grill until the cheese has started to melt.</step>
+ <step>5. Serve and enjoy!</step>
+ </method>
+ <comment>Tell your friends about it!</comment>
+</recipe>
diff --git a/examples/xmlpatterns/schema/files/order.xsd b/examples/xmlpatterns/schema/files/order.xsd
new file mode 100644
index 0000000..405cafe
--- /dev/null
+++ b/examples/xmlpatterns/schema/files/order.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="order">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerId" type="xsd:positiveInteger"/>
+ <xsd:element name="article" type="articleType" maxOccurs="unbounded"/>
+ <xsd:element name="deliveryDate" type="xsd:date"/>
+ <xsd:element name="payed" type="xsd:boolean"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="articleType">
+ <xsd:sequence>
+ <xsd:element name="articleId" type="xsd:positiveInteger"/>
+ <xsd:element name="count" type="xsd:positiveInteger"/>
+ <xsd:element name="comment" type="xsd:string" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+</xsd:schema>
diff --git a/examples/xmlpatterns/schema/files/recipe.xsd b/examples/xmlpatterns/schema/files/recipe.xsd
new file mode 100644
index 0000000..bbbafd9
--- /dev/null
+++ b/examples/xmlpatterns/schema/files/recipe.xsd
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="recipe">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="title" type="xsd:string"/>
+ <xsd:element name="ingredient" type="ingredientType" maxOccurs="unbounded"/>
+ <xsd:element name="time" type="timeType"/>
+ <xsd:element name="method">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="step" type="xsd:string" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="ingredientType">
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="quantity" type="xsd:positiveInteger"/>
+ <xsd:attribute name="unit" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="timeType">
+ <xsd:attribute name="quantity" type="xsd:positiveInteger"/>
+ <xsd:attribute name="unit">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="seconds"/>
+ <xsd:enumeration value="minutes"/>
+ <xsd:enumeration value="hours"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+
+</xsd:schema>
diff --git a/examples/xmlpatterns/schema/files/valid_contact.xml b/examples/xmlpatterns/schema/files/valid_contact.xml
new file mode 100644
index 0000000..53c04d4
--- /dev/null
+++ b/examples/xmlpatterns/schema/files/valid_contact.xml
@@ -0,0 +1,11 @@
+<contact>
+ <givenName>John</givenName>
+ <familyName>Doe</familyName>
+ <birthdate>1977-12-25</birthdate>
+ <homeAddress>
+ <street>Sandakerveien 116</street>
+ <zipCode>N-0550</zipCode>
+ <city>Oslo</city>
+ <country>Norway</country>
+ </homeAddress>
+</contact>
diff --git a/examples/xmlpatterns/schema/files/valid_order.xml b/examples/xmlpatterns/schema/files/valid_order.xml
new file mode 100644
index 0000000..f83c36c
--- /dev/null
+++ b/examples/xmlpatterns/schema/files/valid_order.xml
@@ -0,0 +1,18 @@
+<order>
+ <customerId>194223</customerId>
+ <article>
+ <articleId>22242</articleId>
+ <count>5</count>
+ </article>
+ <article>
+ <articleId>32372</articleId>
+ <count>12</count>
+ <comment>without stripes</comment>
+ </article>
+ <article>
+ <articleId>23649</articleId>
+ <count>2</count>
+ </article>
+ <deliveryDate>2009-01-23</deliveryDate>
+ <payed>true</payed>
+</order>
diff --git a/examples/xmlpatterns/schema/files/valid_recipe.xml b/examples/xmlpatterns/schema/files/valid_recipe.xml
new file mode 100644
index 0000000..f6499ba
--- /dev/null
+++ b/examples/xmlpatterns/schema/files/valid_recipe.xml
@@ -0,0 +1,13 @@
+<recipe>
+ <title>Cheese on Toast</title>
+ <ingredient name="Bread" quantity="2" unit="slices"/>
+ <ingredient name="Cheese" quantity="2" unit="slices"/>
+ <time quantity="3" unit="minutes"/>
+ <method>
+ <step>1. Slice the bread and cheese.</step>
+ <step>2. Grill one side of each slice of bread.</step>
+ <step>3. Turn over the bread and place a slice of cheese on each piece.</step>
+ <step>4. Grill until the cheese has started to melt.</step>
+ <step>5. Serve and enjoy!</step>
+ </method>
+</recipe>
diff --git a/examples/xmlpatterns/schema/main.cpp b/examples/xmlpatterns/schema/main.cpp
new file mode 100644
index 0000000..d501b5f
--- /dev/null
+++ b/examples/xmlpatterns/schema/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "mainwindow.h"
+
+//! [0]
+int main(int argc, char* argv[])
+{
+ Q_INIT_RESOURCE(schema);
+ QApplication app(argc, argv);
+ MainWindow* const window = new MainWindow;
+ window->show();
+ return app.exec();
+}
+//! [0]
diff --git a/examples/xmlpatterns/schema/mainwindow.cpp b/examples/xmlpatterns/schema/mainwindow.cpp
new file mode 100644
index 0000000..ac0dd00
--- /dev/null
+++ b/examples/xmlpatterns/schema/mainwindow.cpp
@@ -0,0 +1,217 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtXmlPatterns>
+
+#include "mainwindow.h"
+#include "xmlsyntaxhighlighter.h"
+
+//! [4]
+class MessageHandler : public QAbstractMessageHandler
+{
+ public:
+ MessageHandler()
+ : QAbstractMessageHandler(0)
+ {
+ }
+
+ QString statusMessage() const
+ {
+ return m_description;
+ }
+
+ int line() const
+ {
+ return m_sourceLocation.line();
+ }
+
+ int column() const
+ {
+ return m_sourceLocation.column();
+ }
+
+ protected:
+ virtual void handleMessage(QtMsgType type, const QString &description,
+ const QUrl &identifier, const QSourceLocation &sourceLocation)
+ {
+ Q_UNUSED(type);
+ Q_UNUSED(identifier);
+
+ m_messageType = type;
+ m_description = description;
+ m_sourceLocation = sourceLocation;
+ }
+
+ private:
+ QtMsgType m_messageType;
+ QString m_description;
+ QSourceLocation m_sourceLocation;
+};
+//! [4]
+
+//! [0]
+MainWindow::MainWindow()
+{
+ setupUi(this);
+
+ new XmlSyntaxHighlighter(schemaView->document());
+ new XmlSyntaxHighlighter(instanceEdit->document());
+
+ schemaSelection->addItem(tr("Contact Schema"));
+ schemaSelection->addItem(tr("Recipe Schema"));
+ schemaSelection->addItem(tr("Order Schema"));
+
+ instanceSelection->addItem(tr("Valid Contact Instance"));
+ instanceSelection->addItem(tr("Invalid Contact Instance"));
+
+ connect(schemaSelection, SIGNAL(currentIndexChanged(int)), SLOT(schemaSelected(int)));
+ connect(instanceSelection, SIGNAL(currentIndexChanged(int)), SLOT(instanceSelected(int)));
+ connect(validateButton, SIGNAL(clicked()), SLOT(validate()));
+ connect(instanceEdit, SIGNAL(textChanged()), SLOT(textChanged()));
+
+ validationStatus->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
+
+ schemaSelected(0);
+ instanceSelected(0);
+}
+//! [0]
+
+//! [1]
+void MainWindow::schemaSelected(int index)
+{
+ instanceSelection->clear();
+ if (index == 0) {
+ instanceSelection->addItem(tr("Valid Contact Instance"));
+ instanceSelection->addItem(tr("Invalid Contact Instance"));
+ } else if (index == 1) {
+ instanceSelection->addItem(tr("Valid Recipe Instance"));
+ instanceSelection->addItem(tr("Invalid Recipe Instance"));
+ } else if (index == 2) {
+ instanceSelection->addItem(tr("Valid Order Instance"));
+ instanceSelection->addItem(tr("Invalid Order Instance"));
+ }
+ textChanged();
+
+ QFile schemaFile(QString(":/schema_%1.xsd").arg(index));
+ schemaFile.open(QIODevice::ReadOnly);
+ const QString schemaText(QString::fromUtf8(schemaFile.readAll()));
+ schemaView->setPlainText(schemaText);
+
+ validate();
+}
+//! [1]
+
+//! [2]
+void MainWindow::instanceSelected(int index)
+{
+ QFile instanceFile(QString(":/instance_%1.xml").arg((2*schemaSelection->currentIndex()) + index));
+ instanceFile.open(QIODevice::ReadOnly);
+ const QString instanceText(QString::fromUtf8(instanceFile.readAll()));
+ instanceEdit->setPlainText(instanceText);
+
+ validate();
+}
+//! [2]
+
+//! [3]
+void MainWindow::validate()
+{
+ const QByteArray schemaData = schemaView->toPlainText().toUtf8();
+ const QByteArray instanceData = instanceEdit->toPlainText().toUtf8();
+
+ MessageHandler messageHandler;
+
+ QXmlSchema schema;
+ schema.setMessageHandler(&messageHandler);
+
+ schema.load(schemaData);
+
+ bool errorOccurred = false;
+ if (!schema.isValid()) {
+ errorOccurred = true;
+ } else {
+ QXmlSchemaValidator validator(schema);
+ if (!validator.validate(instanceData))
+ errorOccurred = true;
+ }
+
+ if (errorOccurred) {
+ validationStatus->setText(messageHandler.statusMessage());
+ moveCursor(messageHandler.line(), messageHandler.column());
+ } else {
+ validationStatus->setText(tr("validation successful"));
+ }
+
+ const QString styleSheet = QString("QLabel {background: %1; padding: 3px}")
+ .arg(errorOccurred ? QColor(Qt::red).lighter(160).name() :
+ QColor(Qt::green).lighter(160).name());
+ validationStatus->setStyleSheet(styleSheet);
+}
+//! [3]
+
+void MainWindow::textChanged()
+{
+ instanceEdit->setExtraSelections(QList<QTextEdit::ExtraSelection>());
+}
+
+void MainWindow::moveCursor(int line, int column)
+{
+ instanceEdit->moveCursor(QTextCursor::Start);
+ for (int i = 1; i < line; ++i)
+ instanceEdit->moveCursor(QTextCursor::Down);
+
+ for (int i = 1; i < column; ++i)
+ instanceEdit->moveCursor(QTextCursor::Right);
+
+ QList<QTextEdit::ExtraSelection> extraSelections;
+ QTextEdit::ExtraSelection selection;
+
+ const QColor lineColor = QColor(Qt::red).lighter(160);
+ selection.format.setBackground(lineColor);
+ selection.format.setProperty(QTextFormat::FullWidthSelection, true);
+ selection.cursor = instanceEdit->textCursor();
+ selection.cursor.clearSelection();
+ extraSelections.append(selection);
+
+ instanceEdit->setExtraSelections(extraSelections);
+
+ instanceEdit->setFocus();
+}
diff --git a/examples/xmlpatterns/schema/mainwindow.h b/examples/xmlpatterns/schema/mainwindow.h
new file mode 100644
index 0000000..2bec81d
--- /dev/null
+++ b/examples/xmlpatterns/schema/mainwindow.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+#include "ui_schema.h"
+
+//! [0]
+class MainWindow : public QMainWindow,
+ private Ui::SchemaMainWindow
+{
+ Q_OBJECT
+
+ public:
+ MainWindow();
+
+ private Q_SLOTS:
+ void schemaSelected(int index);
+ void instanceSelected(int index);
+ void validate();
+ void textChanged();
+
+ private:
+ void moveCursor(int line, int column);
+};
+//! [0]
+#endif
diff --git a/examples/xmlpatterns/schema/schema.pro b/examples/xmlpatterns/schema/schema.pro
new file mode 100644
index 0000000..2cca10a
--- /dev/null
+++ b/examples/xmlpatterns/schema/schema.pro
@@ -0,0 +1,16 @@
+QT += xmlpatterns
+FORMS += schema.ui
+HEADERS = mainwindow.h ../shared/xmlsyntaxhighlighter.h
+RESOURCES = schema.qrc
+SOURCES = main.cpp mainwindow.cpp ../shared/xmlsyntaxhighlighter.cpp
+INCLUDEPATH += ../shared/
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtxmlpatterns/xmlpatterns/schema
+sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.xq *.html files
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtxmlpatterns/xmlpatterns/schema
+INSTALLS += target sources
+
+symbian {
+ TARGET.UID3 = 0xA000D7C6
+ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+}
diff --git a/examples/xmlpatterns/schema/schema.qrc b/examples/xmlpatterns/schema/schema.qrc
new file mode 100644
index 0000000..eb7ddfd
--- /dev/null
+++ b/examples/xmlpatterns/schema/schema.qrc
@@ -0,0 +1,13 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file alias="schema_0.xsd">files/contact.xsd</file>
+ <file alias="schema_1.xsd">files/recipe.xsd</file>
+ <file alias="schema_2.xsd">files/order.xsd</file>
+ <file alias="instance_0.xml">files/valid_contact.xml</file>
+ <file alias="instance_1.xml">files/invalid_contact.xml</file>
+ <file alias="instance_2.xml">files/valid_recipe.xml</file>
+ <file alias="instance_3.xml">files/invalid_recipe.xml</file>
+ <file alias="instance_4.xml">files/valid_order.xml</file>
+ <file alias="instance_5.xml">files/invalid_order.xml</file>
+</qresource>
+</RCC>
diff --git a/examples/xmlpatterns/schema/schema.ui b/examples/xmlpatterns/schema/schema.ui
new file mode 100644
index 0000000..b67f444
--- /dev/null
+++ b/examples/xmlpatterns/schema/schema.ui
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SchemaMainWindow</class>
+ <widget class="QMainWindow" name="SchemaMainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>417</width>
+ <height>594</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>XML Schema Validation</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="schemaLabel">
+ <property name="text">
+ <string>XML Schema Document:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2" colspan="2">
+ <widget class="QComboBox" name="schemaSelection"/>
+ </item>
+ <item row="1" column="0" colspan="4">
+ <widget class="QTextBrowser" name="schemaView"/>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QLabel" name="instanceLabel">
+ <property name="text">
+ <string>XML Instance Document:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2" colspan="2">
+ <widget class="QComboBox" name="instanceSelection"/>
+ </item>
+ <item row="3" column="0" colspan="4">
+ <widget class="QTextEdit" name="instanceEdit"/>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Status:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1" colspan="2">
+ <widget class="QLabel" name="validationStatus">
+ <property name="text">
+ <string>not validated</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="3">
+ <widget class="QPushButton" name="validateButton">
+ <property name="text">
+ <string>Validate</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>