Qt 4.8
qxsdschemaparsercontext.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 
45 
46 using namespace QPatternist;
47 
49  : m_namePool(namePool)
50  , m_schema(new XsdSchema(m_namePool))
51  , m_checker(new XsdSchemaChecker(context, this))
52  , m_resolver(new XsdSchemaResolver(context, this))
53  , m_elementDescriptions(setupElementDescriptions())
54 {
55 }
56 
58 {
59  return m_namePool;
60 }
61 
63 {
64  return m_resolver;
65 }
66 
68 {
69  return m_checker;
70 }
71 
73 {
74  return m_schema;
75 }
76 
78 {
79  return m_elementDescriptions;
80 }
81 
83 {
85 
86  const QString name = QString::fromLatin1("__AnonymousClass_%1").arg((int)m_anonymousNameCounter);
87 
88  return m_namePool->allocateQName(targetNamespace, name);
89 }
90 
92 {
93  enum
94  {
95  ReservedForElements = 60
96  };
97 
99  elementDescriptions.reserve(ReservedForElements);
100 
101  {
103  description.optionalAttributes.reserve(10);
104  //description.tagToken = XsdSchemaToken::Schema;
115  }
116 
117  {
119  //description.tagToken = XsdSchemaToken::Include;
122  }
123 
124  {
126  //description.tagToken = XsdSchemaToken::Import;
130  }
131 
132  {
134  //description.tagToken = XsdSchemaToken::Redefine;
137  }
138 
139  {
141  //description.tagToken = XsdSchemaToken::Override;
144  }
145 
146  {
148  //description.tagToken = XsdSchemaToken::Annotation;
150  }
151 
152  {
154  //description.tagToken = XsdSchemaToken::Appinfo;
156  }
157 
158  {
160  //description.tagToken = XsdSchemaToken::Documentation;
162  }
163 
164  {
166  //description.tagToken = XsdSchemaToken::SimpleType;
170  }
171 
172  {
174  //description.tagToken = XsdSchemaToken::SimpleType;
176  }
177 
178  {
180  //description.tagToken = XsdSchemaToken::Restriction;
183  }
184 
185  {
187  //description.tagToken = XsdSchemaToken::List;
190  }
191 
192  {
194  //description.tagToken = XsdSchemaToken::Union;
197  }
198 
199  {
201  //description.tagToken = XsdSchemaToken::MinExclusive;
205  }
206 
207  {
209  //description.tagToken = XsdSchemaToken::MinInclusive;
213  }
214 
215  {
217  //description.tagToken = XsdSchemaToken::MaxExclusive;
221  }
222 
223  {
225  //description.tagToken = XsdSchemaToken::MaxInclusive;
229  }
230 
231  {
233  //description.tagToken = XsdSchemaToken::TotalDigits;
237  }
238 
239  {
241  //description.tagToken = XsdSchemaToken::FractionDigits;
245  }
246 
247  {
249  //description.tagToken = XsdSchemaToken::Length;
253  }
254 
255  {
257  //description.tagToken = XsdSchemaToken::MinLength;
261  }
262 
263  {
265  //description.tagToken = XsdSchemaToken::MaxLength;
269  }
270 
271  {
273  //description.tagToken = XsdSchemaToken::Enumeration;
276  }
277 
278  {
280  //description.tagToken = XsdSchemaToken::WhiteSpace;
284  }
285 
286  {
288  //description.tagToken = XsdSchemaToken::Pattern;
291  }
292 
293  {
295  description.optionalAttributes.reserve(7);
296  //description.tagToken = XsdSchemaToken::ComplexType;
304  }
305 
306  {
308  //description.tagToken = XsdSchemaToken::ComplexType;
311  }
312 
313  {
315  //description.tagToken = XsdSchemaToken::SimpleContent;
317  }
318 
319  {
321  //description.tagToken = XsdSchemaToken::Restriction;
324  }
325 
326  {
328  //description.tagToken = XsdSchemaToken::Extension;
331  }
332 
333  {
335  //description.tagToken = XsdSchemaToken::ComplexContent;
338  }
339 
340  {
342  //description.tagToken = XsdSchemaToken::Restriction;
345  }
346 
347  {
349  //description.tagToken = XsdSchemaToken::Extension;
352  }
353 
354  {
356  //description.tagToken = XsdSchemaToken::Group;
359  }
360 
361  {
363  description.optionalAttributes.reserve(4);
364  //description.tagToken = XsdSchemaToken::Group;
369  }
370 
371  {
373  //description.tagToken = XsdSchemaToken::All;
375  }
376 
377  {
379  //description.tagToken = XsdSchemaToken::All;
383  }
384 
385  {
387  //description.tagToken = XsdSchemaToken::Choice;
389  }
390 
391  {
393  //description.tagToken = XsdSchemaToken::Choice;
397  }
398 
399  {
401  //description.tagToken = XsdSchemaToken::Sequence;
403  }
404 
405  {
407  //description.tagToken = XsdSchemaToken::Sequence;
411  }
412 
413  {
415  description.optionalAttributes.reserve(5);
416  //description.tagToken = XsdSchemaToken::Attribute;
422  }
423 
424  {
426  description.optionalAttributes.reserve(8);
427  //description.tagToken = XsdSchemaToken::Attribute;
436  }
437 
438  {
440  //description.tagToken = XsdSchemaToken::AttributeGroup;
443  }
444 
445  {
447  //description.tagToken = XsdSchemaToken::AttributeGroup;
450  }
451 
452  {
454  description.optionalAttributes.reserve(11);
455  //description.tagToken = XsdSchemaToken::Element;
467  }
468 
469  {
471  description.optionalAttributes.reserve(10);
472  //description.tagToken = XsdSchemaToken::Element;
483  }
484 
485  {
487  //description.tagToken = XsdSchemaToken::Unique;
490  }
491 
492  {
494  //description.tagToken = XsdSchemaToken::Key;
497  }
498 
499  {
501  //description.tagToken = XsdSchemaToken::Keyref;
505  }
506 
507  {
509  //description.tagToken = XsdSchemaToken::Selector;
513  }
514 
515  {
517  //description.tagToken = XsdSchemaToken::Field;
521  }
522 
523  {
525  description.optionalAttributes.reserve(4);
526  //description.tagToken = XsdSchemaToken::Notation;
531  }
532 
533  {
535  description.optionalAttributes.reserve(7);
536  //description.tagToken = XsdSchemaToken::Any;
544  }
545 
546  {
548  description.optionalAttributes.reserve(5);
549  //description.tagToken = XsdSchemaToken::AnyAttribute;
555  }
556 
557  {
559  //description.tagToken = XsdSchemaToken::Alternative;
564  }
565 
566  {
568  //description.tagToken = XsdSchemaToken::OpenContent;
571  }
572 
573  {
575  //description.tagToken = XsdSchemaToken::DefaultOpenContent;
579  }
580 
581  {
583  //description.tagToken = XsdSchemaToken::Assert;
587  }
588 
589  {
591  //description.tagToken = XsdSchemaToken::Assertion;
595  }
596 
597  Q_ASSERT_X(elementDescriptions.count() == ReservedForElements, Q_FUNC_INFO,
598  qPrintable(QString::fromLatin1("Expected is %1, actual is %2.").arg(ReservedForElements).arg(elementDescriptions.count())));
599 
600  return elementDescriptions;
601 }
602 
XsdSchemaParserContext(const NamePool::Ptr &namePool, const XsdSchemaContext::Ptr &context)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
XsdSchemaResolver::Ptr resolver() const
Represents a XSD schema object.
Definition: qxsdschema_p.h:91
bool ref()
Atomically increments the value of this QAtomicInt.
The QString class provides a Unicode character string.
Definition: qstring.h:83
QXmlName createAnonymousName(const QString &targetNamespace) const
const ElementDescription< XsdSchemaToken, XsdTagScope::Type >::Hash m_elementDescriptions
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
Encapsulates the resolving of type/element references in a schema after parsing has finished...
const char * name
The namespace for the internal API of QtXmlPatterns.
const_iterator insert(const T &value)
Definition: qset.h:179
Encapsulates the checking of schema valitity after reference resolving has finished.
ElementDescription< XsdSchemaToken, XsdTagScope::Type >::Hash elementDescriptions() const
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
static ElementDescription< XsdSchemaToken, XsdTagScope::Type >::Hash setupElementDescriptions()
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
QXmlName allocateQName(const QString &uri, const QString &localName, const QString &prefix=QString())
Definition: qnamepool.cpp:251
QSet< typename TokenLookupClass::NodeName > requiredAttributes
QSet< typename TokenLookupClass::NodeName > optionalAttributes
A structure that lists the optional and required attributes of an element. Used with MaintainingReade...
#define qPrintable(string)
Definition: qglobal.h:1750
#define Q_FUNC_INFO
Definition: qglobal.h:1871
void reserve(int size)
Definition: qset.h:241