|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtXmlPatterns module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
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_XsdSchemaParserContext_H |
|
53 #define Patternist_XsdSchemaParserContext_H |
|
54 |
|
55 #include "qmaintainingreader_p.h" // for definition of ElementDescription |
|
56 #include "qxsdschematoken_p.h" |
|
57 #include "qxsdschema_p.h" |
|
58 #include "qxsdschemachecker_p.h" |
|
59 #include "qxsdschemacontext_p.h" |
|
60 #include "qxsdschemaresolver_p.h" |
|
61 |
|
62 #include <QtCore/QSharedData> |
|
63 |
|
64 QT_BEGIN_HEADER |
|
65 |
|
66 QT_BEGIN_NAMESPACE |
|
67 |
|
68 namespace QPatternist |
|
69 { |
|
70 /** |
|
71 * @short A namespace class that contains identifiers for the different |
|
72 * scopes a tag from the xml schema spec can appear in. |
|
73 */ |
|
74 class XsdTagScope |
|
75 { |
|
76 public: |
|
77 enum Type |
|
78 { |
|
79 Schema, |
|
80 Include, |
|
81 Import, |
|
82 Redefine, |
|
83 Annotation, |
|
84 AppInfo, |
|
85 Documentation, |
|
86 GlobalSimpleType, |
|
87 LocalSimpleType, |
|
88 SimpleRestriction, |
|
89 List, |
|
90 Union, |
|
91 MinExclusiveFacet, |
|
92 MinInclusiveFacet, |
|
93 MaxExclusiveFacet, |
|
94 MaxInclusiveFacet, |
|
95 TotalDigitsFacet, |
|
96 FractionDigitsFacet, |
|
97 LengthFacet, |
|
98 MinLengthFacet, |
|
99 MaxLengthFacet, |
|
100 EnumerationFacet, |
|
101 WhiteSpaceFacet, |
|
102 PatternFacet, |
|
103 GlobalComplexType, |
|
104 LocalComplexType, |
|
105 SimpleContent, |
|
106 SimpleContentRestriction, |
|
107 SimpleContentExtension, |
|
108 ComplexContent, |
|
109 ComplexContentRestriction, |
|
110 ComplexContentExtension, |
|
111 NamedGroup, |
|
112 ReferredGroup, |
|
113 All, |
|
114 LocalAll, |
|
115 Choice, |
|
116 LocalChoice, |
|
117 Sequence, |
|
118 LocalSequence, |
|
119 GlobalAttribute, |
|
120 LocalAttribute, |
|
121 NamedAttributeGroup, |
|
122 ReferredAttributeGroup, |
|
123 GlobalElement, |
|
124 LocalElement, |
|
125 Unique, |
|
126 Key, |
|
127 KeyRef, |
|
128 Selector, |
|
129 Field, |
|
130 Notation, |
|
131 Any, |
|
132 AnyAttribute, |
|
133 Alternative, |
|
134 Assert, |
|
135 Assertion, |
|
136 OpenContent, |
|
137 DefaultOpenContent, |
|
138 Override |
|
139 }; |
|
140 }; |
|
141 |
|
142 /** |
|
143 * A hash that keeps the mapping between the single components that can appear |
|
144 * in a schema document (e.g. elements, attributes, type definitions) and their |
|
145 * source locations inside the document. |
|
146 */ |
|
147 typedef QHash<NamedSchemaComponent::Ptr, QSourceLocation> ComponentLocationHash; |
|
148 |
|
149 /** |
|
150 * @short A context for schema parsing. |
|
151 * |
|
152 * This class provides a context for all components that are |
|
153 * nedded for parsing and compiling the XML schema. |
|
154 * |
|
155 * @ingroup Patternist_schema |
|
156 * @author Tobias Koenig <tobias.koenig@nokia.com> |
|
157 */ |
|
158 class XsdSchemaParserContext : public QSharedData |
|
159 { |
|
160 public: |
|
161 /** |
|
162 * A smart pointer wrapping XsdSchemaParserContext instances. |
|
163 */ |
|
164 typedef QExplicitlySharedDataPointer<XsdSchemaParserContext> Ptr; |
|
165 |
|
166 /** |
|
167 * Creates a new schema parser context object. |
|
168 * |
|
169 * @param namePool The name pool where all names of the schema will be stored in. |
|
170 * @param context The schema context to use for error reporting etc. |
|
171 */ |
|
172 XsdSchemaParserContext(const NamePool::Ptr &namePool, const XsdSchemaContext::Ptr &context); |
|
173 |
|
174 /** |
|
175 * Returns the name pool of the schema parser context. |
|
176 */ |
|
177 NamePool::Ptr namePool() const; |
|
178 |
|
179 /** |
|
180 * Returns the schema resolver of the schema context. |
|
181 */ |
|
182 XsdSchemaResolver::Ptr resolver() const; |
|
183 |
|
184 /** |
|
185 * Returns the schema resolver of the schema context. |
|
186 */ |
|
187 XsdSchemaChecker::Ptr checker() const; |
|
188 |
|
189 /** |
|
190 * Returns the schema object of the schema context. |
|
191 */ |
|
192 XsdSchema::Ptr schema() const; |
|
193 |
|
194 /** |
|
195 * Returns the element descriptions for the schema parser. |
|
196 * |
|
197 * The element descriptions are a fast lookup table for |
|
198 * verifying whether certain attributes are allowed for |
|
199 * a given element type. |
|
200 */ |
|
201 ElementDescription<XsdSchemaToken, XsdTagScope::Type>::Hash elementDescriptions() const; |
|
202 |
|
203 /** |
|
204 * Returns an unique name that is used by the schema parser |
|
205 * for anonymous types. |
|
206 * |
|
207 * @param targetNamespace The namespace of the name. |
|
208 */ |
|
209 QXmlName createAnonymousName(const QString &targetNamespace) const; |
|
210 |
|
211 private: |
|
212 /** |
|
213 * Fills the element description hash with the required and prohibited |
|
214 * attributes. |
|
215 */ |
|
216 static ElementDescription<XsdSchemaToken, XsdTagScope::Type>::Hash setupElementDescriptions(); |
|
217 |
|
218 NamePool::Ptr m_namePool; |
|
219 XsdSchema::Ptr m_schema; |
|
220 XsdSchemaChecker::Ptr m_checker; |
|
221 XsdSchemaResolver::Ptr m_resolver; |
|
222 const ElementDescription<XsdSchemaToken, XsdTagScope::Type>::Hash m_elementDescriptions; |
|
223 mutable QAtomicInt m_anonymousNameCounter; |
|
224 }; |
|
225 } |
|
226 |
|
227 QT_END_NAMESPACE |
|
228 |
|
229 QT_END_HEADER |
|
230 |
|
231 #endif |