summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorQt by Nokia <qt-info@nokia.com>2011-04-27 12:05:43 +0200
committeraxis <qt-info@nokia.com>2011-04-27 12:05:43 +0200
commite1b2c9deb5943faae2b29be6a5c006f75bb73f06 (patch)
treefc79e45367c0a8fc71185e9afc33f7503a58653c /examples
downloadqtxmlpatterns-e1b2c9deb5943faae2b29be6a5c006f75bb73f06.tar.gz
Initial import from the monolithic Qt.
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12
Diffstat (limited to 'examples')
-rw-r--r--examples/examples.pro2
-rw-r--r--examples/xmlpatterns/README38
-rw-r--r--examples/xmlpatterns/filetree/filetree.cpp371
-rw-r--r--examples/xmlpatterns/filetree/filetree.h102
-rw-r--r--examples/xmlpatterns/filetree/filetree.pro17
-rw-r--r--examples/xmlpatterns/filetree/forms/mainwindow.ui200
-rw-r--r--examples/xmlpatterns/filetree/main.cpp53
-rw-r--r--examples/xmlpatterns/filetree/mainwindow.cpp165
-rw-r--r--examples/xmlpatterns/filetree/mainwindow.h72
-rw-r--r--examples/xmlpatterns/filetree/queries.qrc7
-rw-r--r--examples/xmlpatterns/filetree/queries/listCPPFiles.xq19
-rw-r--r--examples/xmlpatterns/filetree/queries/wholeTree.xq1
-rw-r--r--examples/xmlpatterns/recipes/files/allRecipes.xq4
-rw-r--r--examples/xmlpatterns/recipes/files/cookbook.xml62
-rw-r--r--examples/xmlpatterns/recipes/files/liquidIngredientsInSoup.xq5
-rw-r--r--examples/xmlpatterns/recipes/files/mushroomSoup.xq5
-rw-r--r--examples/xmlpatterns/recipes/files/preparationLessThan30.xq9
-rw-r--r--examples/xmlpatterns/recipes/files/preparationTimes.xq5
-rw-r--r--examples/xmlpatterns/recipes/forms/querywidget.ui151
-rw-r--r--examples/xmlpatterns/recipes/main.cpp53
-rw-r--r--examples/xmlpatterns/recipes/querymainwindow.cpp123
-rw-r--r--examples/xmlpatterns/recipes/querymainwindow.h71
-rw-r--r--examples/xmlpatterns/recipes/recipes.pro16
-rw-r--r--examples/xmlpatterns/recipes/recipes.qrc10
-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
-rw-r--r--examples/xmlpatterns/shared/xmlsyntaxhighlighter.cpp105
-rw-r--r--examples/xmlpatterns/shared/xmlsyntaxhighlighter.h71
-rw-r--r--examples/xmlpatterns/trafficinfo/main.cpp53
-rw-r--r--examples/xmlpatterns/trafficinfo/mainwindow.cpp180
-rw-r--r--examples/xmlpatterns/trafficinfo/mainwindow.h76
-rw-r--r--examples/xmlpatterns/trafficinfo/station_example.wml31
-rw-r--r--examples/xmlpatterns/trafficinfo/stationdialog.cpp161
-rw-r--r--examples/xmlpatterns/trafficinfo/stationdialog.h69
-rw-r--r--examples/xmlpatterns/trafficinfo/stationdialog.ui104
-rw-r--r--examples/xmlpatterns/trafficinfo/stationquery.cpp93
-rw-r--r--examples/xmlpatterns/trafficinfo/stationquery.h73
-rw-r--r--examples/xmlpatterns/trafficinfo/time_example.wml56
-rw-r--r--examples/xmlpatterns/trafficinfo/timequery.cpp115
-rw-r--r--examples/xmlpatterns/trafficinfo/timequery.h73
-rw-r--r--examples/xmlpatterns/trafficinfo/trafficinfo.pro14
-rw-r--r--examples/xmlpatterns/xmlpatterns.pro2
-rw-r--r--examples/xmlpatterns/xquery/globalVariables/globalVariables.pro11
-rw-r--r--examples/xmlpatterns/xquery/globalVariables/globals.cpp66
-rw-r--r--examples/xmlpatterns/xquery/globalVariables/globals.gccxml33
-rw-r--r--examples/xmlpatterns/xquery/globalVariables/globals.html40
-rw-r--r--examples/xmlpatterns/xquery/globalVariables/reportGlobals.xq110
-rw-r--r--examples/xmlpatterns/xquery/xquery.pro10
61 files changed, 3712 insertions, 0 deletions
diff --git a/examples/examples.pro b/examples/examples.pro
new file mode 100644
index 0000000..cd32a1b
--- /dev/null
+++ b/examples/examples.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += xmlpatterns
diff --git a/examples/xmlpatterns/README b/examples/xmlpatterns/README
new file mode 100644
index 0000000..5d585dc
--- /dev/null
+++ b/examples/xmlpatterns/README
@@ -0,0 +1,38 @@
+XQuery queries and XPath expressions can be used in Qt with the
+QtXmlPatterns module.
+
+XQuery is a query language used to query XML in a concise and safe manner.
+
+The example launcher provided with Qt can be used to explore each of the
+examples in this directory.
+
+Documentation for these examples can be found via the Tutorial and Examples
+link in the main Qt documentation.
+
+
+Finding the Qt Examples and Demos launcher
+==========================================
+
+On Windows:
+
+The launcher can be accessed via the Windows Start menu. Select the menu
+entry entitled "Qt Examples and Demos" entry in the submenu containing
+the Qt tools.
+
+On Mac OS X:
+
+For the binary distribution, the qtdemo executable is installed in the
+/Developer/Applications/Qt directory. For the source distribution, it is
+installed alongside the other Qt tools on the path specified when Qt is
+configured.
+
+On Unix/Linux:
+
+The qtdemo executable is installed alongside the other Qt tools on the path
+specified when Qt is configured.
+
+On all platforms:
+
+The source code for the launcher can be found in the demos/qtdemo directory
+in the Qt package. This example is built at the same time as the Qt libraries,
+tools, examples, and demonstrations.
diff --git a/examples/xmlpatterns/filetree/filetree.cpp b/examples/xmlpatterns/filetree/filetree.cpp
new file mode 100644
index 0000000..5b90cfb
--- /dev/null
+++ b/examples/xmlpatterns/filetree/filetree.cpp
@@ -0,0 +1,371 @@
+/****************************************************************************
+**
+** 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 <QtCore/QUrl>
+#include <QtCore/QVariant>
+#include <QtXmlPatterns/QXmlNamePool>
+#include "filetree.h"
+
+/*
+The model has two types of nodes: elements & attributes.
+
+ <directory name="">
+ <file name="">
+ </file>
+ </directory>
+
+ In QXmlNodeModelIndex we store two values. QXmlNodeIndex::data()
+ is treated as a signed int, and it is an index into m_fileInfos
+ unless it is -1, in which case it has no meaning and the value
+ of QXmlNodeModelIndex::additionalData() is a Type name instead.
+ */
+
+/*!
+ The constructor passes \a pool to the base class, then loads an
+ internal vector with an instance of QXmlName for each of the
+ strings "file", "directory", "fileName", "filePath", "size",
+ "mimeType", and "suffix".
+ */
+//! [2]
+FileTree::FileTree(const QXmlNamePool& pool)
+ : QSimpleXmlNodeModel(pool),
+ m_filterAllowAll(QDir::AllEntries |
+ QDir::AllDirs |
+ QDir::NoDotAndDotDot |
+ QDir::Hidden),
+ m_sortFlags(QDir::Name)
+{
+ QXmlNamePool np = namePool();
+ m_names.resize(7);
+ m_names[File] = QXmlName(np, QLatin1String("file"));
+ m_names[Directory] = QXmlName(np, QLatin1String("directory"));
+ m_names[AttributeFileName] = QXmlName(np, QLatin1String("fileName"));
+ m_names[AttributeFilePath] = QXmlName(np, QLatin1String("filePath"));
+ m_names[AttributeSize] = QXmlName(np, QLatin1String("size"));
+ m_names[AttributeMIMEType] = QXmlName(np, QLatin1String("mimeType"));
+ m_names[AttributeSuffix] = QXmlName(np, QLatin1String("suffix"));
+}
+//! [2]
+
+/*!
+ Returns the QXmlNodeModelIndex for the model node representing
+ the directory \a dirName.
+
+ It calls QDir::cleanPath(), because an instance of QFileInfo
+ constructed for a path ending in '/' will return the empty string in
+ fileName(), instead of the directory name.
+*/
+QXmlNodeModelIndex FileTree::nodeFor(const QString& dirName) const
+{
+ QFileInfo dirInfo(QDir::cleanPath(dirName));
+ Q_ASSERT(dirInfo.exists());
+ return toNodeIndex(dirInfo);
+}
+
+/*!
+ Since the value will always be in m_fileInfos, it is safe for
+ us to return a const reference to it.
+ */
+//! [6]
+const QFileInfo&
+FileTree::toFileInfo(const QXmlNodeModelIndex &nodeIndex) const
+{
+ return m_fileInfos.at(nodeIndex.data());
+}
+//! [6]
+
+/*!
+ Returns the model node index for the node specified by the
+ QFileInfo and node Type.
+ */
+//! [1]
+QXmlNodeModelIndex
+FileTree::toNodeIndex(const QFileInfo &fileInfo, Type attributeName) const
+{
+ const int indexOf = m_fileInfos.indexOf(fileInfo);
+
+ if (indexOf == -1) {
+ m_fileInfos.append(fileInfo);
+ return createIndex(m_fileInfos.count()-1, attributeName);
+ }
+ else
+ return createIndex(indexOf, attributeName);
+}
+//! [1]
+
+/*!
+ Returns the model node index for the node specified by the
+ QFileInfo, which must be a Type::File or Type::Directory.
+ */
+//! [0]
+QXmlNodeModelIndex FileTree::toNodeIndex(const QFileInfo &fileInfo) const
+{
+ return toNodeIndex(fileInfo, fileInfo.isDir() ? Directory : File);
+}
+//! [0]
+
+/*!
+ This private helper function is only called by nextFromSimpleAxis().
+ It is called whenever nextFromSimpleAxis() is called with an axis
+ parameter of either \c{PreviousSibling} or \c{NextSibling}.
+ */
+//! [5]
+QXmlNodeModelIndex FileTree::nextSibling(const QXmlNodeModelIndex &nodeIndex,
+ const QFileInfo &fileInfo,
+ qint8 offset) const
+{
+ Q_ASSERT(offset == -1 || offset == 1);
+
+ // Get the context node's parent.
+ const QXmlNodeModelIndex parent(nextFromSimpleAxis(Parent, nodeIndex));
+
+ if (parent.isNull())
+ return QXmlNodeModelIndex();
+
+ // Get the parent's child list.
+ const QFileInfo parentFI(toFileInfo(parent));
+ Q_ASSERT(Type(parent.additionalData()) == Directory);
+ const QFileInfoList siblings(QDir(parentFI.absoluteFilePath()).entryInfoList(QStringList(),
+ m_filterAllowAll,
+ m_sortFlags));
+ Q_ASSERT_X(!siblings.isEmpty(), Q_FUNC_INFO, "Can't happen! We started at a child.");
+
+ // Find the index of the child where we started.
+ const int indexOfMe = siblings.indexOf(fileInfo);
+
+ // Apply the offset.
+ const int siblingIndex = indexOfMe + offset;
+ if (siblingIndex < 0 || siblingIndex > siblings.count() - 1)
+ return QXmlNodeModelIndex();
+ else
+ return toNodeIndex(siblings.at(siblingIndex));
+}
+//! [5]
+
+/*!
+ This function is called by the QtXmlPatterns query engine when it
+ wants to move to the next node in the model. It moves along an \a
+ axis, \e from the node specified by \a nodeIndex.
+
+ This function is usually the one that requires the most design and
+ implementation work, because the implementation depends on the
+ perhaps unique structure of your non-XML data.
+
+ There are \l {QAbstractXmlNodeModel::SimpleAxis} {four values} for
+ \a axis that the implementation must handle, but there are really
+ only two axes, i.e., vertical and horizontal. Two of the four values
+ specify direction on the vertical axis (\c{Parent} and
+ \c{FirstChild}), and the other two values specify direction on the
+ horizontal axis (\c{PreviousSibling} and \c{NextSibling}).
+
+ The typical implementation will be a \c switch statement with
+ a case for each of the four \a axis values.
+ */
+//! [4]
+QXmlNodeModelIndex
+FileTree::nextFromSimpleAxis(SimpleAxis axis, const QXmlNodeModelIndex &nodeIndex) const
+{
+ const QFileInfo fi(toFileInfo(nodeIndex));
+ const Type type = Type(nodeIndex.additionalData());
+
+ if (type != File && type != Directory) {
+ Q_ASSERT_X(axis == Parent, Q_FUNC_INFO, "An attribute only has a parent!");
+ return toNodeIndex(fi, Directory);
+ }
+
+ switch (axis) {
+ case Parent:
+ return toNodeIndex(QFileInfo(fi.path()), Directory);
+
+ case FirstChild:
+ {
+ if (type == File) // A file has no children.
+ return QXmlNodeModelIndex();
+ else {
+ Q_ASSERT(type == Directory);
+ Q_ASSERT_X(fi.isDir(), Q_FUNC_INFO, "It isn't really a directory!");
+ const QDir dir(fi.absoluteFilePath());
+ Q_ASSERT(dir.exists());
+
+ const QFileInfoList children(dir.entryInfoList(QStringList(),
+ m_filterAllowAll,
+ m_sortFlags));
+ if (children.isEmpty())
+ return QXmlNodeModelIndex();
+ const QFileInfo firstChild(children.first());
+ return toNodeIndex(firstChild);
+ }
+ }
+
+ case PreviousSibling:
+ return nextSibling(nodeIndex, fi, -1);
+
+ case NextSibling:
+ return nextSibling(nodeIndex, fi, 1);
+ }
+
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Don't ever get here!");
+ return QXmlNodeModelIndex();
+}
+//! [4]
+
+/*!
+ No matter what part of the file system we model (the whole file
+ tree or a subtree), \a node will always have \c{file:///} as
+ the document URI.
+ */
+QUrl FileTree::documentUri(const QXmlNodeModelIndex &node) const
+{
+ Q_UNUSED(node);
+ return QUrl("file:///");
+}
+
+/*!
+ This function returns QXmlNodeModelIndex::Element if \a node
+ is a directory or a file, and QXmlNodeModelIndex::Attribute
+ otherwise.
+ */
+QXmlNodeModelIndex::NodeKind
+FileTree::kind(const QXmlNodeModelIndex &node) const
+{
+ switch (Type(node.additionalData())) {
+ case Directory:
+ case File:
+ return QXmlNodeModelIndex::Element;
+ default:
+ return QXmlNodeModelIndex::Attribute;
+ }
+}
+
+/*!
+ No order is defined for this example, so we always return
+ QXmlNodeModelIndex::Precedes, just to keep everyone happy.
+ */
+QXmlNodeModelIndex::DocumentOrder
+FileTree::compareOrder(const QXmlNodeModelIndex&,
+ const QXmlNodeModelIndex&) const
+{
+ return QXmlNodeModelIndex::Precedes;
+}
+
+/*!
+ Returns the name of \a node. The caller guarantees that \a node is
+ not null and that it is contained in this node model.
+ */
+//! [3]
+QXmlName FileTree::name(const QXmlNodeModelIndex &node) const
+{
+ return m_names.at(node.additionalData());
+}
+//! [3]
+
+/*!
+ Always returns the QXmlNodeModelIndex for the root of the
+ file system, i.e. "/".
+ */
+QXmlNodeModelIndex FileTree::root(const QXmlNodeModelIndex &node) const
+{
+ Q_UNUSED(node);
+ return toNodeIndex(QFileInfo(QLatin1String("/")));
+}
+
+/*!
+ Returns the typed value for \a node, which must be either an
+ attribute or an element. The QVariant returned represents the atomic
+ value of an attribute or the atomic value contained in an element.
+
+ If the QVariant is returned as a default constructed variant,
+ it means that \a node has no typed value.
+ */
+QVariant FileTree::typedValue(const QXmlNodeModelIndex &node) const
+{
+ const QFileInfo &fi = toFileInfo(node);
+
+ switch (Type(node.additionalData())) {
+ case Directory:
+ // deliberate fall through.
+ case File:
+ return QString();
+ case AttributeFileName:
+ return fi.fileName();
+ case AttributeFilePath:
+ return fi.filePath();
+ case AttributeSize:
+ return fi.size();
+ case AttributeMIMEType:
+ {
+ /* We don't have any MIME detection code currently, so return
+ * the most generic one. */
+ return QLatin1String("application/octet-stream");
+ }
+ case AttributeSuffix:
+ return fi.suffix();
+ }
+
+ Q_ASSERT_X(false, Q_FUNC_INFO, "This line should never be reached.");
+ return QString();
+}
+
+/*!
+ Returns the attributes of \a element. The caller guarantees
+ that \a element is an element in this node model.
+ */
+QVector<QXmlNodeModelIndex>
+FileTree::attributes(const QXmlNodeModelIndex &element) const
+{
+ QVector<QXmlNodeModelIndex> result;
+
+ /* Both elements has this attribute. */
+ const QFileInfo &forElement = toFileInfo(element);
+ result.append(toNodeIndex(forElement, AttributeFilePath));
+ result.append(toNodeIndex(forElement, AttributeFileName));
+
+ if (Type(element.additionalData() == File)) {
+ result.append(toNodeIndex(forElement, AttributeSize));
+ result.append(toNodeIndex(forElement, AttributeSuffix));
+ //result.append(toNodeIndex(forElement, AttributeMIMEType));
+ }
+ else {
+ Q_ASSERT(element.additionalData() == Directory);
+ }
+
+ return result;
+}
+
diff --git a/examples/xmlpatterns/filetree/filetree.h b/examples/xmlpatterns/filetree/filetree.h
new file mode 100644
index 0000000..a36b9a4
--- /dev/null
+++ b/examples/xmlpatterns/filetree/filetree.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** 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 <QtCore/QFileInfo>
+#include <QtCore/QDir>
+#include <QtCore/QVector>
+#include <QtXmlPatterns/QSimpleXmlNodeModel>
+
+class FileTree : public QSimpleXmlNodeModel
+{
+ public:
+ FileTree(const QXmlNamePool &namePool);
+
+ QXmlNodeModelIndex nodeFor(const QString &fileName) const;
+
+ //! [0]
+ virtual QXmlNodeModelIndex::DocumentOrder compareOrder(const QXmlNodeModelIndex&, const QXmlNodeModelIndex&) const;
+ virtual QXmlName name(const QXmlNodeModelIndex &node) const;
+ virtual QUrl documentUri(const QXmlNodeModelIndex &node) const;
+ virtual QXmlNodeModelIndex::NodeKind kind(const QXmlNodeModelIndex &node) const;
+ virtual QXmlNodeModelIndex root(const QXmlNodeModelIndex &node) const;
+ virtual QVariant typedValue(const QXmlNodeModelIndex &node) const;
+ //! [0]
+ protected:
+ //! [1]
+ virtual QVector<QXmlNodeModelIndex> attributes(const QXmlNodeModelIndex &element) const;
+ virtual QXmlNodeModelIndex nextFromSimpleAxis(SimpleAxis, const QXmlNodeModelIndex&) const;
+ //! [1]
+
+ private:
+ //! [4]
+ enum Type {
+ File,
+ Directory,
+ AttributeFileName,
+ AttributeFilePath,
+ AttributeSize,
+ AttributeMIMEType,
+ AttributeSuffix
+ };
+ //! [4]
+
+ inline QXmlNodeModelIndex nextSibling(const QXmlNodeModelIndex &nodeIndex,
+ const QFileInfo &from,
+ qint8 offset) const;
+ inline const QFileInfo &toFileInfo(const QXmlNodeModelIndex &index) const;
+ inline QXmlNodeModelIndex toNodeIndex(const QFileInfo &index,
+ Type attributeName) const;
+ inline QXmlNodeModelIndex toNodeIndex(const QFileInfo &index) const;
+
+ /*
+ One possible improvement is to use a hash, and use the &*&value()
+ trick to get a pointer, which would be stored in data() instead
+ of the index.
+ */
+ //! [2]
+ mutable QVector<QFileInfo> m_fileInfos;
+ const QDir::Filters m_filterAllowAll;
+ const QDir::SortFlags m_sortFlags;
+ QVector<QXmlName> m_names;
+ //! [2]
+};
+
+ //! [3]
+ //! [3]
diff --git a/examples/xmlpatterns/filetree/filetree.pro b/examples/xmlpatterns/filetree/filetree.pro
new file mode 100644
index 0000000..8d9c1fa
--- /dev/null
+++ b/examples/xmlpatterns/filetree/filetree.pro
@@ -0,0 +1,17 @@
+SOURCES += main.cpp filetree.cpp mainwindow.cpp ../shared/xmlsyntaxhighlighter.cpp
+HEADERS += filetree.h mainwindow.h ../shared/xmlsyntaxhighlighter.h
+FORMS += forms/mainwindow.ui
+QT += xmlpatterns
+RESOURCES += queries.qrc
+INCLUDEPATH += ../shared/
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtxmlpatterns/xmlpatterns/filetree
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.xq *.html
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtxmlpatterns/xmlpatterns/filetree
+INSTALLS += target sources
+
+symbian {
+ TARGET.UID3 = 0xA000D7C4
+ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+}
diff --git a/examples/xmlpatterns/filetree/forms/mainwindow.ui b/examples/xmlpatterns/filetree/forms/mainwindow.ui
new file mode 100644
index 0000000..993050f
--- /dev/null
+++ b/examples/xmlpatterns/filetree/forms/mainwindow.ui
@@ -0,0 +1,200 @@
+<ui version="4.0" >
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>910</width>
+ <height>676</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>File Tree</string>
+ </property>
+ <widget class="QWidget" name="centralwidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>29</y>
+ <width>910</width>
+ <height>625</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3" >
+ <item>
+ <widget class="QLabel" name="label" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font" >
+ <font>
+ <italic>true</italic>
+ </font>
+ </property>
+ <property name="text" >
+ <string></string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSplitter" name="splitter_2" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QWidget" name="" >
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+ <widget class="QLabel" name="treeInfo" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="fileTree" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Minimum" hsizetype="Expanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ <property name="html" >
+ <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
+&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;/p>&lt;/body>&lt;/html></string>
+ </property>
+ <property name="acceptRichText" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="" >
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <widget class="QComboBox" name="queryBox" />
+ </item>
+ <item>
+ <widget class="QSplitter" name="splitter" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <widget class="QTextEdit" name="queryEdit" >
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ <property name="html" >
+ <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
+&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;/p>&lt;/body>&lt;/html></string>
+ </property>
+ <property name="acceptRichText" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QTextEdit" name="output" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Minimum" hsizetype="Expanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ <property name="html" >
+ <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
+&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;/p>&lt;/body>&lt;/html></string>
+ </property>
+ <property name="acceptRichText" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ <zorder>label</zorder>
+ <zorder>splitter_2</zorder>
+ <zorder>queryBox</zorder>
+ <zorder>treeInfo</zorder>
+ <zorder>splitter</zorder>
+ </widget>
+ <widget class="QMenuBar" name="menubar" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>910</width>
+ <height>29</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuFile" >
+ <property name="title" >
+ <string>&amp;File</string>
+ </property>
+ <addaction name="actionOpenDirectory" />
+ </widget>
+ <widget class="QMenu" name="menu_Help" >
+ <property name="title" >
+ <string>&amp;Help</string>
+ </property>
+ <addaction name="actionAbout" />
+ </widget>
+ <addaction name="menuFile" />
+ <addaction name="menu_Help" />
+ </widget>
+ <widget class="QStatusBar" name="statusbar" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>654</y>
+ <width>910</width>
+ <height>22</height>
+ </rect>
+ </property>
+ </widget>
+ <action name="actionOpenDirectory" >
+ <property name="text" >
+ <string>Open Directory...</string>
+ </property>
+ <property name="shortcut" >
+ <string>Ctrl+O</string>
+ </property>
+ </action>
+ <action name="actionAbout" >
+ <property name="text" >
+ <string>&amp;About</string>
+ </property>
+ <property name="shortcut" >
+ <string>Ctrl+A</string>
+ </property>
+ </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/xmlpatterns/filetree/main.cpp b/examples/xmlpatterns/filetree/main.cpp
new file mode 100644
index 0000000..939072a
--- /dev/null
+++ b/examples/xmlpatterns/filetree/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/QApplication>
+
+#include "mainwindow.h"
+
+int main(int argc, char **argv)
+{
+ Q_INIT_RESOURCE(queries);
+ QApplication app(argc, argv);
+ MainWindow mainWindow;
+
+ mainWindow.show();
+ return app.exec();
+}
diff --git a/examples/xmlpatterns/filetree/mainwindow.cpp b/examples/xmlpatterns/filetree/mainwindow.cpp
new file mode 100644
index 0000000..43502ce
--- /dev/null
+++ b/examples/xmlpatterns/filetree/mainwindow.cpp
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** 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 <QLibraryInfo>
+#include <QtXmlPatterns>
+
+#include "mainwindow.h"
+#include "xmlsyntaxhighlighter.h"
+
+//! [0]
+MainWindow::MainWindow() : m_fileTree(m_namePool)
+{
+ setupUi(this);
+
+ new XmlSyntaxHighlighter(fileTree->document());
+
+ // Set up the font.
+ {
+ QFont font("Courier",10);
+ font.setFixedPitch(true);
+
+ fileTree->setFont(font);
+ queryEdit->setFont(font);
+ output->setFont(font);
+ }
+
+ const QString dir(QLibraryInfo::location(QLibraryInfo::ExamplesPath) + "/xmlpatterns/filetree");
+ qDebug() << dir;
+
+ if (QDir(dir).exists())
+ loadDirectory(dir);
+ else
+ fileTree->setPlainText(tr("Use the Open menu entry to select a directory."));
+
+ const QStringList queries(QDir(":/queries/", "*.xq").entryList());
+ int len = queries.count();
+
+ for (int i = 0; i < len; ++i)
+ queryBox->addItem(queries.at(i));
+
+}
+//! [0]
+
+//! [2]
+void MainWindow::on_queryBox_currentIndexChanged()
+{
+ QFile queryFile(":/queries/" + queryBox->currentText());
+ queryFile.open(QIODevice::ReadOnly);
+
+ queryEdit->setPlainText(QString::fromLatin1(queryFile.readAll()));
+ evaluateResult();
+}
+//! [2]
+
+//! [3]
+void MainWindow::evaluateResult()
+{
+ if (queryBox->currentText().isEmpty())
+ return;
+
+ QXmlQuery query(m_namePool);
+ query.bindVariable("fileTree", m_fileNode);
+ query.setQuery(QUrl("qrc:/queries/" + queryBox->currentText()));
+
+ QByteArray formatterOutput;
+ QBuffer buffer(&formatterOutput);
+ buffer.open(QIODevice::WriteOnly);
+
+ QXmlFormatter formatter(query, &buffer);
+ query.evaluateTo(&formatter);
+
+ output->setText(QString::fromLatin1(formatterOutput.constData()));
+}
+//! [3]
+
+//! [1]
+void MainWindow::on_actionOpenDirectory_triggered()
+{
+ const QString directoryName = QFileDialog::getExistingDirectory(this);
+ if (!directoryName.isEmpty())
+ loadDirectory(directoryName);
+}
+//! [1]
+
+//! [4]
+//! [5]
+void MainWindow::loadDirectory(const QString &directory)
+{
+ Q_ASSERT(QDir(directory).exists());
+
+ m_fileNode = m_fileTree.nodeFor(directory);
+//! [5]
+
+ QXmlQuery query(m_namePool);
+ query.bindVariable("fileTree", m_fileNode);
+ query.setQuery(QUrl("qrc:/queries/wholeTree.xq"));
+
+ QByteArray output;
+ QBuffer buffer(&output);
+ buffer.open(QIODevice::WriteOnly);
+
+ QXmlFormatter formatter(query, &buffer);
+ query.evaluateTo(&formatter);
+
+ treeInfo->setText(tr("Model of %1 output as XML.").arg(directory));
+ fileTree->setText(QString::fromLatin1(output.constData()));
+ evaluateResult();
+//! [6]
+}
+//! [6]
+//! [4]
+
+void MainWindow::on_actionAbout_triggered()
+{
+ QMessageBox::about(this, tr("About File Tree"),
+ tr("<p>Select <b>File->Open Directory</b> and "
+ "choose a directory. The directory is then "
+ "loaded into the model, and the model is "
+ "displayed on the left as XML.</p>"
+
+ "<p>From the query menu on the right, select "
+ "a query. The query is displayed and then run "
+ "on the model. The results are displayed below "
+ "the query.</p>"));
+}
+
+
diff --git a/examples/xmlpatterns/filetree/mainwindow.h b/examples/xmlpatterns/filetree/mainwindow.h
new file mode 100644
index 0000000..8bf3196
--- /dev/null
+++ b/examples/xmlpatterns/filetree/mainwindow.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** 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 <QFile>
+#include <QMainWindow>
+#include <QXmlNamePool>
+//! [0]
+#include "filetree.h"
+#include "ui_mainwindow.h"
+
+class MainWindow : public QMainWindow, private Ui_MainWindow
+{
+ Q_OBJECT
+
+ public:
+ MainWindow();
+
+ private slots:
+ void on_actionOpenDirectory_triggered();
+ void on_actionAbout_triggered();
+ void on_queryBox_currentIndexChanged();
+
+ private:
+ void loadDirectory(const QString &directory);
+ void evaluateResult();
+
+ const QXmlNamePool m_namePool;
+ const FileTree m_fileTree;
+ QXmlNodeModelIndex m_fileNode;
+};
+//! [0]
+#endif
diff --git a/examples/xmlpatterns/filetree/queries.qrc b/examples/xmlpatterns/filetree/queries.qrc
new file mode 100644
index 0000000..2e48601
--- /dev/null
+++ b/examples/xmlpatterns/filetree/queries.qrc
@@ -0,0 +1,7 @@
+<!DOCTYPE RCC>
+ <RCC version="1.0">
+<qresource>
+ <file>queries/listCPPFiles.xq</file>
+ <file>queries/wholeTree.xq</file>
+</qresource>
+</RCC>
diff --git a/examples/xmlpatterns/filetree/queries/listCPPFiles.xq b/examples/xmlpatterns/filetree/queries/listCPPFiles.xq
new file mode 100644
index 0000000..e311d27
--- /dev/null
+++ b/examples/xmlpatterns/filetree/queries/listCPPFiles.xq
@@ -0,0 +1,19 @@
+declare variable $where as xs:string := string($fileTree/@filePath);
+<html>
+ <head>
+ <title>All cpp files in: {$where}</title>
+ </head>
+ <body>
+ <p>
+ cpp-files found in {$where} sorted by size:
+ </p>
+ <ul> {
+ for $file in $fileTree//file[@suffix = "cpp"]
+ order by xs:integer($file/@size)
+ return
+ <li>
+ {string($file/@fileName)}, size: {string($file/@size)}
+ </li>
+ } </ul>
+ </body>
+</html>
diff --git a/examples/xmlpatterns/filetree/queries/wholeTree.xq b/examples/xmlpatterns/filetree/queries/wholeTree.xq
new file mode 100644
index 0000000..ec2977b
--- /dev/null
+++ b/examples/xmlpatterns/filetree/queries/wholeTree.xq
@@ -0,0 +1 @@
+$fileTree
diff --git a/examples/xmlpatterns/recipes/files/allRecipes.xq b/examples/xmlpatterns/recipes/files/allRecipes.xq
new file mode 100644
index 0000000..6888c31
--- /dev/null
+++ b/examples/xmlpatterns/recipes/files/allRecipes.xq
@@ -0,0 +1,4 @@
+(: Select all recipes. :)
+declare variable $inputDocument external;
+
+doc($inputDocument)/cookbook/recipe/<p>{string(title)}</p>
diff --git a/examples/xmlpatterns/recipes/files/cookbook.xml b/examples/xmlpatterns/recipes/files/cookbook.xml
new file mode 100644
index 0000000..3b6f621
--- /dev/null
+++ b/examples/xmlpatterns/recipes/files/cookbook.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cookbook>
+ <recipe xml:id="MushroomSoup">
+ <title>Quick and Easy Mushroom Soup</title>
+ <ingredient name="Fresh mushrooms"
+ quantity="7"
+ unit="pieces"/>
+ <ingredient name="Garlic"
+ quantity="1"
+ unit="cloves"/>
+ <ingredient name="Olive oil"
+ quantity="2"
+ unit="tablespoons"/>
+ <ingredient name="Milk"
+ quantity="200"
+ unit="milliliters"/>
+ <ingredient name="Water"
+ quantity="200"
+ unit="milliliters"/>
+ <ingredient name="Cream"
+ quantity="100"
+ unit="milliliters"/>
+ <ingredient name="Vegetable soup cube"
+ quantity="1/2"
+ unit="cubes"/>
+ <ingredient name="Ground black pepper"
+ quantity="1/2"
+ unit="teaspoons"/>
+ <ingredient name="Dried parsley"
+ quantity="1"
+ unit="teaspoons"/>
+ <time quantity="20"
+ unit="minutes"/>
+ <method>
+ <step>1. Slice mushrooms and garlic.</step>
+ <step>2. Fry mushroom slices and garlic with olive oil.</step>
+ <step>3. Once mushrooms are cooked, add milk, cream water. Stir.</step>
+ <step>4. Add vegetable soup cube.</step>
+ <step>5. Reduce heat, add pepper and parsley.</step>
+ <step>6. Turn off the stove before the mixture boils.</step>
+ <step>7. Blend the mixture.</step>
+ </method>
+ </recipe>
+ <recipe xml:id="CheeseOnToast">
+ <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>
+</cookbook>
diff --git a/examples/xmlpatterns/recipes/files/liquidIngredientsInSoup.xq b/examples/xmlpatterns/recipes/files/liquidIngredientsInSoup.xq
new file mode 100644
index 0000000..3baecd8
--- /dev/null
+++ b/examples/xmlpatterns/recipes/files/liquidIngredientsInSoup.xq
@@ -0,0 +1,5 @@
+(: All liquid ingredients form Mushroom Soup. :)
+declare variable $inputDocument external;
+
+doc($inputDocument)/cookbook/recipe[@xml:id = "MushroomSoup"]/ingredient[@unit = "milliliters"]/
+<p>{@name, @quantity, @unit}</p>
diff --git a/examples/xmlpatterns/recipes/files/mushroomSoup.xq b/examples/xmlpatterns/recipes/files/mushroomSoup.xq
new file mode 100644
index 0000000..b1fee34
--- /dev/null
+++ b/examples/xmlpatterns/recipes/files/mushroomSoup.xq
@@ -0,0 +1,5 @@
+(: All ingredients for Mushroom Soup. :)
+declare variable $inputDocument external;
+
+doc($inputDocument)/cookbook/recipe[@xml:id = "MushroomSoup"]/ingredient/
+<p>{@name, @quantity}</p>
diff --git a/examples/xmlpatterns/recipes/files/preparationLessThan30.xq b/examples/xmlpatterns/recipes/files/preparationLessThan30.xq
new file mode 100644
index 0000000..d74a4eb
--- /dev/null
+++ b/examples/xmlpatterns/recipes/files/preparationLessThan30.xq
@@ -0,0 +1,9 @@
+(: All recipes taking 10 minutes or less to prepare. :)
+declare variable $inputDocument external;
+
+doc($inputDocument)/cookbook/recipe/time[@unit = "minutes" and xs:integer(@quantity) <= 10]/
+<p>
+ {
+ concat(../title, ' (', @quantity, ' ', @unit, ')')
+ }
+</p>
diff --git a/examples/xmlpatterns/recipes/files/preparationTimes.xq b/examples/xmlpatterns/recipes/files/preparationTimes.xq
new file mode 100644
index 0000000..cb4217f
--- /dev/null
+++ b/examples/xmlpatterns/recipes/files/preparationTimes.xq
@@ -0,0 +1,5 @@
+(: All recipes with preparation times. :)
+declare variable $inputDocument external;
+
+doc($inputDocument)/cookbook/recipe/
+<recipe title="{title}" time="{time/@quantity} {time/@unit}"/>
diff --git a/examples/xmlpatterns/recipes/forms/querywidget.ui b/examples/xmlpatterns/recipes/forms/querywidget.ui
new file mode 100644
index 0000000..fb2ab64
--- /dev/null
+++ b/examples/xmlpatterns/recipes/forms/querywidget.ui
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QueryWidget</class>
+ <widget class="QMainWindow" name="QueryWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>570</width>
+ <height>531</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Recipes XQuery Example</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="inputGroupBox">
+ <property name="minimumSize">
+ <size>
+ <width>550</width>
+ <height>120</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Input Document</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
+ <layout class="QVBoxLayout" name="_2">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QTextEdit" name="inputTextEdit">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="queryGroupBox">
+ <property name="minimumSize">
+ <size>
+ <width>550</width>
+ <height>120</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Select your query:</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <item>
+ <widget class="QComboBox" name="defaultQueries"/>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="queryTextEdit">
+ <property name="minimumSize">
+ <size>
+ <width>400</width>
+ <height>60</height>
+ </size>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ <property name="acceptRichText">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="outputGroupBox">
+ <property name="minimumSize">
+ <size>
+ <width>550</width>
+ <height>120</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Output Document</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_6">
+ <item>
+ <layout class="QVBoxLayout" name="_3">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QTextEdit" name="outputTextEdit">
+ <property name="minimumSize">
+ <size>
+ <width>500</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ <property name="acceptRichText">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>570</width>
+ <height>26</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/xmlpatterns/recipes/main.cpp b/examples/xmlpatterns/recipes/main.cpp
new file mode 100644
index 0000000..cf679f5
--- /dev/null
+++ b/examples/xmlpatterns/recipes/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 "querymainwindow.h"
+
+//! [0]
+int main(int argc, char* argv[])
+{
+ Q_INIT_RESOURCE(recipes);
+ QApplication app(argc, argv);
+ QueryMainWindow* const queryWindow = new QueryMainWindow;
+ queryWindow->show();
+ return app.exec();
+}
+//! [0]
diff --git a/examples/xmlpatterns/recipes/querymainwindow.cpp b/examples/xmlpatterns/recipes/querymainwindow.cpp
new file mode 100644
index 0000000..95a8669
--- /dev/null
+++ b/examples/xmlpatterns/recipes/querymainwindow.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** 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 "querymainwindow.h"
+#include "xmlsyntaxhighlighter.h"
+
+//! [0]
+QueryMainWindow::QueryMainWindow() : ui_defaultQueries(0)
+{
+ setupUi(this);
+
+ new XmlSyntaxHighlighter(findChild<QTextEdit*>("inputTextEdit")->document());
+ new XmlSyntaxHighlighter(findChild<QTextEdit*>("outputTextEdit")->document());
+
+ ui_defaultQueries = findChild<QComboBox*>("defaultQueries");
+ QMetaObject::connectSlotsByName(this);
+ connect(ui_defaultQueries, SIGNAL(currentIndexChanged(int)), SLOT(displayQuery(int)));
+
+ loadInputFile();
+ const QStringList queries(QDir(":/files/", "*.xq").entryList());
+ int len = queries.count();
+ for(int i = 0; i < len; ++i)
+ ui_defaultQueries->addItem(queries.at(i));
+}
+//! [0]
+
+
+//! [1]
+void QueryMainWindow::displayQuery(int index)
+{
+ QFile queryFile(QString(":files/") + ui_defaultQueries->itemText(index));
+ queryFile.open(QIODevice::ReadOnly);
+ const QString query(QString::fromLatin1(queryFile.readAll()));
+ findChild<QTextEdit*>("queryTextEdit")->setPlainText(query);
+
+ evaluate(query);
+}
+//! [1]
+
+
+void QueryMainWindow::loadInputFile()
+{
+ QFile forView;
+ forView.setFileName(":/files/cookbook.xml");
+ if (!forView.open(QIODevice::ReadOnly)) {
+ QMessageBox::information(this,
+ tr("Unable to open file"), forView.errorString());
+ return;
+ }
+
+ QTextStream in(&forView);
+ QString inputDocument = in.readAll();
+ findChild<QTextEdit*>("inputTextEdit")->setPlainText(inputDocument);
+}
+
+
+//! [2]
+void QueryMainWindow::evaluate(const QString &str)
+{
+ QFile sourceDocument;
+ sourceDocument.setFileName(":/files/cookbook.xml");
+ sourceDocument.open(QIODevice::ReadOnly);
+
+ QByteArray outArray;
+ QBuffer buffer(&outArray);
+ buffer.open(QIODevice::ReadWrite);
+
+ QXmlQuery query;
+ query.bindVariable("inputDocument", &sourceDocument);
+ query.setQuery(str);
+ if (!query.isValid())
+ return;
+
+ QXmlFormatter formatter(query, &buffer);
+ if (!query.evaluateTo(&formatter))
+ return;
+
+ buffer.close();
+ findChild<QTextEdit*>("outputTextEdit")->setPlainText(QString::fromUtf8(outArray.constData()));
+
+}
+//! [2]
+
diff --git a/examples/xmlpatterns/recipes/querymainwindow.h b/examples/xmlpatterns/recipes/querymainwindow.h
new file mode 100644
index 0000000..675b047
--- /dev/null
+++ b/examples/xmlpatterns/recipes/querymainwindow.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** 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 QUERYMAINWINDOW_H
+#define QUERYMAINWINDOW_H
+
+#include <QMainWindow>
+
+#include "ui_querywidget.h"
+
+QT_BEGIN_NAMESPACE
+class QComboBox;
+QT_END_NAMESPACE
+
+//! [0]
+class QueryMainWindow : public QMainWindow,
+ private Ui::QueryWidget
+{
+ Q_OBJECT
+
+ public:
+ QueryMainWindow();
+
+ public slots:
+ void displayQuery(int index);
+
+ private:
+ QComboBox* ui_defaultQueries;
+
+ void evaluate(const QString &str);
+ void loadInputFile();
+};
+//! [0]
+#endif
diff --git a/examples/xmlpatterns/recipes/recipes.pro b/examples/xmlpatterns/recipes/recipes.pro
new file mode 100644
index 0000000..4c10227
--- /dev/null
+++ b/examples/xmlpatterns/recipes/recipes.pro
@@ -0,0 +1,16 @@
+QT += xmlpatterns
+FORMS += forms/querywidget.ui
+HEADERS = querymainwindow.h ../shared/xmlsyntaxhighlighter.h
+RESOURCES = recipes.qrc
+SOURCES = main.cpp querymainwindow.cpp ../shared/xmlsyntaxhighlighter.cpp
+INCLUDEPATH += ../shared/
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtxmlpatterns/xmlpatterns/recipes
+sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.xq *.html forms files
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtxmlpatterns/xmlpatterns/recipes
+INSTALLS += target sources
+
+symbian {
+ TARGET.UID3 = 0xA000D7C5
+ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+}
diff --git a/examples/xmlpatterns/recipes/recipes.qrc b/examples/xmlpatterns/recipes/recipes.qrc
new file mode 100644
index 0000000..65b6615
--- /dev/null
+++ b/examples/xmlpatterns/recipes/recipes.qrc
@@ -0,0 +1,10 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>files/cookbook.xml</file>
+ <file>files/allRecipes.xq</file>
+ <file>files/liquidIngredientsInSoup.xq</file>
+ <file>files/mushroomSoup.xq</file>
+ <file>files/preparationLessThan30.xq</file>
+ <file>files/preparationTimes.xq</file>
+</qresource>
+</RCC>
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>
diff --git a/examples/xmlpatterns/shared/xmlsyntaxhighlighter.cpp b/examples/xmlpatterns/shared/xmlsyntaxhighlighter.cpp
new file mode 100644
index 0000000..c6bbeff
--- /dev/null
+++ b/examples/xmlpatterns/shared/xmlsyntaxhighlighter.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** 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 "xmlsyntaxhighlighter.h"
+
+XmlSyntaxHighlighter::XmlSyntaxHighlighter(QTextDocument *parent)
+ : QSyntaxHighlighter(parent)
+{
+ HighlightingRule rule;
+
+ // tag format
+ tagFormat.setForeground(Qt::darkBlue);
+ tagFormat.setFontWeight(QFont::Bold);
+ rule.pattern = QRegExp("(<[a-zA-Z:]+\\b|<\\?[a-zA-Z:]+\\b|\\?>|>|/>|</[a-zA-Z:]+>)");
+ rule.format = tagFormat;
+ highlightingRules.append(rule);
+
+ // attribute format
+ attributeFormat.setForeground(Qt::darkGreen);
+ rule.pattern = QRegExp("[a-zA-Z:]+=");
+ rule.format = attributeFormat;
+ highlightingRules.append(rule);
+
+ // attribute content format
+ attributeContentFormat.setForeground(Qt::red);
+ rule.pattern = QRegExp("(\"[^\"]*\"|'[^']*')");
+ rule.format = attributeContentFormat;
+ highlightingRules.append(rule);
+
+ commentFormat.setForeground(Qt::lightGray);
+ commentFormat.setFontItalic(true);
+
+ commentStartExpression = QRegExp("<!--");
+ commentEndExpression = QRegExp("-->");
+}
+
+void XmlSyntaxHighlighter::highlightBlock(const QString &text)
+{
+ foreach (const HighlightingRule &rule, highlightingRules) {
+ QRegExp expression(rule.pattern);
+ int index = text.indexOf(expression);
+ while (index >= 0) {
+ int length = expression.matchedLength();
+ setFormat(index, length, rule.format);
+ index = text.indexOf(expression, index + length);
+ }
+ }
+ setCurrentBlockState(0);
+
+ int startIndex = 0;
+ if (previousBlockState() != 1)
+ startIndex = text.indexOf(commentStartExpression);
+
+ while (startIndex >= 0) {
+ int endIndex = text.indexOf(commentEndExpression, startIndex);
+ int commentLength;
+ if (endIndex == -1) {
+ setCurrentBlockState(1);
+ commentLength = text.length() - startIndex;
+ } else {
+ commentLength = endIndex - startIndex
+ + commentEndExpression.matchedLength();
+ }
+ setFormat(startIndex, commentLength, commentFormat);
+ startIndex = text.indexOf(commentStartExpression,
+ startIndex + commentLength);
+ }
+}
diff --git a/examples/xmlpatterns/shared/xmlsyntaxhighlighter.h b/examples/xmlpatterns/shared/xmlsyntaxhighlighter.h
new file mode 100644
index 0000000..860edd6
--- /dev/null
+++ b/examples/xmlpatterns/shared/xmlsyntaxhighlighter.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** 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 XMLSYNTAXHIGHLIGHTER_H
+#define XMLSYNTAXHIGHLIGHTER_H
+
+#include <QtGui/QSyntaxHighlighter>
+
+class XmlSyntaxHighlighter : public QSyntaxHighlighter
+{
+ public:
+ XmlSyntaxHighlighter(QTextDocument *parent = 0);
+
+ protected:
+ virtual void highlightBlock(const QString &text);
+
+ private:
+ struct HighlightingRule
+ {
+ QRegExp pattern;
+ QTextCharFormat format;
+ };
+ QVector<HighlightingRule> highlightingRules;
+
+ QRegExp commentStartExpression;
+ QRegExp commentEndExpression;
+
+ QTextCharFormat tagFormat;
+ QTextCharFormat attributeFormat;
+ QTextCharFormat attributeContentFormat;
+ QTextCharFormat commentFormat;
+};
+
+#endif
diff --git a/examples/xmlpatterns/trafficinfo/main.cpp b/examples/xmlpatterns/trafficinfo/main.cpp
new file mode 100644
index 0000000..95acca5
--- /dev/null
+++ b/examples/xmlpatterns/trafficinfo/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 "mainwindow.h"
+
+#include <QtGui/QApplication>
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ MainWindow window;
+ window.show();
+
+ return app.exec();
+}
diff --git a/examples/xmlpatterns/trafficinfo/mainwindow.cpp b/examples/xmlpatterns/trafficinfo/mainwindow.cpp
new file mode 100644
index 0000000..72a561c
--- /dev/null
+++ b/examples/xmlpatterns/trafficinfo/mainwindow.cpp
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** 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 "mainwindow.h"
+#include "stationdialog.h"
+
+#include <QtCore/QSettings>
+#include <QtCore/QTimer>
+#include <QtGui/QAction>
+#include <QtGui/QApplication>
+#include <QtGui/QBitmap>
+#include <QtGui/QLinearGradient>
+#include <QtGui/QMouseEvent>
+#include <QtGui/QPainter>
+
+MainWindow::MainWindow()
+ : QWidget(0, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
+{
+ QAction *quitAction = new QAction(tr("E&xit"), this);
+ quitAction->setShortcuts(QKeySequence::Quit);
+ connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+
+ QAction *configAction = new QAction(tr("&Select station..."), this);
+ configAction->setShortcut(tr("Ctrl+C"));
+ connect(configAction, SIGNAL(triggered()), this, SLOT(configure()));
+
+ addAction(configAction);
+ addAction(quitAction);
+
+ setContextMenuPolicy(Qt::ActionsContextMenu);
+
+ setWindowTitle(tr("Traffic Info Oslo"));
+
+ const QSettings settings("Qt Traffic Info", "trafficinfo");
+ m_station = StationInformation(settings.value("stationId", "03012130").toString(),
+ settings.value("stationName", "Nydalen [T-bane] (OSL)").toString());
+ m_lines = settings.value("lines", QStringList()).toStringList();
+
+ QTimer *timer = new QTimer(this);
+ connect(timer, SIGNAL(timeout()), this, SLOT(updateTimeInformation()));
+ timer->start(1000*60*5);
+ QMetaObject::invokeMethod(this, SLOT(updateTimeInformation()), Qt::QueuedConnection);
+}
+
+MainWindow::~MainWindow()
+{
+ QSettings settings("Qt Traffic Info", "trafficinfo");
+ settings.setValue("stationId", m_station.id());
+ settings.setValue("stationName", m_station.name());
+ settings.setValue("lines", m_lines);
+}
+
+QSize MainWindow::sizeHint() const
+{
+ return QSize(300, 200);
+}
+
+void MainWindow::mouseMoveEvent(QMouseEvent *event)
+{
+ if (event->buttons() & Qt::LeftButton) {
+ move(event->globalPos() - m_dragPosition);
+ event->accept();
+ }
+}
+
+void MainWindow::mousePressEvent(QMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton) {
+ m_dragPosition = event->globalPos() - frameGeometry().topLeft();
+ event->accept();
+ }
+}
+
+void MainWindow::paintEvent(QPaintEvent*)
+{
+ const QPoint start(width()/2, 0);
+ const QPoint finalStop(width()/2, height());
+ QLinearGradient gradient(start, finalStop);
+ const QColor qtGreen(102, 176, 54);
+ gradient.setColorAt(0, qtGreen.dark());
+ gradient.setColorAt(0.5, qtGreen);
+ gradient.setColorAt(1, qtGreen.dark());
+
+ QPainter p(this);
+ p.fillRect(0, 0, width(), height(), gradient);
+
+ QFont headerFont("Sans Serif", 12, QFont::Bold);
+ QFont normalFont("Sans Serif", 9, QFont::Normal);
+
+ // draw it twice for shadow effect
+ p.setFont(headerFont);
+ QRect headerRect(1, 1, width(), 25);
+ p.setPen(Qt::black);
+ p.drawText(headerRect, Qt::AlignCenter, m_station.name());
+
+ headerRect.moveTopLeft(QPoint(0, 0));
+ p.setPen(Qt::white);
+ p.drawText(headerRect, Qt::AlignCenter, m_station.name());
+
+ p.setFont(normalFont);
+ int pos = 40;
+ for (int i = 0; i < m_times.count() && i < 9; ++i) {
+ p.setPen(Qt::black);
+ p.drawText(51, pos + 1, m_times.at(i).time());
+ p.drawText(101, pos + 1, m_times.at(i).direction());
+
+ p.setPen(Qt::white);
+ p.drawText(50, pos, m_times.at(i).time());
+ p.drawText(100, pos, m_times.at(i).direction());
+
+ pos += 18;
+ }
+}
+
+void MainWindow::resizeEvent(QResizeEvent*)
+{
+ QBitmap maskBitmap(width(), height());
+ maskBitmap.clear();
+
+ QPainter p(&maskBitmap);
+ p.setBrush(Qt::black);
+ p.drawRoundRect(0, 0, width(), height(), 20, 30);
+ p.end();
+
+ setMask(maskBitmap);
+}
+
+void MainWindow::updateTimeInformation()
+{
+ m_times = TimeQuery::query(m_station.id(), m_lines, QDateTime::currentDateTime());
+
+ update();
+}
+
+void MainWindow::configure()
+{
+ StationDialog dlg(m_station.name(), m_lines, this);
+ if (dlg.exec()) {
+ m_station = dlg.selectedStation();
+ m_lines = dlg.lineNumbers();
+ updateTimeInformation();
+ }
+}
diff --git a/examples/xmlpatterns/trafficinfo/mainwindow.h b/examples/xmlpatterns/trafficinfo/mainwindow.h
new file mode 100644
index 0000000..800131e
--- /dev/null
+++ b/examples/xmlpatterns/trafficinfo/mainwindow.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** 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 "stationquery.h"
+#include "timequery.h"
+
+#include <QtGui/QWidget>
+
+class MainWindow : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ MainWindow();
+ ~MainWindow();
+
+ QSize sizeHint() const;
+
+ protected:
+ void mouseMoveEvent(QMouseEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void paintEvent(QPaintEvent *event);
+ void resizeEvent(QResizeEvent *event);
+
+ private Q_SLOTS:
+ void updateTimeInformation();
+ void configure();
+
+ private:
+ QPoint m_dragPosition;
+ TimeInformation::List m_times;
+ StationInformation m_station;
+ QStringList m_lines;
+};
+
+#endif
diff --git a/examples/xmlpatterns/trafficinfo/station_example.wml b/examples/xmlpatterns/trafficinfo/station_example.wml
new file mode 100644
index 0000000..da7f82f
--- /dev/null
+++ b/examples/xmlpatterns/trafficinfo/station_example.wml
@@ -0,0 +1,31 @@
+//! [0]
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
+<wml>
+<template>
+ <do type="prev" name="b" label="Tilbake"><prev/></do>
+ <do type="options" label="Nytt søk"><go href="velkommen.wml"/></do>
+</template>
+<card id="Liste" title="Trafikanten">
+<p>
+<small>
+Velg stoppsted: <br />
+
+ <a title="Velg" href="DateLink.asp?fra=05280320">Nydalen (Østre Toten) (Ø-T)</a><br />
+
+ <a title="Velg" href="DateLink.asp?fra=03012126">Nydalen st. (i Store ringvei) (OSL)</a><br />
+
+ <a title="Velg" href="DateLink.asp?fra=03012131">Nydalen T [buss] (OSL)</a><br />
+
+ <a title="Velg" href="DateLink.asp?fra=03012130">Nydalen [T-bane] (OSL)</a><br />
+
+ <a title="Velg" href="DateLink.asp?fra=03012125">Nydalen [tog] (OSL)</a><br />
+
+<br/>
+<a title="Nytt søk" href="Velkommen.wml">"Nytt søk"</a>
+<br/>
+</small>
+</p>
+</card>
+</wml>
+//! [0]
diff --git a/examples/xmlpatterns/trafficinfo/stationdialog.cpp b/examples/xmlpatterns/trafficinfo/stationdialog.cpp
new file mode 100644
index 0000000..3d3ebc7
--- /dev/null
+++ b/examples/xmlpatterns/trafficinfo/stationdialog.cpp
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** 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 "stationdialog.h"
+#include "ui_stationdialog.h"
+
+#include <QtCore/QAbstractListModel>
+
+class StationModel : public QAbstractListModel
+{
+ public:
+ enum Role
+ {
+ StationIdRole = Qt::UserRole + 1,
+ StationNameRole
+ };
+
+ StationModel(QObject *parent = 0)
+ : QAbstractListModel(parent)
+ {
+ }
+
+ void setStations(const StationInformation::List &list)
+ {
+ m_stations = list;
+ layoutChanged();
+ }
+
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const
+ {
+ if (!parent.isValid())
+ return m_stations.count();
+ else
+ return 0;
+ }
+
+ virtual int columnCount(const QModelIndex &parent = QModelIndex()) const
+ {
+ if (!parent.isValid())
+ return 1;
+ else
+ return 0;
+ }
+
+ virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const
+ {
+ if (!index.isValid())
+ return QVariant();
+
+ if (index.column() > 1 || index.row() >= m_stations.count())
+ return QVariant();
+
+ const StationInformation info = m_stations.at(index.row());
+ if (role == Qt::DisplayRole || role == StationNameRole)
+ return info.name();
+ else if (role == StationIdRole)
+ return info.id();
+
+ return QVariant();
+ }
+
+ private:
+ StationInformation::List m_stations;
+};
+
+StationDialog::StationDialog(const QString &name, const QStringList &lineNumbers, QWidget *parent)
+ : QDialog(parent)
+{
+ m_ui.setupUi(this);
+
+ connect(m_ui.m_searchButton, SIGNAL(clicked()), this, SLOT(searchStations()));
+
+ m_ui.m_searchButton->setDefault(true);
+ m_ui.m_input->setText(name);
+
+ m_model = new StationModel(this);
+ m_ui.m_view->setModel(m_model);
+
+ for (int i = 0; i < lineNumbers.count(); ++i) {
+ if (i == 0)
+ m_ui.m_line1->setText(lineNumbers.at(i));
+ else if (i == 1)
+ m_ui.m_line2->setText(lineNumbers.at(i));
+ else if (i == 2)
+ m_ui.m_line3->setText(lineNumbers.at(i));
+ else if (i == 3)
+ m_ui.m_line4->setText(lineNumbers.at(i));
+ }
+
+ QMetaObject::invokeMethod(this, SLOT(searchStations()), Qt::QueuedConnection);
+}
+
+StationInformation StationDialog::selectedStation() const
+{
+ const QModelIndex index = m_ui.m_view->currentIndex();
+
+ if (!index.isValid())
+ return StationInformation();
+
+ return StationInformation(index.data(StationModel::StationIdRole).toString(),
+ index.data(StationModel::StationNameRole).toString());
+}
+
+QStringList StationDialog::lineNumbers() const
+{
+ QStringList lines;
+
+ if (!m_ui.m_line1->text().simplified().isEmpty())
+ lines.append(m_ui.m_line1->text().simplified());
+ if (!m_ui.m_line2->text().simplified().isEmpty())
+ lines.append(m_ui.m_line2->text().simplified());
+ if (!m_ui.m_line3->text().simplified().isEmpty())
+ lines.append(m_ui.m_line3->text().simplified());
+ if (!m_ui.m_line4->text().simplified().isEmpty())
+ lines.append(m_ui.m_line4->text().simplified());
+
+ return lines;
+}
+
+void StationDialog::searchStations()
+{
+ m_model->setStations(StationQuery::query(m_ui.m_input->text()));
+ m_ui.m_view->keyboardSearch(m_ui.m_input->text());
+}
diff --git a/examples/xmlpatterns/trafficinfo/stationdialog.h b/examples/xmlpatterns/trafficinfo/stationdialog.h
new file mode 100644
index 0000000..81a73e8
--- /dev/null
+++ b/examples/xmlpatterns/trafficinfo/stationdialog.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** 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 STATIONDIALOG_H
+#define STATIONDIALOG_H
+
+#include <QtGui/QDialog>
+
+#include "stationquery.h"
+#include "ui_stationdialog.h"
+
+class StationModel;
+
+class StationDialog : public QDialog
+{
+ Q_OBJECT
+
+ public:
+ StationDialog(const QString &id, const QStringList &lineNumbers, QWidget *parent);
+
+ StationInformation selectedStation() const;
+ QStringList lineNumbers() const;
+
+ private Q_SLOTS:
+ void searchStations();
+
+ private:
+ Ui_StationDialog m_ui;
+ StationModel *m_model;
+};
+
+#endif
diff --git a/examples/xmlpatterns/trafficinfo/stationdialog.ui b/examples/xmlpatterns/trafficinfo/stationdialog.ui
new file mode 100644
index 0000000..254dedb
--- /dev/null
+++ b/examples/xmlpatterns/trafficinfo/stationdialog.ui
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>StationDialog</class>
+ <widget class="QDialog" name="StationDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>462</width>
+ <height>391</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Select Station</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLineEdit" name="m_input"/>
+ </item>
+ <item row="0" column="1">
+ <widget class="QPushButton" name="m_searchButton">
+ <property name="text">
+ <string>Search</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QListView" name="m_view"/>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Lines:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="m_line1"/>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="m_line2"/>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="m_line3"/>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="m_line4"/>
+ </item>
+ </layout>
+ </item>
+ <item row="3" column="0" colspan="2">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>StationDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>228</x>
+ <y>373</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>StationDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>296</x>
+ <y>372</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/examples/xmlpatterns/trafficinfo/stationquery.cpp b/examples/xmlpatterns/trafficinfo/stationquery.cpp
new file mode 100644
index 0000000..6575bbf
--- /dev/null
+++ b/examples/xmlpatterns/trafficinfo/stationquery.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** 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 "stationquery.h"
+
+#include <QtCore/QStringList>
+#include <QtXmlPatterns/QXmlQuery>
+
+StationInformation::StationInformation()
+{
+}
+
+StationInformation::StationInformation(const QString &id, const QString &name)
+ : m_id(id), m_name(name)
+{
+}
+
+QString StationInformation::id() const
+{
+ return m_id;
+}
+
+QString StationInformation::name() const
+{
+ return m_name;
+}
+
+//! [0]
+StationInformation::List StationQuery::query(const QString &name)
+{
+ const QString stationIdQueryUrl = QString("doc(concat('http://wap.trafikanten.no/FromLink1.asp?fra=', $station))/wml/card/p/small/a[@title='Velg']/substring(@href,18)");
+ const QString stationNameQueryUrl = QString("doc(concat('http://wap.trafikanten.no/FromLink1.asp?fra=', $station))/wml/card/p/small/a[@title='Velg']/string()");
+
+ QStringList stationIds;
+ QStringList stationNames;
+
+ QXmlQuery query;
+
+ query.bindVariable("station", QVariant(QString::fromLatin1(QUrl::toPercentEncoding(name))));
+ query.setQuery(stationIdQueryUrl);
+ query.evaluateTo(&stationIds);
+
+ query.bindVariable("station", QVariant(QString::fromLatin1(QUrl::toPercentEncoding(name))));
+ query.setQuery(stationNameQueryUrl);
+ query.evaluateTo(&stationNames);
+
+ if (stationIds.count() != stationNames.count()) // something went wrong...
+ return StationInformation::List();
+
+ StationInformation::List information;
+ for (int i = 0; i < stationIds.count(); ++i)
+ information.append(StationInformation(stationIds.at(i), stationNames.at(i)));
+
+ return information;
+}
+//! [0]
diff --git a/examples/xmlpatterns/trafficinfo/stationquery.h b/examples/xmlpatterns/trafficinfo/stationquery.h
new file mode 100644
index 0000000..6b60e5e
--- /dev/null
+++ b/examples/xmlpatterns/trafficinfo/stationquery.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** 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 STATIONQUERY_H
+#define STATIONQUERY_H
+
+#include <QtCore/QList>
+#include <QtCore/QString>
+
+//! [0]
+class StationInformation
+{
+ public:
+ typedef QList<StationInformation> List;
+
+ StationInformation();
+ StationInformation(const QString &id, const QString &name);
+
+ QString id() const;
+ QString name() const;
+
+ private:
+ QString m_id;
+ QString m_name;
+};
+//! [0]
+
+//! [1]
+class StationQuery
+{
+ public:
+ static StationInformation::List query(const QString &name);
+};
+//! [1]
+
+#endif
diff --git a/examples/xmlpatterns/trafficinfo/time_example.wml b/examples/xmlpatterns/trafficinfo/time_example.wml
new file mode 100644
index 0000000..75e3408
--- /dev/null
+++ b/examples/xmlpatterns/trafficinfo/time_example.wml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
+<wml>
+<template>
+ <do type="prev" name="b" label="Tilbake"><prev/></do>
+ <do type="options" name="n" label="Nytt søk"><go href="velkommen.wml"/></do>
+</template>
+<card id="Liste" title="Trafikanten">
+<p>
+<small>
+Fra Nydalen [T-bane]:<br />
+
+ <a href="Rute.asp?d=3011030&amp;t=21832&amp;l=4&amp;Start=1">13.00</a>
+ 4 Bergkrystallen [T-bane]<br />
+
+ <a href="Rute.asp?d=3012585&amp;t=22543&amp;l=6&amp;Start=1">13.05</a>
+ 6 Åsjordet<br />
+
+ <a href="Rute.asp?d=3011730&amp;t=22264&amp;l=5&amp;Start=1">13.09</a>
+ 5 Vestli [T-bane]<br />
+
+ <a href="Rute.asp?d=3012120&amp;t=22080&amp;l=5&amp;Start=1">13.13</a>
+ 5 Storo [T-bane]<br />
+
+ <a href="Rute.asp?d=3011030&amp;t=21831&amp;l=4&amp;Start=1">13.15</a>
+ 4 Bergkrystallen [T-bane]<br />
+
+ <a href="Rute.asp?d=3012585&amp;t=22542&amp;l=6&amp;Start=1">13.20</a>
+ 6 Åsjordet<br />
+
+ <a href="Rute.asp?d=3011730&amp;t=22263&amp;l=5&amp;Start=1">13.24</a>
+ 5 Vestli [T-bane]<br />
+
+ <a href="Rute.asp?d=3012120&amp;t=22079&amp;l=5&amp;Start=1">13.28</a>
+ 5 Storo [T-bane]<br />
+
+ <a href="Rute.asp?d=3011030&amp;t=21830&amp;l=4&amp;Start=1">13.30</a>
+ 4 Bergkrystallen [T-bane]<br />
+
+ <a href="Rute.asp?d=3012585&amp;t=22541&amp;l=6&amp;Start=1">13.35</a>
+ 6 Åsjordet<br />
+
+ <br />
+ <a title="Neste 10" href="F.asp?f=03012130&amp;t=13&amp;m=35&amp;d=14.11.2008&amp;Start=11">Neste 10 avganger</a>
+
+<br/>
+<a href="F.asp?f=03012130&amp;t=14&amp;d=14.11.2008&amp;Start=1">Neste timeintervall</a>
+<br/>
+<a href="F.asp?f=03012130&amp;t=12&amp;d=14.11.2008&amp;Start=1">Forrige timeintervall</a>
+<br/>
+<a href="Velkommen.wml">"Nytt søk"</a>
+<br/>
+</small>
+</p>
+</card>
+</wml>
diff --git a/examples/xmlpatterns/trafficinfo/timequery.cpp b/examples/xmlpatterns/trafficinfo/timequery.cpp
new file mode 100644
index 0000000..eaefaf7
--- /dev/null
+++ b/examples/xmlpatterns/trafficinfo/timequery.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** 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 "timequery.h"
+
+#include <QtCore/QStringList>
+#include <QtXmlPatterns/QXmlQuery>
+
+TimeInformation::TimeInformation(const QString &time, const QString &direction)
+ : m_time(time), m_direction(direction)
+{
+}
+
+QString TimeInformation::time() const
+{
+ return m_time;
+}
+
+QString TimeInformation::direction() const
+{
+ return m_direction;
+}
+
+TimeInformation::List TimeQuery::query(const QString &stationId, const QStringList &lineNumbers, const QDateTime &dateTime)
+{
+ const TimeInformation::List information = queryInternal(stationId, dateTime);
+
+ TimeInformation::List filteredInformation;
+
+ if (!lineNumbers.isEmpty()) {
+ for (int i = 0; i < information.count(); ++i) {
+ const TimeInformation info = information.at(i);
+ for (int j = 0; j < lineNumbers.count(); ++j) {
+ if (info.direction().startsWith(QString("%1 ").arg(lineNumbers.at(j))))
+ filteredInformation.append(info);
+ }
+ }
+ } else {
+ filteredInformation = information;
+ }
+
+ return filteredInformation;
+}
+
+//! [1]
+TimeInformation::List TimeQuery::queryInternal(const QString &stationId, const QDateTime &dateTime)
+{
+ const QString timesQueryUrl = QString("doc('http://wap.trafikanten.no/F.asp?f=%1&amp;t=%2&amp;m=%3&amp;d=%4&amp;start=1')/wml/card/p/small/a[fn:starts-with(@href, 'Rute')]/string()")
+ .arg(stationId)
+ .arg(dateTime.time().hour())
+ .arg(dateTime.time().minute())
+ .arg(dateTime.toString("dd.MM.yyyy"));
+ const QString directionsQueryUrl = QString("doc('http://wap.trafikanten.no/F.asp?f=%1&amp;t=%2&amp;m=%3&amp;d=%4&amp;start=1')/wml/card/p/small/text()[matches(., '[0-9].*')]/string()")
+ .arg(stationId)
+ .arg(dateTime.time().hour())
+ .arg(dateTime.time().minute())
+ .arg(dateTime.toString("dd.MM.yyyy"));
+
+ QStringList times;
+ QStringList directions;
+
+ QXmlQuery query;
+ query.setQuery(timesQueryUrl);
+ query.evaluateTo(&times);
+
+ query.setQuery(directionsQueryUrl);
+ query.evaluateTo(&directions);
+
+ if (times.count() != directions.count()) // something went wrong...
+ return TimeInformation::List();
+
+ TimeInformation::List information;
+ for (int i = 0; i < times.count(); ++i)
+ information.append(TimeInformation(times.at(i).simplified(), directions.at(i).simplified()));
+
+ return information;
+}
+//! [1]
diff --git a/examples/xmlpatterns/trafficinfo/timequery.h b/examples/xmlpatterns/trafficinfo/timequery.h
new file mode 100644
index 0000000..5ff6346
--- /dev/null
+++ b/examples/xmlpatterns/trafficinfo/timequery.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** 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 TIMEQUERY_H
+#define TIMEQUERY_H
+
+#include <QtCore/QDateTime>
+#include <QtCore/QList>
+#include <QtCore/QStringList>
+
+class TimeInformation
+{
+ public:
+ typedef QList<TimeInformation> List;
+
+ TimeInformation(const QString &time, const QString &direction);
+
+ QString time() const;
+ QString direction() const;
+
+ private:
+ QString m_time;
+ QString m_direction;
+};
+
+
+class TimeQuery
+{
+ public:
+ static TimeInformation::List query(const QString &stationId, const QStringList &lineNumbers, const QDateTime &dateTime);
+
+ private:
+ static TimeInformation::List queryInternal(const QString &stationId, const QDateTime &dateTime);
+};
+
+#endif
diff --git a/examples/xmlpatterns/trafficinfo/trafficinfo.pro b/examples/xmlpatterns/trafficinfo/trafficinfo.pro
new file mode 100644
index 0000000..836927f
--- /dev/null
+++ b/examples/xmlpatterns/trafficinfo/trafficinfo.pro
@@ -0,0 +1,14 @@
+QT += xmlpatterns
+HEADERS = mainwindow.h stationdialog.h stationquery.h timequery.h
+SOURCES = main.cpp mainwindow.cpp stationdialog.cpp stationquery.cpp timequery.cpp
+FORMS = stationdialog.ui
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtxmlpatterns/xmlpatterns/trafficinfo
+sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtxmlpatterns/xmlpatterns/trafficinfo
+INSTALLS += target sources
+
+symbian {
+ TARGET.UID3 = 0xA000D7C7
+ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+}
diff --git a/examples/xmlpatterns/xmlpatterns.pro b/examples/xmlpatterns/xmlpatterns.pro
new file mode 100644
index 0000000..e5649f5
--- /dev/null
+++ b/examples/xmlpatterns/xmlpatterns.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += filetree xquery trafficinfo schema recipes
diff --git a/examples/xmlpatterns/xquery/globalVariables/globalVariables.pro b/examples/xmlpatterns/xquery/globalVariables/globalVariables.pro
new file mode 100644
index 0000000..a371c2a
--- /dev/null
+++ b/examples/xmlpatterns/xquery/globalVariables/globalVariables.pro
@@ -0,0 +1,11 @@
+# We don't have any C++ files to build, so in order to trick qmake which
+# doesn't understand that, we use the subdirs template, but without specifying
+# any subdirs.
+TEMPLATE = subdirs
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtxmlpatterns/xmlpatterns/xquery/globalVariables
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.cpp *.pro *.xq *.html globals.gccxml
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtxmlpatterns/xmlpatterns/xquery/globalVariables
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/xmlpatterns/xquery/globalVariables/globals.cpp b/examples/xmlpatterns/xquery/globalVariables/globals.cpp
new file mode 100644
index 0000000..8aa1f65
--- /dev/null
+++ b/examples/xmlpatterns/xquery/globalVariables/globals.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+//! [0]
+ 1. int mutablePrimitive1;
+ 2. int mutablePrimitive2;
+ 3. const int constPrimitive1 = 4;
+ 4. const int constPrimitive2 = 3;
+ 5.
+ 6. class ComplexClass
+ 7. {
+ 8. public:
+ 9. ComplexClass();
+10. ComplexClass(const ComplexClass &);
+11. ~ComplexClass();
+12. };
+13.
+14. ComplexClass mutableComplex1;
+15. ComplexClass mutableComplex2;
+16. const ComplexClass constComplex1;
+17. const ComplexClass constComplex2;
+18.
+19. int main()
+20. {
+22. int localVariable;
+23. localVariable = 0;
+24. return localVariable;
+25. }
+//! [0]
diff --git a/examples/xmlpatterns/xquery/globalVariables/globals.gccxml b/examples/xmlpatterns/xquery/globalVariables/globals.gccxml
new file mode 100644
index 0000000..81bcb22
--- /dev/null
+++ b/examples/xmlpatterns/xquery/globalVariables/globals.gccxml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<GCC_XML>
+ <Namespace id="_1" name="::" members="_3 _4 _5 _6 _7 _8 _9 _10 _11 _12 _13 _14 _15 " mangled="_Z2::"/>
+ <Namespace id="_2" name="std" context="_1" members="" mangled="_Z3std"/>
+ <Function id="_3" name="_GLOBAL__D_globals.cppwVRo3a" returns="_16" context="_1" location="f0:14" file="f0" line="14" endline="14"/>
+ <Function id="_4" name="_GLOBAL__I_globals.cppwVRo3a" returns="_16" context="_1" location="f0:14" file="f0" line="14" endline="14"/>
+ <Function id="_5" name="__static_initialization_and_destruction_0" returns="_16" context="_1" mangled="_Z41__static_initialization_and_destruction_0ii" location="f0:23" file="f0" line="23" endline="14">
+ <Argument name="__initialize_p" type="_17"/>
+ <Argument name="__priority" type="_17"/>
+ </Function>
+ <Function id="_6" name="main" returns="_17" context="_1" location="f0:20" file="f0" line="20" endline="24"/>
+ <Variable id="_7" name="constComplex2" type="_11c" context="_1" location="f0:17" file="f0" line="17"/>
+ <Variable id="_8" name="constComplex1" type="_11c" context="_1" location="f0:16" file="f0" line="16"/>
+ <Variable id="_9" name="mutableComplex2" type="_11" context="_1" location="f0:15" file="f0" line="15"/>
+ <Variable id="_10" name="mutableComplex1" type="_11" context="_1" location="f0:14" file="f0" line="14"/>
+ <Class id="_11" name="ComplexClass" context="_1" mangled="12ComplexClass" location="f0:7" file="f0" line="7" members="_19 _20 _21 " bases=""/>
+ <Variable id="_12" name="constPrimitive2" type="_17c" init="3" context="_1" location="f0:4" file="f0" line="4"/>
+ <Variable id="_13" name="constPrimitive1" type="_17c" init="4" context="_1" location="f0:3" file="f0" line="3"/>
+ <Variable id="_14" name="mutablePrimitive2" type="_17" context="_1" location="f0:2" file="f0" line="2"/>
+ <Variable id="_15" name="mutablePrimitive1" type="_17" context="_1" location="f0:1" file="f0" line="1"/>
+ <FundamentalType id="_16" name="void"/>
+ <FundamentalType id="_17" name="int"/>
+ <CvQualifiedType id="_11c" type="_11" const="1"/>
+ <Constructor id="_19" name="ComplexClass" context="_11" mangled="_ZN12ComplexClassC1Ev *INTERNAL* " location="f0:9" file="f0" line="9" extern="1"/>
+ <Constructor id="_20" name="ComplexClass" context="_11" mangled="_ZN12ComplexClassC1ERKS_ *INTERNAL* " location="f0:10" file="f0" line="10" extern="1">
+ <Argument type="_23"/>
+ </Constructor>
+ <Destructor id="_21" name="ComplexClass" context="_11" mangled="_ZN12ComplexClassD1Ev *INTERNAL* " location="f0:11" file="f0" line="11" extern="1">
+ </Destructor>
+ <CvQualifiedType id="_17c" type="_17" const="1"/>
+ <ReferenceType id="_23" type="_11c"/>
+ <File id="f0" name="globals.cpp"/>
+</GCC_XML>
diff --git a/examples/xmlpatterns/xquery/globalVariables/globals.html b/examples/xmlpatterns/xquery/globalVariables/globals.html
new file mode 100644
index 0000000..d8affc8
--- /dev/null
+++ b/examples/xmlpatterns/xquery/globalVariables/globals.html
@@ -0,0 +1,40 @@
+<html xmlns="http://www.w3.org/1999/xhtml/" xml:lang="en" lang="en">
+ <head>
+ <title>Global variables report for globals.gccxml</title>
+ </head>
+ <style type="text/css">
+ .details
+ {
+ text-align: center;
+ font-size: 80%;
+ color: blue
+ }
+ .variableName
+ {
+ font-family: courier;
+ color: blue
+ }
+ </style>
+ <body>
+ <p class="details">Start report: 2008-12-16T13:43:49.65Z</p>
+ <p>Global variables with complex types:</p>
+ <ol>
+ <li>
+ <span class="variableName">mutableComplex1</span> in globals.cpp at line 14</li>
+ <li>
+ <span class="variableName">mutableComplex2</span> in globals.cpp at line 15</li>
+ <li>
+ <span class="variableName">constComplex1</span> in globals.cpp at line 16</li>
+ <li>
+ <span class="variableName">constComplex2</span> in globals.cpp at line 17</li>
+ </ol>
+ <p>Mutable global variables with primitives types:</p>
+ <ol>
+ <li>
+ <span class="variableName">mutablePrimitive1</span> in globals.cpp at line 1</li>
+ <li>
+ <span class="variableName">mutablePrimitive2</span> in globals.cpp at line 2</li>
+ </ol>
+ <p class="details">End report: 2008-12-16T13:43:49.65Z</p>
+ </body>
+</html>
diff --git a/examples/xmlpatterns/xquery/globalVariables/reportGlobals.xq b/examples/xmlpatterns/xquery/globalVariables/reportGlobals.xq
new file mode 100644
index 0000000..026679d
--- /dev/null
+++ b/examples/xmlpatterns/xquery/globalVariables/reportGlobals.xq
@@ -0,0 +1,110 @@
+(:
+ This XQuery loads a GCC-XML file and reports the locations of all
+ global variables in the original C++ source. To run the query,
+ use the command line:
+
+ xmlpatterns reportGlobals.xq -param fileToOpen=globals.gccxml -output globals.html
+
+ "fileToOpen=globals.gccxml" binds the file name "globals.gccxml"
+ to the variable "fileToOpen" declared and used below.
+:)
+
+declare variable $fileToOpen as xs:anyURI external;
+declare variable $inDoc as document-node() := doc($fileToOpen);
+
+(:
+ This function determines whether the typeId is a complex type,
+ e.g. QString. We only check whether it's a class. To be strictly
+ correct, we should check whether the class has a non-synthesized
+ constructor. We accept both mutable and const types.
+:)
+declare function local:isComplexType($typeID as xs:string) as xs:boolean
+{
+ exists($inDoc/GCC_XML/Class[@id = $typeID])
+ or
+ exists($inDoc/GCC_XML/Class[@id = $inDoc/GCC_XML/CvQualifiedType[@id = $typeID]/@type])
+};
+
+(:
+ This function determines whether the typeId is a primitive type.
+:)
+declare function local:isPrimitive($typeId as xs:string) as xs:boolean
+{
+ exists($inDoc/GCC_XML/FundamentalType[@id = $typeId])
+};
+
+(:
+ This function constructs a line for the report. The line contains
+ a variable name, the source file, and the line number.
+:)
+declare function local:location($block as element()) as xs:string
+{
+ concat($inDoc/GCC_XML/File[@id = $block/@file]/@name, " at line ", $block/@line)
+};
+
+(:
+ This function generates the report. Note that it is called once
+ in the <body> element of the <html> output.
+
+ It ignores const variables of simple types but reports all others.
+:)
+declare function local:report() as element()+
+{
+ let $complexVariables as element(Variable)* := $inDoc/GCC_XML/Variable[local:isComplexType(@type)]
+ return if (exists($complexVariables))
+ then (<p xmlns="http://www.w3.org/1999/xhtml/">Global variables with complex types:</p>,
+ <ol xmlns="http://www.w3.org/1999/xhtml/">
+ {
+ (: For each Variable in $complexVariables... :)
+ $complexVariables/<li><span class="variableName">{string(@name)}</span> in {local:location(.)}</li>
+ }
+ </ol>)
+ else <p xmlns="http://www.w3.org/1999/xhtml/">No complex global variables found.</p>
+
+ ,
+
+ let $primitiveVariables as element(Variable)+ := $inDoc/GCC_XML/Variable[local:isPrimitive(@type)]
+ return if (exists($primitiveVariables))
+ then (<p xmlns="http://www.w3.org/1999/xhtml/">Mutable global variables with primitives types:</p>,
+ <ol xmlns="http://www.w3.org/1999/xhtml/">
+ {
+ (: For each Variable in $complexVariables... :)
+ $primitiveVariables/<li><span class="variableName">{string(@name)}</span> in {local:location(.)}</li>
+ }
+ </ol>)
+ else <p xmlns="http://www.w3.org/1999/xhtml/">No mutable primitive global variables found.</p>
+};
+
+(:
+ This is where the <html> report is output. First
+ there is some style stuff, then the <body> element,
+ which contains the call to the \c{local:report()}
+ declared above.
+:)
+<html xmlns="http://www.w3.org/1999/xhtml/" xml:lang="en" lang="en">
+ <head>
+ <title>Global variables report for {$fileToOpen}</title>
+ </head>
+ <style type="text/css">
+ .details
+ {{
+ text-align: left;
+ font-size: 80%;
+ color: blue
+ }}
+ .variableName
+ {{
+ font-family: courier;
+ color: blue
+ }}
+ </style>
+
+ <body>
+ <p class="details">Start report: {current-dateTime()}</p>
+ {
+ local:report()
+ }
+ <p class="details">End report: {current-dateTime()}</p>
+ </body>
+
+</html>
diff --git a/examples/xmlpatterns/xquery/xquery.pro b/examples/xmlpatterns/xquery/xquery.pro
new file mode 100644
index 0000000..7f35295
--- /dev/null
+++ b/examples/xmlpatterns/xquery/xquery.pro
@@ -0,0 +1,10 @@
+TEMPLATE = subdirs
+SUBDIRS += globalVariables
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtxmlpatterns/xmlpatterns/xquery
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS xquery.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtxmlpatterns/xmlpatterns/xquery
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)