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