Qt 4.8
qxsdvalidatinginstancereader_p.h
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 
42 //
43 // W A R N I N G
44 // -------------
45 //
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.
49 //
50 // We mean it.
51 
52 #ifndef Patternist_XsdValidatingInstanceReader_H
53 #define Patternist_XsdValidatingInstanceReader_H
54 
55 #include "qxsdidchelper_p.h"
56 #include "qxsdinstancereader_p.h"
57 #include "qxsdstatemachine_p.h"
59 
60 #include <QtCore/QStack>
61 
63 
65 
66 class QXmlQuery;
67 
68 namespace QPatternist
69 {
80  {
81  public:
83 
92  XsdValidatingInstanceReader(XsdValidatedXmlNodeModel *model, const QUrl &documentUri, const XsdSchemaContext::Ptr &context);
93 
99  void addSchema(const XsdSchema::Ptr &schema, const QUrl &url);
100 
104  bool read();
105 
106  private:
114  bool loadSchema(const QString &targetNamespace, const QUrl &location);
115 
119  void error(const QString &msg) const;
120 
128  bool validate(bool &hasStateMachine, XsdElement::Ptr &element);
129 
137  bool validateElement(const XsdElement::Ptr &declaration, bool &hasStateMachine);
138 
151  bool validateElementType(const XsdElement::Ptr &declaration, const SchemaType::Ptr &type, bool isNilled, bool &hasStateMachine);
152 
163  bool validateElementSimpleType(const XsdElement::Ptr &declaration, const SchemaType::Ptr &type, bool isNilled);
164 
177  bool validateElementComplexType(const XsdElement::Ptr &declaration, const SchemaType::Ptr &type, bool isNilled, bool &hasStateMachine);
178 
182  bool validateAttribute(const XsdAttributeUse::Ptr &declaration, const QString &value);
183 
187  bool validateAttribute(const XsdAttribute::Ptr &declaration, const QString &value);
188 
192  bool validateAttributeWildcard(const QXmlName &attributeName, const XsdWildcard::Ptr &wildcard);
193 
197  bool validateIdentityConstraint(const XsdElement::Ptr &element, const QXmlItem &currentItem);
198 
202  bool validateUniqueIdentityConstraint(const XsdElement::Ptr &element, const XsdIdentityConstraint::Ptr &constraint, const TargetNode::Set &qualifiedNodeSet);
203 
207  bool validateKeyIdentityConstraint(const XsdElement::Ptr &element, const XsdIdentityConstraint::Ptr &constraint, const TargetNode::Set &targetNodeSet, const TargetNode::Set &qualifiedNodeSet);
208 
212  bool validateKeyRefIdentityConstraint(const XsdElement::Ptr &element, const XsdIdentityConstraint::Ptr &constraint, const TargetNode::Set &qualifiedNodeSet);
213 
223  bool selectNodeSets(const XsdElement::Ptr &element, const QXmlItem &currentItem, const XsdIdentityConstraint::Ptr &constraint, TargetNode::Set &targetNodeSet, TargetNode::Set &qualifiedNodeSet);
224 
229  QXmlQuery createXQuery(const QList<QXmlName> &namespaceBindings, const QXmlItem &contextNode, const QString &query) const;
230 
235 
240 
244  SchemaType::Ptr typeByName(const QXmlName &name) const;
245 
249  void addIdIdRefBinding(const QString &id, const NamedSchemaComponent::Ptr &binding);
250 
255  QString qNameAttribute(const QXmlName &attributeName);
256 
262 
267  void createAndPushStateMachine(const XsdParticle::Ptr &particle);
268 
270  typedef QHashIterator<QUrl, QStringList> MergedSchemasIterator;
271 
273  MergedSchemas m_mergedSchemas;
280 
289  };
290 }
291 
293 
295 
296 #endif
bool validateIdentityConstraint(const XsdElement::Ptr &element, const QXmlItem &currentItem)
QString qNameAttribute(const QXmlName &attributeName)
int type
Definition: qmetatype.cpp:239
void addSchema(const XsdSchema::Ptr &schema, const QUrl &url)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
bool validateElementType(const XsdElement::Ptr &declaration, const SchemaType::Ptr &type, bool isNilled, bool &hasStateMachine)
void addIdIdRefBinding(const QString &id, const NamedSchemaComponent::Ptr &binding)
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
bool loadSchema(const QString &targetNamespace, const QUrl &location)
bool validateKeyIdentityConstraint(const XsdElement::Ptr &element, const XsdIdentityConstraint::Ptr &constraint, const TargetNode::Set &targetNodeSet, const TargetNode::Set &qualifiedNodeSet)
The QXmlItem class contains either an XML node or an atomic value.
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
The QStack class is a template class that provides a stack.
Definition: qcontainerfwd.h:63
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
XsdValidatingInstanceReader(XsdValidatedXmlNodeModel *model, const QUrl &documentUri, const XsdSchemaContext::Ptr &context)
QHashIterator< QUrl, QStringList > MergedSchemasIterator
SchemaType::Ptr typeByName(const QXmlName &name) const
bool validateElement(const XsdElement::Ptr &declaration, bool &hasStateMachine)
bool validateKeyRefIdentityConstraint(const XsdElement::Ptr &element, const XsdIdentityConstraint::Ptr &constraint, const TargetNode::Set &qualifiedNodeSet)
XsdAttribute::Ptr attributeByName(const QXmlName &name) const
bool selectNodeSets(const XsdElement::Ptr &element, const QXmlItem &currentItem, const XsdIdentityConstraint::Ptr &constraint, TargetNode::Set &targetNodeSet, TargetNode::Set &qualifiedNodeSet)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QExplicitlySharedDataPointer< XsdValidatingInstanceReader > Ptr
QXmlQuery createXQuery(const QList< QXmlName > &namespaceBindings, const QXmlItem &contextNode, const QString &query) const
The schema instance reader.
The namespace for the internal API of QtXmlPatterns.
bool validateElementComplexType(const XsdElement::Ptr &declaration, const SchemaType::Ptr &type, bool isNilled, bool &hasStateMachine)
bool validateAttributeWildcard(const QXmlName &attributeName, const XsdWildcard::Ptr &wildcard)
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
bool validate(bool &hasStateMachine, XsdElement::Ptr &element)
A delegate class that wraps around a QAbstractXmlNodeModel and provides additional validation specifi...
XsdElement::Ptr elementByName(const QXmlName &name) const
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
bool validateElementSimpleType(const XsdElement::Ptr &declaration, const SchemaType::Ptr &type, bool isNilled)
QStack< XsdStateMachine< XsdTerm::Ptr > > m_stateMachines
The validating schema instance reader.
bool validateAttribute(const XsdAttributeUse::Ptr &declaration, const QString &value)
#define QT_END_HEADER
Definition: qglobal.h:137
The QXmlQuery class performs XQueries on XML data, or on non-XML data modeled to look like XML...
Definition: qxmlquery.h:79
QVector< QXmlName > namespaceBindings(const QXmlNodeModelIndex &index) const
void createAndPushStateMachine(const XsdParticle::Ptr &particle)
bool validateUniqueIdentityConstraint(const XsdElement::Ptr &element, const XsdIdentityConstraint::Ptr &constraint, const TargetNode::Set &qualifiedNodeSet)