1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 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 The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/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 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 // 41 // W A R N I N G 42 // ------------- 43 // 44 // This file is not part of the Qt API. It exists purely as an 45 // implementation detail. This header file may change from version to 46 // version without notice, or even be removed. 47 // 48 // We mean it. 49 50 #ifndef Patternist_XsdComplexType_H 51 #define Patternist_XsdComplexType_H 52 53 #include <private/qanytype_p.h> 54 #include <private/qxsdassertion_p.h> 55 #include <private/qxsdattributeuse_p.h> 56 #include <private/qxsdparticle_p.h> 57 #include <private/qxsdsimpletype_p.h> 58 #include <private/qxsduserschematype_p.h> 59 #include <private/qxsdwildcard_p.h> 60 61 #include <QtCore/QSet> 62 63 QT_BEGIN_NAMESPACE 64 65 namespace QPatternist 66 { 67 /** 68 * @short Represents a XSD complexType object. 69 * 70 * This class represents the <em>complexType</em> object of a XML schema as described 71 * <a href="http://www.w3.org/TR/xmlschema11-1/#Complex_Type_Definitions">here</a>. 72 * 73 * It contains information from either a top-level complex type declaration (as child of a <em>schema</em> object) 74 * or a local complex type declaration (as descendant of an <em>element</em> object). 75 * 76 * @see <a href="http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040309/xml-schema-api.html#Interface-XSComplexType">XML Schema API reference</a> 77 * @ingroup Patternist_schema 78 * @author Tobias Koenig <tobias.koenig@nokia.com> 79 */ 80 class XsdComplexType : public XsdUserSchemaType<AnyType> 81 { 82 public: 83 typedef QExplicitlySharedDataPointer<XsdComplexType> Ptr; 84 85 /** 86 * @short Describes the open content object of a complex type. 87 * 88 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-open_content">Open Content Definition</a> 89 */ 90 class OpenContent : public QSharedData, public XsdAnnotated 91 { 92 public: 93 typedef QExplicitlySharedDataPointer<OpenContent> Ptr; 94 95 /** 96 * Describes the mode of the open content. 97 * 98 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#oc-mode">Mode Definition</a> 99 */ 100 enum Mode 101 { 102 None, 103 Interleave, 104 Suffix 105 }; 106 107 /** 108 * Sets the @p mode of the open content. 109 * 110 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#oc-mode">Mode Definition</a> 111 */ 112 void setMode(Mode mode); 113 114 /** 115 * Returns the mode of the open content. 116 */ 117 Mode mode() const; 118 119 /** 120 * Sets the @p wildcard of the open content. 121 * 122 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#oc-wildcard">Wildcard Definition</a> 123 */ 124 void setWildcard(const XsdWildcard::Ptr &wildcard); 125 126 /** 127 * Returns the wildcard of the open content. 128 */ 129 XsdWildcard::Ptr wildcard() const; 130 131 private: 132 Mode m_mode; 133 XsdWildcard::Ptr m_wildcard; 134 }; 135 136 /** 137 * @short Describes the content type of a complex type. 138 */ 139 class ContentType : public QSharedData 140 { 141 public: 142 typedef QExplicitlySharedDataPointer<ContentType> Ptr; 143 144 /** 145 * Describes the variety of the content type. 146 */ 147 enum Variety 148 { 149 Empty = 0, ///< The complex type has no further content. 150 Simple, ///< The complex type has only simple type content (e.g. text, number etc.) 151 ElementOnly, ///< The complex type has further elements or attributes but no text as content. 152 Mixed ///< The complex type has further elements or attributes and text as content. 153 }; 154 155 /** 156 * Sets the @p variety of the content type. 157 * 158 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-variety">Variety Definition</a> 159 */ 160 void setVariety(Variety variety); 161 162 /** 163 * Returns the variety of the content type. 164 */ 165 Variety variety() const; 166 167 /** 168 * Sets the @p particle object of the content type. 169 * 170 * The content type has only a particle object if 171 * its variety is ElementOnly or Mixed. 172 * 173 * @see XsdParticle 174 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-particle">Particle Declaration</a> 175 */ 176 void setParticle(const XsdParticle::Ptr &particle); 177 178 /** 179 * Returns the particle object of the content type, 180 * or an empty pointer if its variety is neither 181 * ElementOnly nor Mixed. 182 */ 183 XsdParticle::Ptr particle() const; 184 185 /** 186 * Sets the open @p content object of the content type. 187 * 188 * The content type has only an open content object if 189 * its variety is ElementOnly or Mixed. 190 * 191 * @see OpenContent 192 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-open_content">Open Content Declaration</a> 193 */ 194 void setOpenContent(const OpenContent::Ptr &content); 195 196 /** 197 * Returns the open content object of the content type, 198 * or an empty pointer if its variety is neither 199 * ElementOnly nor Mixed. 200 */ 201 OpenContent::Ptr openContent() const; 202 203 /** 204 * Sets the simple @p type object of the content type. 205 * 206 * The content type has only a simple type object if 207 * its variety is Simple. 208 * 209 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-simple_type_definition">Simple Type Definition</a> 210 */ 211 void setSimpleType(const AnySimpleType::Ptr &type); 212 213 /** 214 * Returns the simple type object of the content type, 215 * or an empty pointer if its variety is not Simple. 216 */ 217 AnySimpleType::Ptr simpleType() const; 218 219 private: 220 Variety m_variety; 221 XsdParticle::Ptr m_particle; 222 OpenContent::Ptr m_openContent; 223 XsdSimpleType::Ptr m_simpleType; 224 }; 225 226 227 /** 228 * Creates a complex type object with empty content. 229 */ 230 XsdComplexType(); 231 232 /** 233 * Destroys the complex type object. 234 */ ~XsdComplexType()235 ~XsdComplexType() {}; 236 237 /** 238 * Returns the display name of the complex type. 239 * 240 * The display name can be used to show the type name 241 * to the user. 242 * 243 * @param namePool The name pool where the type name is stored in. 244 */ 245 virtual QString displayName(const NamePool::Ptr &namePool) const; 246 247 /** 248 * Sets the base type of the complex type. 249 * 250 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-base_type_definition">Base Type Definition</a> 251 */ 252 void setWxsSuperType(const SchemaType::Ptr &type); 253 254 /** 255 * Returns the base type of the complex type. 256 */ 257 virtual SchemaType::Ptr wxsSuperType() const; 258 259 /** 260 * Sets the context @p component of the complex type. 261 * 262 * The component is either an element declaration or a complex type definition. 263 */ 264 void setContext(const NamedSchemaComponent::Ptr &component); 265 266 /** 267 * Returns the context component of the complex type. 268 */ 269 NamedSchemaComponent::Ptr context() const; 270 271 /** 272 * Sets the derivation @p method of the complex type. 273 * 274 * The derivation method depends on whether the complex 275 * type object has an extension or restriction object as child. 276 * 277 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-derivation_method">Derivation Method Definition</a> 278 * @see DerivationMethod 279 */ 280 void setDerivationMethod(DerivationMethod method); 281 282 /** 283 * Returns the derivation method of the complex type. 284 */ 285 virtual DerivationMethod derivationMethod() const; 286 287 /** 288 * Sets whether the complex type is @p abstract. 289 * 290 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-abstract">Abstract Definition</a> 291 */ 292 void setIsAbstract(bool abstract); 293 294 /** 295 * Returns whether the complex type is abstract. 296 */ 297 virtual bool isAbstract() const; 298 299 /** 300 * Sets the list of all attribute @p uses of the complex type. 301 * 302 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-attribute_uses">Attribute Uses Declaration</a> 303 */ 304 void setAttributeUses(const XsdAttributeUse::List &uses); 305 306 /** 307 * Adds a new attribute @p use to the complex type. 308 */ 309 void addAttributeUse(const XsdAttributeUse::Ptr &use); 310 311 /** 312 * Returns the list of all attribute uses of the complex type. 313 */ 314 XsdAttributeUse::List attributeUses() const; 315 316 /** 317 * Sets the attribute @p wildcard of the complex type. 318 * 319 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-attribute_wildcard">Attribute Wildcard Declaration</a> 320 */ 321 void setAttributeWildcard(const XsdWildcard::Ptr &wildcard); 322 323 /** 324 * Returns the attribute wildcard of the complex type. 325 */ 326 XsdWildcard::Ptr attributeWildcard() const; 327 328 /** 329 * Always returns SchemaType::ComplexType 330 */ 331 virtual TypeCategory category() const; 332 333 /** 334 * Sets the content @p type of the complex type. 335 * 336 * @see ContentType 337 */ 338 void setContentType(const ContentType::Ptr &type); 339 340 /** 341 * Returns the content type of the complex type. 342 */ 343 ContentType::Ptr contentType() const; 344 345 /** 346 * Sets the prohibited @p substitutions of the complex type. 347 * 348 * Only ExtensionConstraint and RestrictionConstraint are allowed. 349 * 350 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-prohibited_substitutions">Prohibited Substitutions Definition</a> 351 */ 352 void setProhibitedSubstitutions(const BlockingConstraints &substitutions); 353 354 /** 355 * Returns the prohibited substitutions of the complex type. 356 */ 357 BlockingConstraints prohibitedSubstitutions() const; 358 359 /** 360 * Sets the @p assertions of the complex type. 361 * 362 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-assertions">Assertions Definition</a> 363 */ 364 void setAssertions(const XsdAssertion::List &assertions); 365 366 /** 367 * Adds an @p assertion to the complex type. 368 * 369 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-assertions">Assertions Definition</a> 370 */ 371 void addAssertion(const XsdAssertion::Ptr &assertion); 372 373 /** 374 * Returns the assertions of the complex type. 375 */ 376 XsdAssertion::List assertions() const; 377 378 /** 379 * Always returns @c true. 380 */ 381 virtual bool isDefinedBySchema() const; 382 383 private: 384 SchemaType::Ptr m_superType; 385 NamedSchemaComponent::Ptr m_context; 386 DerivationMethod m_derivationMethod; 387 bool m_isAbstract; 388 XsdAttributeUse::List m_attributeUses; 389 XsdWildcard::Ptr m_attributeWildcard; 390 ContentType::Ptr m_contentType; 391 BlockingConstraints m_prohibitedSubstitutions; 392 XsdAssertion::List m_assertions; 393 }; 394 } 395 396 QT_END_NAMESPACE 397 398 #endif 399