[556] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
| 3 | ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
---|
| 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
| 6 | **
|
---|
| 7 | ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 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 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
| 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 <[email protected]>
|
---|
| 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
|
---|