1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
46 // This file is not part of the Qt API. It exists purely as an
47 // implementation detail. This header file may change from version to
48 // version without notice, or even be removed.
52 #ifndef Patternist_SequenceReceiver_H
53 #define Patternist_SequenceReceiver_H
55 #include <QSharedData>
57 #include <private/qitem_p.h>
66 * @short A push interface for the XPath Data Model. Similar to SAX's
69 * @ingroup Patternist_xdm
70 * @author Frans Englich <frans.englich@nokia.com>
72 class QAbstractXmlReceiver : public QSharedData
75 typedef QExplicitlySharedDataPointer<QAbstractXmlReceiver> Ptr;
77 inline QAbstractXmlReceiver()
81 virtual ~QAbstractXmlReceiver();
84 * @short Signals the start of an element by name @p name.
86 virtual void startElement(const QXmlName name) = 0;
89 * @short Signals the presence of the namespace declaration @p nb.
91 * This event is received @c after startElement(), as opposed to
92 * SAX, and before any attribute() events.
94 virtual void namespaceBinding(const QXmlName &nb) = 0;
97 * @short Signals the end of the current element.
99 virtual void endElement() = 0;
102 * @short Signals the presence of an attribute node.
104 * This function is guaranteed by the caller to always be
105 * called after a call to startElement() or attribute().
107 * @param name the name of the attribute. Guaranteed to always be
109 * @param value the value of the attribute. Guaranteed to always be
112 virtual void attribute(const QXmlName name,
113 const QString &value) = 0;
115 virtual void processingInstruction(const QXmlName name,
116 const QString &value) = 0;
117 virtual void comment(const QString &value) = 0;
120 * @short Sends an Item to this QAbstractXmlReceiver that may be a QXmlNodeModelIndex or an
123 virtual void item(const Item &item) = 0;
126 * Sends a text node with value @p value. Adjascent text nodes
127 * may be sent. There's no restrictions on @p value, beyond that it
128 * must be valid XML characters. For instance, @p value may contain
131 * @see whitespaceOnly()
133 virtual void characters(const QString &value) = 0;
136 * This function may be called instead of characters() if, and only if,
137 * @p value consists only of whitespace.
139 * The caller gurantees that @p value, is not empty.
141 * By whitespace is meant a sequence of characters that are either
142 * spaces, tabs, or the two new line characters, in any order. In
143 * other words, the whole of Unicode's whitespace category is not
144 * considered whitespace.
146 * However, there's no guarantee or requirement that whitespaceOnly()
147 * is called for text nodes containing whitespace only, characters()
148 * may be called just as well. This is why the default implementation
149 * for whitespaceOnly() calls characters().
153 virtual void whitespaceOnly(const QStringRef &value);
156 * Start of a document node.
158 virtual void startDocument() = 0;
161 * End of a document node.
163 virtual void endDocument() = 0;
167 * Treats @p outputItem as an node and calls the appropriate function,
168 * such as attribute() or comment(), depending on its QXmlNodeModelIndex::NodeKind.
170 * This a helper function sub-classes can use to multi-plex Nodes received
173 * @param outputItem must be a QXmlNodeModelIndex.
175 void sendAsNode(const Item &outputItem);
179 * Call sendAsNode() for each child of @p node. As consistent with the
180 * XPath Data Model, this does not include attribute nodes.
182 template<const QXmlNodeModelIndex::Axis axis>
183 inline void sendFromAxis(const QXmlNodeModelIndex &node);
184 Q_DISABLE_COPY(QAbstractXmlReceiver)