Qt 4.8
qxsdvalidatedxmlnodemodel.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
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.
16 **
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.
24 **
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.
28 **
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.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
43 
44 #include <QtCore/QUrl>
45 #include <QtCore/QVariant>
46 #include <QtCore/QVector>
47 
49 
50 using namespace QPatternist;
51 
53  : m_internalModel(model)
54 {
55 }
56 
58 {
59 }
60 
62 {
63  return m_internalModel->baseUri(index);
64 }
65 
67 {
68  return m_internalModel->documentUri(index);
69 }
70 
72 {
73  return m_internalModel->kind(index);
74 }
75 
77 {
78  return m_internalModel->compareOrder(index, otherIndex);
79 }
80 
82 {
83  return m_internalModel->root(index);
84 }
85 
87 {
88  return m_internalModel->name(index);
89 }
90 
92 {
93  return m_internalModel->stringValue(index);
94 }
95 
97 {
98  return m_internalModel->typedValue(index);
99 }
100 
102 {
103  return m_internalModel->iterate(index, axis);
104 }
105 
107 {
108  return m_internalModel->sequencedTypedValue(index);
109 }
110 
112 {
113  return m_internalModel->type(index);
114 }
115 
117 {
118  return m_internalModel->namespaceForPrefix(index, prefix);
119 }
120 
122 {
123  return m_internalModel->isDeepEqual(index, otherIndex);
124 }
125 
127 {
128  m_internalModel->sendNamespaces(index, receiver);
129 }
130 
132 {
133  return m_internalModel->namespaceBindings(index);
134 }
135 
137 {
138  return m_internalModel->elementById(name);
139 }
140 
142 {
143  return m_internalModel->nodesByIdref(name);
144 }
145 
147 {
148  return m_internalModel->copyNodeTo(index, receiver, settings);
149 }
150 
152 {
153  return m_internalModel->nextFromSimpleAxis(axis, origin);
154 }
155 
157 {
158  return m_internalModel->attributes(index);
159 }
160 
162 {
163  m_assignedElements.insert(index, element);
164 }
165 
167 {
168  if (m_assignedElements.contains(index))
169  return m_assignedElements.value(index);
170  else
171  return XsdElement::Ptr();
172 }
173 
175 {
176  m_assignedAttributes.insert(index, attribute);
177 }
178 
180 {
181  if (m_assignedAttributes.contains(index))
182  return m_assignedAttributes.value(index);
183  else
184  return XsdAttribute::Ptr();
185 }
186 
188 {
189  m_assignedTypes.insert(index, type);
190 }
191 
193 {
194  if (m_assignedTypes.contains(index))
195  return m_assignedTypes.value(index);
196  else
197  return SchemaType::Ptr();
198 }
199 
201 {
202  m_idIdRefBindings[id].insert(binding);
203 }
204 
206 {
207  return m_idIdRefBindings.keys();
208 }
209 
211 {
212  return m_idIdRefBindings.value(id);
213 }
214 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
XsdValidatedXmlNodeModel(const QAbstractXmlNodeModel *model)
virtual QXmlName::NamespaceCode namespaceForPrefix(const QXmlNodeModelIndex &ni, const QXmlName::PrefixCode prefix) const
Returns the namespace URI on ni that corresponds to prefix.
virtual void sendNamespaces(const QXmlNodeModelIndex &n, QAbstractXmlReceiver *const receiver) const
virtual QXmlNodeModelIndex root(const QXmlNodeModelIndex &n) const
Returns the root node of the tree that contains the node whose index is n.
The QXmlNodeModelIndex class identifies a node in an XML node model subclassed from QAbstractXmlNodeM...
void setAssignedAttribute(const QXmlNodeModelIndex &index, const XsdAttribute::Ptr &attribute)
void setAssignedType(const QXmlNodeModelIndex &index, const SchemaType::Ptr &type)
A push interface for the XPath Data Model. Similar to SAX&#39;s ContentHandler.
virtual QPatternist::ItemTypePtr type(const QXmlNodeModelIndex &ni) const
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual QXmlNodeModelIndex elementById(const QXmlName &NCName) const =0
Returns the index of the element identified as id.
qint16 NamespaceCode
Definition: qxmlname.h:82
virtual QUrl documentUri(const QXmlNodeModelIndex &ni) const =0
Returns the document URI of n.
QHash< QXmlNodeModelIndex, XsdAttribute::Ptr > m_assignedAttributes
virtual QXmlNodeModelIndex::NodeKind kind(const QXmlNodeModelIndex &ni) const =0
Returns a value indicating the kind of node identified by ni.
virtual bool isDeepEqual(const QXmlNodeModelIndex &ni1, const QXmlNodeModelIndex &ni2) const
Determines whether ni1 is deep equal to ni2.
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
virtual QUrl baseUri(const QXmlNodeModelIndex &ni) const
Returns the base URI for the node whose index is n.
virtual QXmlName name(const QXmlNodeModelIndex &ni) const
Returns the name of ni.
virtual QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< QXmlNodeModelIndex > > iterate(const QXmlNodeModelIndex &ni, QXmlNodeModelIndex::Axis axis) const
Performs navigation, starting from ni, by returning an QAbstractXmlForwardIterator that returns nodes...
virtual QPatternist::ItemIteratorPtr sequencedTypedValue(const QXmlNodeModelIndex &ni) const
virtual QPatternist::ItemIteratorPtr sequencedTypedValue(const QXmlNodeModelIndex &ni) const
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual QXmlName::NamespaceCode namespaceForPrefix(const QXmlNodeModelIndex &ni, const QXmlName::PrefixCode prefix) const
Returns the namespace URI on ni that corresponds to prefix.
virtual QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< QXmlNodeModelIndex > > iterate(const QXmlNodeModelIndex &ni, QXmlNodeModelIndex::Axis axis) const
Performs navigation, starting from ni, by returning an QAbstractXmlForwardIterator that returns nodes...
QSet< NamedSchemaComponent::Ptr > idIdRefBindings(const QString &id) const
virtual QXmlNodeModelIndex nextFromSimpleAxis(SimpleAxis axis, const QXmlNodeModelIndex &origin) const =0
When QtXmlPatterns evaluate path expressions, it emulate them through a combination of calls with QSi...
virtual QXmlNodeModelIndex::NodeKind kind(const QXmlNodeModelIndex &ni) const
Returns a value indicating the kind of node identified by ni.
QHash< QXmlNodeModelIndex, XsdElement::Ptr > m_assignedElements
virtual QUrl baseUri(const QXmlNodeModelIndex &ni) const =0
Returns the base URI for the node whose index is n.
QHash< QString, QSet< NamedSchemaComponent::Ptr > > m_idIdRefBindings
SchemaType::Ptr assignedType(const QXmlNodeModelIndex &index) const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
virtual QVector< QXmlName > namespaceBindings(const QXmlNodeModelIndex &n) const
Returns the in-scope namespaces of n.
XsdElement::Ptr assignedElement(const QXmlNodeModelIndex &index) const
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
void setAssignedElement(const QXmlNodeModelIndex &index, const XsdElement::Ptr &element)
The QAbstractXmlNodeModel class is an abstract base class for modeling non-XML data to look like XML ...
DocumentOrder
Identifies the specific node comparison operator that should be used.
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
The namespace for the internal API of QtXmlPatterns.
virtual QVector< QXmlNodeModelIndex > nodesByIdref(const QXmlName &NCName) const =0
Returns the elements and/or attributes that have an IDREF value equal to idref.
virtual QUrl documentUri(const QXmlNodeModelIndex &ni) const
Returns the document URI of n.
virtual QXmlNodeModelIndex root(const QXmlNodeModelIndex &n) const =0
Returns the root node of the tree that contains the node whose index is n.
virtual QPatternist::ItemTypePtr type(const QXmlNodeModelIndex &ni) const
XsdAttribute::Ptr assignedAttribute(const QXmlNodeModelIndex &index) const
virtual QVariant typedValue(const QXmlNodeModelIndex &n) const
Returns the typed value for node node.
virtual QVariant typedValue(const QXmlNodeModelIndex &n) const =0
Returns the typed value for node node.
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
virtual QXmlNodeModelIndex nextFromSimpleAxis(SimpleAxis axis, const QXmlNodeModelIndex &origin) const
When QtXmlPatterns evaluate path expressions, it emulate them through a combination of calls with QSi...
NodeKind
Identifies a kind of node.
virtual QVector< QXmlNodeModelIndex > nodesByIdref(const QXmlName &NCName) const
Returns the elements and/or attributes that have an IDREF value equal to idref.
SimpleAxis
Four axes that each contain one node only.
virtual void copyNodeTo(const QXmlNodeModelIndex &node, QAbstractXmlReceiver *const receiver, const NodeCopySettings &) const
virtual QXmlName name(const QXmlNodeModelIndex &ni) const =0
Returns the name of ni.
virtual void sendNamespaces(const QXmlNodeModelIndex &n, QAbstractXmlReceiver *const receiver) const
Sends the namespaces declared on n to receiver.
virtual QVector< QXmlNodeModelIndex > attributes(const QXmlNodeModelIndex &element) const
Returns the attributes of element.
QExplicitlySharedDataPointer< XsdElement > Ptr
Definition: qxsdelement_p.h:86
QExplicitlySharedDataPointer< SchemaType > Ptr
Definition: qschematype_p.h:82
quint16 index
Axis
Identify the axes emanating from a node.
virtual bool isDeepEqual(const QXmlNodeModelIndex &ni1, const QXmlNodeModelIndex &ni2) const
Determines whether ni1 is deep equal to ni2.
QHash< QXmlNodeModelIndex, SchemaType::Ptr > m_assignedTypes
The QFlags class provides a type-safe way of storing OR-combinations of enum values.
Definition: qglobal.h:2313
virtual QXmlNodeModelIndex elementById(const QXmlName &NCName) const
Returns the index of the element identified as id.
virtual QString stringValue(const QXmlNodeModelIndex &n) const =0
Returns the string value for node n.
void addIdIdRefBinding(const QString &id, const NamedSchemaComponent::Ptr &binding)
virtual void copyNodeTo(const QXmlNodeModelIndex &node, QAbstractXmlReceiver *const receiver, const NodeCopySettings &) const
virtual QXmlNodeModelIndex::DocumentOrder compareOrder(const QXmlNodeModelIndex &ni1, const QXmlNodeModelIndex &ni2) const
This function returns the relative document order for the nodes indexed by ni1 and ni2...
virtual QVector< QXmlName > namespaceBindings(const QXmlNodeModelIndex &n) const =0
Returns the in-scope namespaces of n.
QExplicitlySharedDataPointer< XsdAttribute > Ptr
virtual QXmlNodeModelIndex::DocumentOrder compareOrder(const QXmlNodeModelIndex &ni1, const QXmlNodeModelIndex &ni2) const =0
This function returns the relative document order for the nodes indexed by ni1 and ni2...
virtual QVector< QXmlNodeModelIndex > attributes(const QXmlNodeModelIndex &element) const =0
Returns the attributes of element.
virtual QString stringValue(const QXmlNodeModelIndex &n) const
Returns the string value for node n.
NamespaceCode PrefixCode
Definition: qxmlname.h:83