1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
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 The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40//
41// W A R N I N G
42// -------------
43//
44// This file is not part of the Qt API. It exists purely as an
45// implementation detail. This header file may change from version to
46// version without notice, or even be removed.
47//
48// We mean it.
49
50#ifndef Patternist_XsdSchemaContext_H
51#define Patternist_XsdSchemaContext_H
52
53#include <private/qnamedschemacomponent_p.h>
54#include <private/qreportcontext_p.h>
55#include <private/qschematypefactory_p.h>
56#include <private/qxsdschematoken_p.h>
57#include <private/qxsdschema_p.h>
58#include <private/qxsdschemachecker_p.h>
59#include <private/qxsdschemaresolver_p.h>
60
61#include <QtCore/QUrl>
62#include <QtNetwork/QNetworkAccessManager>
63#include <QtXmlPatterns/QAbstractMessageHandler>
64
65QT_BEGIN_NAMESPACE
66
67namespace QPatternist
68{
69 /**
70 * @short A context for schema parsing and validation.
71 *
72 * This class provides the infrastructure for error reporting and
73 * network access. Additionally it stores objects that are used by
74 * both, the parser and the validator.
75 *
76 * @ingroup Patternist_schema
77 * @author Tobias Koenig <tobias.koenig@nokia.com>
78 */
79 class XsdSchemaContext : public ReportContext
80 {
81 public:
82 /**
83 * A smart pointer wrapping XsdSchemaContext instances.
84 */
85 typedef QExplicitlySharedDataPointer<XsdSchemaContext> Ptr;
86
87 /**
88 * Creates a new schema context object.
89 *
90 * @param namePool The name pool all names belong to.
91 */
92 XsdSchemaContext(const NamePool::Ptr &namePool);
93
94 /**
95 * Returns the name pool of the schema context.
96 */
97 virtual NamePool::Ptr namePool() const;
98
99 /**
100 * Sets the base URI for the main schema.
101 *
102 * The main schema is the one that includes resp. imports
103 * all the other schema files.
104 */
105 virtual void setBaseURI(const QUrl &uri);
106
107 /**
108 * Returns the base URI of the main schema.
109 */
110 virtual QUrl baseURI() const;
111
112 /**
113 * Sets the network access manager that should be used
114 * to access referenced schema definitions.
115 */
116 void setNetworkAccessManager(QNetworkAccessManager *accessManager);
117
118 /**
119 * Returns the network access manager that is used to
120 * access referenced schema definitions.
121 */
122 virtual QNetworkAccessManager* networkAccessManager() const;
123
124 /**
125 * Sets the message @p handler used by the context for error reporting.
126 */
127 void setMessageHandler(QAbstractMessageHandler *handler);
128
129 /**
130 * Returns the message handler used by the context for
131 * error reporting.
132 */
133 virtual QAbstractMessageHandler* messageHandler() const;
134
135 /**
136 * Always returns an empty source location.
137 */
138 virtual QSourceLocation locationFor(const SourceLocationReflection *const reflection) const;
139
140 /**
141 * Sets the uri @p resolver that is used for resolving URIs in the
142 * schema parser.
143 */
144 void setUriResolver(const QAbstractUriResolver *resolver);
145
146 /**
147 * Returns the uri resolver that is used for resolving URIs in the
148 * schema parser.
149 */
150 virtual const QAbstractUriResolver* uriResolver() const;
151
152 /**
153 * Returns the list of facets for the given simple @p type.
154 */
155 XsdFacet::Hash facetsForType(const AnySimpleType::Ptr &type) const;
156
157 /**
158 * Returns a schema type factory that contains some predefined schema types.
159 */
160 SchemaTypeFactory::Ptr schemaTypeFactory() const;
161
162 /**
163 * The following variables should not be accessed directly.
164 */
165 mutable SchemaTypeFactory::Ptr m_schemaTypeFactory;
166 mutable QHash<SchemaType::Ptr, XsdFacet::Hash> m_builtinTypesFacetList;
167
168 private:
169 QHash<SchemaType::Ptr, XsdFacet::Hash> setupBuiltinTypesFacetList() const;
170
171 NamePool::Ptr m_namePool;
172 QNetworkAccessManager* m_networkAccessManager;
173 QUrl m_baseURI;
174 const QAbstractUriResolver* m_uriResolver;
175 QAbstractMessageHandler* m_messageHandler;
176 };
177}
178
179QT_END_NAMESPACE
180
181#endif
182

source code of qtxmlpatterns/src/xmlpatterns/schema/qxsdschemacontext_p.h