0
|
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_XsdSchemaParser_H
|
|
53 |
#define Patternist_XsdSchemaParser_H
|
|
54 |
|
|
55 |
#include "qnamespacesupport_p.h"
|
|
56 |
#include "qxsdalternative_p.h"
|
|
57 |
#include "qxsdattribute_p.h"
|
|
58 |
#include "qxsdattributegroup_p.h"
|
|
59 |
#include "qxsdattributeterm_p.h"
|
|
60 |
#include "qxsdcomplextype_p.h"
|
|
61 |
#include "qxsdelement_p.h"
|
|
62 |
#include "qxsdidcache_p.h"
|
|
63 |
#include "qxsdmodelgroup_p.h"
|
|
64 |
#include "qxsdnotation_p.h"
|
|
65 |
#include "qxsdsimpletype_p.h"
|
|
66 |
#include "qxsdschemacontext_p.h"
|
|
67 |
#include "qxsdschemaparsercontext_p.h"
|
|
68 |
#include "qxsdstatemachine_p.h"
|
|
69 |
|
|
70 |
#include <QtCore/QHash>
|
|
71 |
#include <QtCore/QSet>
|
|
72 |
#include <QtCore/QUrl>
|
|
73 |
#include <QtXml/QXmlStreamReader>
|
|
74 |
#include <QtXmlPatterns/QXmlNamePool>
|
|
75 |
|
|
76 |
QT_BEGIN_HEADER
|
|
77 |
|
|
78 |
QT_BEGIN_NAMESPACE
|
|
79 |
|
|
80 |
namespace QPatternist
|
|
81 |
{
|
|
82 |
/**
|
|
83 |
* @short Implements the parsing of XML schema file.
|
|
84 |
*
|
|
85 |
* This class parses a XML schema in XML presentation from an QIODevice
|
|
86 |
* and returns object representation as XsdSchema.
|
|
87 |
*
|
|
88 |
* @ingroup Patternist_schema
|
|
89 |
* @author Tobias Koenig <tobias.koenig@nokia.com>
|
|
90 |
*/
|
|
91 |
class XsdSchemaParser : public MaintainingReader<XsdSchemaToken, XsdTagScope::Type>
|
|
92 |
{
|
|
93 |
friend class ElementNamespaceHandler;
|
|
94 |
friend class TagValidationHandler;
|
|
95 |
|
|
96 |
public:
|
|
97 |
enum ParserType
|
|
98 |
{
|
|
99 |
TopLevelParser,
|
|
100 |
IncludeParser,
|
|
101 |
ImportParser,
|
|
102 |
RedefineParser
|
|
103 |
};
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Creates a new schema parser object.
|
|
107 |
*/
|
|
108 |
XsdSchemaParser(const XsdSchemaContext::Ptr &context, const XsdSchemaParserContext::Ptr &parserContext, QIODevice *device);
|
|
109 |
|
|
110 |
/**
|
|
111 |
* Parses the XML schema file.
|
|
112 |
*
|
|
113 |
* @return @c true on success, @c false if the schema is somehow invalid.
|
|
114 |
*/
|
|
115 |
bool parse(ParserType parserType = TopLevelParser);
|
|
116 |
|
|
117 |
/**
|
|
118 |
* Describes a set of namespace URIs
|
|
119 |
*/
|
|
120 |
typedef QSet<QUrl> NamespaceSet;
|
|
121 |
|
|
122 |
/**
|
|
123 |
* Sets which @p schemas have been included already, so the parser
|
|
124 |
* can detect circular includes.
|
|
125 |
*/
|
|
126 |
void setIncludedSchemas(const NamespaceSet &schemas);
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Sets which @p schemas have been imported already, so the parser
|
|
130 |
* can detect circular imports.
|
|
131 |
*/
|
|
132 |
void setImportedSchemas(const NamespaceSet &schemas);
|
|
133 |
|
|
134 |
/**
|
|
135 |
* Sets which @p schemas have been redefined already, so the parser
|
|
136 |
* can detect circular redefines.
|
|
137 |
*/
|
|
138 |
void setRedefinedSchemas(const NamespaceSet &schemas);
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Sets the target namespace of the schema to parse.
|
|
142 |
*/
|
|
143 |
void setTargetNamespace(const QString &targetNamespace);
|
|
144 |
|
|
145 |
/**
|
|
146 |
* Sets the document URI of the schema to parse.
|
|
147 |
*/
|
|
148 |
void setDocumentURI(const QUrl &uri);
|
|
149 |
|
|
150 |
/**
|
|
151 |
* Returns the document URI of the schema to parse.
|
|
152 |
*/
|
|
153 |
QUrl documentURI() const;
|
|
154 |
|
|
155 |
/**
|
|
156 |
* Reimplemented from MaintainingReader, always returns @c false.
|
|
157 |
*/
|
|
158 |
bool isAnyAttributeAllowed() const;
|
|
159 |
|
|
160 |
private:
|
|
161 |
/**
|
|
162 |
* Used internally to report any kind of parsing error or
|
|
163 |
* schema inconsistency.
|
|
164 |
*/
|
|
165 |
virtual void error(const QString &msg);
|
|
166 |
|
|
167 |
void attributeContentError(const char *attributeName, const char *elementName, const QString &value, const SchemaType::Ptr &type = SchemaType::Ptr());
|
|
168 |
|
|
169 |
/**
|
|
170 |
* Sets the target namespace of the schema to parse.
|
|
171 |
*/
|
|
172 |
void setTargetNamespaceExtended(const QString &targetNamespace);
|
|
173 |
|
|
174 |
/**
|
|
175 |
* This method is called for parsing the top-level <em>schema</em> object.
|
|
176 |
*/
|
|
177 |
void parseSchema(ParserType parserType);
|
|
178 |
|
|
179 |
/**
|
|
180 |
* This method is called for parsing any top-level <em>include</em> object.
|
|
181 |
*/
|
|
182 |
void parseInclude();
|
|
183 |
|
|
184 |
/**
|
|
185 |
* This method is called for parsing any top-level <em>import</em> object.
|
|
186 |
*/
|
|
187 |
void parseImport();
|
|
188 |
|
|
189 |
/**
|
|
190 |
* This method is called for parsing any top-level <em>redefine</em> object.
|
|
191 |
*/
|
|
192 |
void parseRedefine();
|
|
193 |
|
|
194 |
/**
|
|
195 |
* This method is called for parsing any <em>annotation</em> object everywhere
|
|
196 |
* in the schema.
|
|
197 |
*/
|
|
198 |
XsdAnnotation::Ptr parseAnnotation();
|
|
199 |
|
|
200 |
/**
|
|
201 |
* This method is called for parsing an <em>appinfo</em> object as child of
|
|
202 |
* an <em>annotation</em> object.
|
|
203 |
*/
|
|
204 |
XsdApplicationInformation::Ptr parseAppInfo();
|
|
205 |
|
|
206 |
/**
|
|
207 |
* This method is called for parsing a <em>documentation</em> object as child of
|
|
208 |
* an <em>annotation</em> object.
|
|
209 |
*/
|
|
210 |
XsdDocumentation::Ptr parseDocumentation();
|
|
211 |
|
|
212 |
/**
|
|
213 |
* This method is called for parsing a <em>defaultOpenContent</em> object.
|
|
214 |
*/
|
|
215 |
void parseDefaultOpenContent();
|
|
216 |
|
|
217 |
/**
|
|
218 |
* This method is called for parsing any top-level <em>simpleType</em> object.
|
|
219 |
*/
|
|
220 |
XsdSimpleType::Ptr parseGlobalSimpleType();
|
|
221 |
|
|
222 |
/**
|
|
223 |
* This method is called for parsing any <em>simpleType</em> object as descendant
|
|
224 |
* of an <em>element</em> or <em>complexType</em> object.
|
|
225 |
*/
|
|
226 |
XsdSimpleType::Ptr parseLocalSimpleType();
|
|
227 |
|
|
228 |
/**
|
|
229 |
* This method is called for parsing a <em>restriction</em> object as child
|
|
230 |
* of a <em>simpleType</em> object.
|
|
231 |
*/
|
|
232 |
void parseSimpleRestriction(const XsdSimpleType::Ptr &ptr);
|
|
233 |
|
|
234 |
/**
|
|
235 |
* This method is called for parsing a <em>list</em> object as child
|
|
236 |
* of a <em>simpleType</em> object.
|
|
237 |
*/
|
|
238 |
void parseList(const XsdSimpleType::Ptr &ptr);
|
|
239 |
|
|
240 |
/**
|
|
241 |
* This method is called for parsing a <em>union</em> object as child
|
|
242 |
* of a <em>simpleType</em> object.
|
|
243 |
*/
|
|
244 |
void parseUnion(const XsdSimpleType::Ptr &ptr);
|
|
245 |
|
|
246 |
/**
|
|
247 |
* This method is called for parsing a <em>minExclusive</em> object as child
|
|
248 |
* of a <em>restriction</em> object.
|
|
249 |
*/
|
|
250 |
XsdFacet::Ptr parseMinExclusiveFacet();
|
|
251 |
|
|
252 |
/**
|
|
253 |
* This method is called for parsing a <em>minInclusive</em> object as child
|
|
254 |
* of a <em>restriction</em> object.
|
|
255 |
*/
|
|
256 |
XsdFacet::Ptr parseMinInclusiveFacet();
|
|
257 |
|
|
258 |
/**
|
|
259 |
* This method is called for parsing a <em>maxExclusive</em> object as child
|
|
260 |
* of a <em>restriction</em> object.
|
|
261 |
*/
|
|
262 |
XsdFacet::Ptr parseMaxExclusiveFacet();
|
|
263 |
|
|
264 |
/**
|
|
265 |
* This method is called for parsing a <em>maxInclusive</em> object as child
|
|
266 |
* of a <em>restriction</em> object.
|
|
267 |
*/
|
|
268 |
XsdFacet::Ptr parseMaxInclusiveFacet();
|
|
269 |
|
|
270 |
/**
|
|
271 |
* This method is called for parsing a <em>totalDigits</em> object as child
|
|
272 |
* of a <em>restriction</em> object.
|
|
273 |
*/
|
|
274 |
XsdFacet::Ptr parseTotalDigitsFacet();
|
|
275 |
|
|
276 |
/**
|
|
277 |
* This method is called for parsing a <em>fractionDigits</em> object as child
|
|
278 |
* of a <em>restriction</em> object.
|
|
279 |
*/
|
|
280 |
XsdFacet::Ptr parseFractionDigitsFacet();
|
|
281 |
|
|
282 |
/**
|
|
283 |
* This method is called for parsing a <em>length</em> object as child
|
|
284 |
* of a <em>restriction</em> object.
|
|
285 |
*/
|
|
286 |
XsdFacet::Ptr parseLengthFacet();
|
|
287 |
|
|
288 |
/**
|
|
289 |
* This method is called for parsing a <em>minLength</em> object as child
|
|
290 |
* of a <em>restriction</em> object.
|
|
291 |
*/
|
|
292 |
XsdFacet::Ptr parseMinLengthFacet();
|
|
293 |
|
|
294 |
/**
|
|
295 |
* This method is called for parsing a <em>maxLength</em> object as child
|
|
296 |
* of a <em>restriction</em> object.
|
|
297 |
*/
|
|
298 |
XsdFacet::Ptr parseMaxLengthFacet();
|
|
299 |
|
|
300 |
/**
|
|
301 |
* This method is called for parsing an <em>enumeration</em> object as child
|
|
302 |
* of a <em>restriction</em> object.
|
|
303 |
*/
|
|
304 |
XsdFacet::Ptr parseEnumerationFacet();
|
|
305 |
|
|
306 |
/**
|
|
307 |
* This method is called for parsing a <em>whiteSpace</em> object as child
|
|
308 |
* of a <em>restriction</em> object.
|
|
309 |
*/
|
|
310 |
XsdFacet::Ptr parseWhiteSpaceFacet();
|
|
311 |
|
|
312 |
/**
|
|
313 |
* This method is called for parsing a <em>pattern</em> object as child
|
|
314 |
* of a <em>restriction</em> object.
|
|
315 |
*/
|
|
316 |
XsdFacet::Ptr parsePatternFacet();
|
|
317 |
|
|
318 |
/**
|
|
319 |
* This method is called for parsing an <em>assertion</em> object as child
|
|
320 |
* of a <em>restriction</em> object.
|
|
321 |
*/
|
|
322 |
XsdFacet::Ptr parseAssertionFacet();
|
|
323 |
|
|
324 |
/**
|
|
325 |
* This method is called for parsing any top-level <em>complexType</em> object.
|
|
326 |
*/
|
|
327 |
XsdComplexType::Ptr parseGlobalComplexType();
|
|
328 |
|
|
329 |
/**
|
|
330 |
* This method is called for parsing any <em>complexType</em> object as descendant
|
|
331 |
* of an <em>element</em> object.
|
|
332 |
*/
|
|
333 |
XsdComplexType::Ptr parseLocalComplexType();
|
|
334 |
|
|
335 |
/**
|
|
336 |
* This method resolves the content type of the @p complexType for the given
|
|
337 |
* @p effectiveMixed value.
|
|
338 |
*/
|
|
339 |
void resolveComplexContentType(const XsdComplexType::Ptr &complexType, bool effectiveMixed);
|
|
340 |
|
|
341 |
/**
|
|
342 |
* This method is called for parsing a <em>simpleContent</em> object as child
|
|
343 |
* of a <em>complexType</em> object.
|
|
344 |
*/
|
|
345 |
void parseSimpleContent(const XsdComplexType::Ptr &complexType);
|
|
346 |
|
|
347 |
/**
|
|
348 |
* This method is called for parsing a <em>restriction</em> object as child
|
|
349 |
* of a <em>simpleContent</em> object.
|
|
350 |
*/
|
|
351 |
void parseSimpleContentRestriction(const XsdComplexType::Ptr &complexType);
|
|
352 |
|
|
353 |
/**
|
|
354 |
* This method is called for parsing an <em>extension</em> object as child
|
|
355 |
* of a <em>simpleContent</em> object.
|
|
356 |
*/
|
|
357 |
void parseSimpleContentExtension(const XsdComplexType::Ptr &complexType);
|
|
358 |
|
|
359 |
/**
|
|
360 |
* This method is called for parsing a <em>complexContent</em> object as child
|
|
361 |
* of a <em>complexType</em> object.
|
|
362 |
*
|
|
363 |
* @param complexType The complex type the complex content belongs to.
|
|
364 |
* @param mixed The output parameter for the mixed value.
|
|
365 |
*/
|
|
366 |
void parseComplexContent(const XsdComplexType::Ptr &complexType, bool *mixed);
|
|
367 |
|
|
368 |
/**
|
|
369 |
* This method is called for parsing a <em>restriction</em> object as child
|
|
370 |
* of a <em>complexContent</em> object.
|
|
371 |
*/
|
|
372 |
void parseComplexContentRestriction(const XsdComplexType::Ptr &complexType);
|
|
373 |
|
|
374 |
/**
|
|
375 |
* This method is called for parsing an <em>extension</em> object as child
|
|
376 |
* of a <em>complexContent</em> object.
|
|
377 |
*/
|
|
378 |
void parseComplexContentExtension(const XsdComplexType::Ptr &complexType);
|
|
379 |
|
|
380 |
/**
|
|
381 |
* This method is called for parsing an <em>assert</em> object as child
|
|
382 |
* of a <em>complexType</em> or parsing a <em>assertion</em> facet object as
|
|
383 |
* child of a <em>simpleType</em>.
|
|
384 |
*
|
|
385 |
* @param nodeName Either XsdSchemaToken::Assert or XsdSchemaToken::Assertion.
|
|
386 |
* @param tag Either XsdTagScope::Assert or XsdTagScope::Assertion.
|
|
387 |
*/
|
|
388 |
XsdAssertion::Ptr parseAssertion(const XsdSchemaToken::NodeName &nodeName, const XsdTagScope::Type &tag);
|
|
389 |
|
|
390 |
/**
|
|
391 |
* This method is called for parsing an <em>openContent</em> object.
|
|
392 |
*/
|
|
393 |
XsdComplexType::OpenContent::Ptr parseOpenContent();
|
|
394 |
|
|
395 |
/**
|
|
396 |
* This method is called for parsing a top-level <em>group</em> object.
|
|
397 |
*/
|
|
398 |
XsdModelGroup::Ptr parseNamedGroup();
|
|
399 |
|
|
400 |
/**
|
|
401 |
* This method is called for parsing a non-top-level <em>group</em> object
|
|
402 |
* that contains a <em>ref</em> attribute.
|
|
403 |
*/
|
|
404 |
XsdTerm::Ptr parseReferredGroup(const XsdParticle::Ptr &particle);
|
|
405 |
|
|
406 |
/**
|
|
407 |
* This method is called for parsing an <em>all</em> object as child
|
|
408 |
* of a top-level <em>group</em> object.
|
|
409 |
*
|
|
410 |
* @param parent The schema component the <em>all</em> object is part of.
|
|
411 |
*/
|
|
412 |
XsdModelGroup::Ptr parseAll(const NamedSchemaComponent::Ptr &parent);
|
|
413 |
|
|
414 |
/**
|
|
415 |
* This method is called for parsing an <em>all</em> object as descendant
|
|
416 |
* of a <em>complexType</em> object.
|
|
417 |
*
|
|
418 |
* @param particle The particle the <em>all</em> object belongs to.
|
|
419 |
* @param parent The schema component the <em>all</em> object is part of.
|
|
420 |
*/
|
|
421 |
XsdModelGroup::Ptr parseLocalAll(const XsdParticle::Ptr &particle, const NamedSchemaComponent::Ptr &parent);
|
|
422 |
|
|
423 |
/**
|
|
424 |
* This method is called for parsing a <em>choice</em> object as child
|
|
425 |
* of a top-level <em>group</em> object.
|
|
426 |
*
|
|
427 |
* @param parent The schema component the <em>choice</em> object is part of.
|
|
428 |
*/
|
|
429 |
XsdModelGroup::Ptr parseChoice(const NamedSchemaComponent::Ptr &parent);
|
|
430 |
|
|
431 |
/**
|
|
432 |
* This method is called for parsing a <em>choice</em> object as descendant
|
|
433 |
* of a <em>complexType</em> object or a <em>choice</em> object.
|
|
434 |
*
|
|
435 |
* @param particle The particle the <em>choice</em> object belongs to.
|
|
436 |
* @param parent The schema component the <em>choice</em> object is part of.
|
|
437 |
*/
|
|
438 |
XsdModelGroup::Ptr parseLocalChoice(const XsdParticle::Ptr &particle, const NamedSchemaComponent::Ptr &parent);
|
|
439 |
|
|
440 |
/**
|
|
441 |
* This method is called for parsing a <em>sequence</em> object as child
|
|
442 |
* of a top-level <em>group</em> object.
|
|
443 |
*
|
|
444 |
* @param parent The schema component the <em>sequence</em> object is part of.
|
|
445 |
*/
|
|
446 |
XsdModelGroup::Ptr parseSequence(const NamedSchemaComponent::Ptr &parent);
|
|
447 |
|
|
448 |
/**
|
|
449 |
* This method is called for parsing a <em>sequence</em> object as descendant
|
|
450 |
* of a <em>complexType</em> object or a <em>sequence</em> object.
|
|
451 |
*
|
|
452 |
* @param particle The particle the <em>sequence</em> object belongs to.
|
|
453 |
* @param parent The schema component the <em>sequence</em> object is part of.
|
|
454 |
*/
|
|
455 |
XsdModelGroup::Ptr parseLocalSequence(const XsdParticle::Ptr &particle, const NamedSchemaComponent::Ptr &parent);
|
|
456 |
|
|
457 |
/**
|
|
458 |
* A helper method that parses the minOccurs and maxOccurs constraints for
|
|
459 |
* the given @p particle that has the given @p tagName.
|
|
460 |
*/
|
|
461 |
bool parseMinMaxConstraint(const XsdParticle::Ptr &particle, const char* tagName);
|
|
462 |
|
|
463 |
/**
|
|
464 |
* This method is called for parsing any top-level <em>attribute</em> object.
|
|
465 |
*/
|
|
466 |
XsdAttribute::Ptr parseGlobalAttribute();
|
|
467 |
|
|
468 |
/**
|
|
469 |
* This method is called for parsing any non-top-level <em>attribute</em> object as a
|
|
470 |
* descendant of a <em>complexType</em> object or an <em>attributeGroup</em> object.
|
|
471 |
*
|
|
472 |
* @param parent The parent component the <em>attribute</em> object is part of.
|
|
473 |
*/
|
|
474 |
XsdAttributeUse::Ptr parseLocalAttribute(const NamedSchemaComponent::Ptr &parent);
|
|
475 |
|
|
476 |
/**
|
|
477 |
* This method is called for parsing a top-level <em>attributeGroup</em> object.
|
|
478 |
*/
|
|
479 |
XsdAttributeGroup::Ptr parseNamedAttributeGroup();
|
|
480 |
|
|
481 |
/**
|
|
482 |
* This method is called for parsing a non-top-level <em>attributeGroup</em> object
|
|
483 |
* that contains a <em>ref</em> attribute.
|
|
484 |
*/
|
|
485 |
XsdAttributeUse::Ptr parseReferredAttributeGroup();
|
|
486 |
|
|
487 |
/**
|
|
488 |
* This method is called for parsing any top-level <em>element</em> object.
|
|
489 |
*/
|
|
490 |
XsdElement::Ptr parseGlobalElement();
|
|
491 |
|
|
492 |
/**
|
|
493 |
* This method is called for parsing any non-top-level <em>element</em> object as a
|
|
494 |
* descendant of a <em>complexType</em> object or a <em>group</em> object.
|
|
495 |
*
|
|
496 |
* @param particle The particle the <em>element</em> object belongs to.
|
|
497 |
* @param parent The parent component the <em>element</em> object is part of.
|
|
498 |
*/
|
|
499 |
XsdTerm::Ptr parseLocalElement(const XsdParticle::Ptr &particle, const NamedSchemaComponent::Ptr &parent);
|
|
500 |
|
|
501 |
/**
|
|
502 |
* This method is called for parsing a <em>unique</em> object as child of an <em>element</em> object.
|
|
503 |
*/
|
|
504 |
XsdIdentityConstraint::Ptr parseUnique();
|
|
505 |
|
|
506 |
/**
|
|
507 |
* This method is called for parsing a <em>key</em> object as child of an <em>element</em> object.
|
|
508 |
*/
|
|
509 |
XsdIdentityConstraint::Ptr parseKey();
|
|
510 |
|
|
511 |
/**
|
|
512 |
* This method is called for parsing a <em>keyref</em> object as child of an <em>element</em> object.
|
|
513 |
*/
|
|
514 |
XsdIdentityConstraint::Ptr parseKeyRef(const XsdElement::Ptr &element);
|
|
515 |
|
|
516 |
/**
|
|
517 |
* This method is called for parsing a <em>selector</em> object as child of an <em>unique</em> object,
|
|
518 |
* <em>key</em> object or <em>keyref</em> object,
|
|
519 |
*
|
|
520 |
* @param ptr The identity constraint it belongs to.
|
|
521 |
*/
|
|
522 |
void parseSelector(const XsdIdentityConstraint::Ptr &ptr);
|
|
523 |
|
|
524 |
/**
|
|
525 |
* This method is called for parsing a <em>field</em> object as child of an <em>unique</em> object,
|
|
526 |
* <em>key</em> object or <em>keyref</em> object,
|
|
527 |
*
|
|
528 |
* @param ptr The identity constraint it belongs to.
|
|
529 |
*/
|
|
530 |
void parseField(const XsdIdentityConstraint::Ptr &ptr);
|
|
531 |
|
|
532 |
/**
|
|
533 |
* This method is called for parsing an <em>alternative</em> object inside an <em>element</em> object.
|
|
534 |
*/
|
|
535 |
XsdAlternative::Ptr parseAlternative();
|
|
536 |
|
|
537 |
/**
|
|
538 |
* This method is called for parsing a top-level <em>notation</em> object.
|
|
539 |
*/
|
|
540 |
XsdNotation::Ptr parseNotation();
|
|
541 |
|
|
542 |
/**
|
|
543 |
* This method is called for parsing an <em>any</em> object somewhere in
|
|
544 |
* the schema.
|
|
545 |
*
|
|
546 |
* @param particle The particle the <em>any</em> object belongs to.
|
|
547 |
*/
|
|
548 |
XsdWildcard::Ptr parseAny(const XsdParticle::Ptr &particle);
|
|
549 |
|
|
550 |
/**
|
|
551 |
* This method is called for parsing an <em>anyAttribute</em> object somewhere in
|
|
552 |
* the schema.
|
|
553 |
*/
|
|
554 |
XsdWildcard::Ptr parseAnyAttribute();
|
|
555 |
|
|
556 |
/**
|
|
557 |
* This method is called for parsing unknown object as descendant of the <em>annotation</em> object.
|
|
558 |
*/
|
|
559 |
void parseUnknownDocumentation();
|
|
560 |
|
|
561 |
/**
|
|
562 |
* This method is called for parsing unknown object in the schema.
|
|
563 |
*/
|
|
564 |
void parseUnknown();
|
|
565 |
|
|
566 |
/**
|
|
567 |
* Returnes an source location for the current position.
|
|
568 |
*/
|
|
569 |
QSourceLocation currentSourceLocation() const;
|
|
570 |
|
|
571 |
/**
|
|
572 |
* Converts a @p qualified name into a QXmlName @p name and does some error handling.
|
|
573 |
*/
|
|
574 |
void convertName(const QString &qualified, NamespaceSupport::NameType type, QXmlName &name);
|
|
575 |
|
|
576 |
/**
|
|
577 |
* A helper method that reads in a 'name' attribute and checks it for syntactic errors.
|
|
578 |
*/
|
|
579 |
inline QString readNameAttribute(const char *elementName);
|
|
580 |
|
|
581 |
/**
|
|
582 |
* A helper method that reads in an attribute that contains an QName and
|
|
583 |
* checks it for syntactic errors.
|
|
584 |
*/
|
|
585 |
inline QString readQNameAttribute(const QString &typeAttribute, const char *elementName);
|
|
586 |
|
|
587 |
/**
|
|
588 |
* A helper method that reads in a namespace attribute and checks for syntactic errors.
|
|
589 |
*/
|
|
590 |
inline QString readNamespaceAttribute(const QString &attributeName, const char *elementName);
|
|
591 |
|
|
592 |
/**
|
|
593 |
* A helper method that reads the final attribute and does correct handling of schema default definitions.
|
|
594 |
*/
|
|
595 |
inline SchemaType::DerivationConstraints readDerivationConstraintAttribute(const SchemaType::DerivationConstraints &allowedConstraints, const char *elementName);
|
|
596 |
|
|
597 |
/**
|
|
598 |
* A helper method that reads the block attribute and does correct handling of schema default definitions.
|
|
599 |
*/
|
|
600 |
inline NamedSchemaComponent::BlockingConstraints readBlockingConstraintAttribute(const NamedSchemaComponent::BlockingConstraints &allowedConstraints, const char *elementName);
|
|
601 |
|
|
602 |
/**
|
|
603 |
* A helper method that reads all components for a xpath expression for the current scope.
|
|
604 |
*/
|
|
605 |
XsdXPathExpression::Ptr readXPathExpression(const char *elementName);
|
|
606 |
|
|
607 |
/**
|
|
608 |
* Describes the type of XPath that is allowed by the readXPathAttribute method.
|
|
609 |
*/
|
|
610 |
enum XPathType {
|
|
611 |
XPath20,
|
|
612 |
XPathSelector,
|
|
613 |
XPathField
|
|
614 |
};
|
|
615 |
|
|
616 |
/**
|
|
617 |
* A helper method that reads an attribute that represents a xpath query and does basic
|
|
618 |
* validation.
|
|
619 |
*/
|
|
620 |
QString readXPathAttribute(const QString &attributeName, XPathType type, const char *elementName);
|
|
621 |
|
|
622 |
/**
|
|
623 |
* A helper method that reads in an "id" attribute, checks it for syntactic errors
|
|
624 |
* and tests whether a component with the same id has already been parsed.
|
|
625 |
*/
|
|
626 |
inline void validateIdAttribute(const char *elementName);
|
|
627 |
|
|
628 |
/**
|
|
629 |
* Adds an @p element to the schema and checks for duplicated entries.
|
|
630 |
*/
|
|
631 |
void addElement(const XsdElement::Ptr &element);
|
|
632 |
|
|
633 |
/**
|
|
634 |
* Adds an @p attribute to the schema and checks for duplicated entries.
|
|
635 |
*/
|
|
636 |
void addAttribute(const XsdAttribute::Ptr &attribute);
|
|
637 |
|
|
638 |
/**
|
|
639 |
* Adds a @p type to the schema and checks for duplicated entries.
|
|
640 |
*/
|
|
641 |
void addType(const SchemaType::Ptr &type);
|
|
642 |
|
|
643 |
/**
|
|
644 |
* Adds an anonymous @p type to the schema and checks for duplicated entries.
|
|
645 |
*/
|
|
646 |
void addAnonymousType(const SchemaType::Ptr &type);
|
|
647 |
|
|
648 |
/**
|
|
649 |
* Adds an attribute @p group to the schema and checks for duplicated entries.
|
|
650 |
*/
|
|
651 |
void addAttributeGroup(const XsdAttributeGroup::Ptr &group);
|
|
652 |
|
|
653 |
/**
|
|
654 |
* Adds an element @p group to the schema and checks for duplicated entries.
|
|
655 |
*/
|
|
656 |
void addElementGroup(const XsdModelGroup::Ptr &group);
|
|
657 |
|
|
658 |
/**
|
|
659 |
* Adds a @p notation to the schema and checks for duplicated entries.
|
|
660 |
*/
|
|
661 |
void addNotation(const XsdNotation::Ptr ¬ation);
|
|
662 |
|
|
663 |
/**
|
|
664 |
* Adds an identity @p constraint to the schema and checks for duplicated entries.
|
|
665 |
*/
|
|
666 |
void addIdentityConstraint(const XsdIdentityConstraint::Ptr &constraint);
|
|
667 |
|
|
668 |
/**
|
|
669 |
* Adds the @p facet to the list of @p facets for @p type and checks for duplicates.
|
|
670 |
*/
|
|
671 |
void addFacet(const XsdFacet::Ptr &facet, XsdFacet::Hash &facets, const SchemaType::Ptr &type);
|
|
672 |
|
|
673 |
/**
|
|
674 |
* Sets up the state machines for validating the right occurrence of xml elements.
|
|
675 |
*/
|
|
676 |
void setupStateMachines();
|
|
677 |
|
|
678 |
/**
|
|
679 |
* Sets up a list of names of known builtin types.
|
|
680 |
*/
|
|
681 |
void setupBuiltinTypeNames();
|
|
682 |
|
|
683 |
/**
|
|
684 |
* Checks whether the given @p tag is equal to the given @p token and
|
|
685 |
* the given @p namespaceToken is the XML Schema namespace.
|
|
686 |
*/
|
|
687 |
inline bool isSchemaTag(XsdSchemaToken::NodeName tag, XsdSchemaToken::NodeName token, XsdSchemaToken::NodeName namespaceToken) const;
|
|
688 |
|
|
689 |
XsdSchemaContext::Ptr m_context;
|
|
690 |
XsdSchemaParserContext::Ptr m_parserContext;
|
|
691 |
NamePool::Ptr m_namePool;
|
|
692 |
NamespaceSupport m_namespaceSupport;
|
|
693 |
XsdSchemaResolver::Ptr m_schemaResolver;
|
|
694 |
XsdSchema::Ptr m_schema;
|
|
695 |
|
|
696 |
QString m_targetNamespace;
|
|
697 |
QString m_attributeFormDefault;
|
|
698 |
QString m_elementFormDefault;
|
|
699 |
QString m_blockDefault;
|
|
700 |
QString m_finalDefault;
|
|
701 |
QString m_xpathDefaultNamespace;
|
|
702 |
QXmlName m_defaultAttributes;
|
|
703 |
XsdComplexType::OpenContent::Ptr m_defaultOpenContent;
|
|
704 |
bool m_defaultOpenContentAppliesToEmpty;
|
|
705 |
|
|
706 |
NamespaceSet m_includedSchemas;
|
|
707 |
NamespaceSet m_importedSchemas;
|
|
708 |
NamespaceSet m_redefinedSchemas;
|
|
709 |
QUrl m_documentURI;
|
|
710 |
XsdIdCache::Ptr m_idCache;
|
|
711 |
QHash<XsdTagScope::Type, XsdStateMachine<XsdSchemaToken::NodeName> > m_stateMachines;
|
|
712 |
ComponentLocationHash m_componentLocationHash;
|
|
713 |
QSet<QXmlName> m_builtinTypeNames;
|
|
714 |
};
|
|
715 |
}
|
|
716 |
|
|
717 |
QT_END_NAMESPACE
|
|
718 |
|
|
719 |
QT_END_HEADER
|
|
720 |
|
|
721 |
#endif
|