1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
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.
52 #ifndef Patternist_XsdComplexType_H
53 #define Patternist_XsdComplexType_H
55 #include <private/qanytype_p.h>
56 #include <private/qxsdassertion_p.h>
57 #include <private/qxsdattributeuse_p.h>
58 #include <private/qxsdparticle_p.h>
59 #include <private/qxsdsimpletype_p.h>
60 #include <private/qxsduserschematype_p.h>
61 #include <private/qxsdwildcard_p.h>
63 #include <QtCore/QSet>
72 * @short Represents a XSD complexType object.
74 * This class represents the <em>complexType</em> object of a XML schema as described
75 * <a href="http://www.w3.org/TR/xmlschema11-1/#Complex_Type_Definitions">here</a>.
77 * It contains information from either a top-level complex type declaration (as child of a <em>schema</em> object)
78 * or a local complex type declaration (as descendant of an <em>element</em> object).
80 * @see <a href="http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040309/xml-schema-api.html#Interface-XSComplexType">XML Schema API reference</a>
81 * @ingroup Patternist_schema
82 * @author Tobias Koenig <tobias.koenig@nokia.com>
84 class XsdComplexType : public XsdUserSchemaType<AnyType>
87 typedef QExplicitlySharedDataPointer<XsdComplexType> Ptr;
90 * @short Describes the open content object of a complex type.
92 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-open_content">Open Content Definition</a>
94 class OpenContent : public QSharedData, public XsdAnnotated
97 typedef QExplicitlySharedDataPointer<OpenContent> Ptr;
100 * Describes the mode of the open content.
102 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#oc-mode">Mode Definition</a>
112 * Sets the @p mode of the open content.
114 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#oc-mode">Mode Definition</a>
116 void setMode(Mode mode);
119 * Returns the mode of the open content.
124 * Sets the @p wildcard of the open content.
126 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#oc-wildcard">Wildcard Definition</a>
128 void setWildcard(const XsdWildcard::Ptr &wildcard);
131 * Returns the wildcard of the open content.
133 XsdWildcard::Ptr wildcard() const;
137 XsdWildcard::Ptr m_wildcard;
141 * @short Describes the content type of a complex type.
143 class ContentType : public QSharedData
146 typedef QExplicitlySharedDataPointer<ContentType> Ptr;
149 * Describes the variety of the content type.
153 Empty = 0, ///< The complex type has no further content.
154 Simple, ///< The complex type has only simple type content (e.g. text, number etc.)
155 ElementOnly, ///< The complex type has further elements or attributes but no text as content.
156 Mixed ///< The complex type has further elements or attributes and text as content.
160 * Sets the @p variety of the content type.
162 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-variety">Variety Definition</a>
164 void setVariety(Variety variety);
167 * Returns the variety of the content type.
169 Variety variety() const;
172 * Sets the @p particle object of the content type.
174 * The content type has only a particle object if
175 * its variety is ElementOnly or Mixed.
178 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-particle">Particle Declaration</a>
180 void setParticle(const XsdParticle::Ptr &particle);
183 * Returns the particle object of the content type,
184 * or an empty pointer if its variety is neither
185 * ElementOnly nor Mixed.
187 XsdParticle::Ptr particle() const;
190 * Sets the open @p content object of the content type.
192 * The content type has only an open content object if
193 * its variety is ElementOnly or Mixed.
196 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-open_content">Open Content Declaration</a>
198 void setOpenContent(const OpenContent::Ptr &content);
201 * Returns the open content object of the content type,
202 * or an empty pointer if its variety is neither
203 * ElementOnly nor Mixed.
205 OpenContent::Ptr openContent() const;
208 * Sets the simple @p type object of the content type.
210 * The content type has only a simple type object if
211 * its variety is Simple.
213 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ct-simple_type_definition">Simple Type Definition</a>
215 void setSimpleType(const AnySimpleType::Ptr &type);
218 * Returns the simple type object of the content type,
219 * or an empty pointer if its variety is not Simple.
221 AnySimpleType::Ptr simpleType() const;
225 XsdParticle::Ptr m_particle;
226 OpenContent::Ptr m_openContent;
227 XsdSimpleType::Ptr m_simpleType;
232 * Creates a complex type object with empty content.
237 * Destroys the complex type object.
239 ~XsdComplexType() {};
242 * Returns the display name of the complex type.
244 * The display name can be used to show the type name
247 * @param namePool The name pool where the type name is stored in.
249 virtual QString displayName(const NamePool::Ptr &namePool) const;
252 * Sets the base type of the complex type.
254 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-base_type_definition">Base Type Definition</a>
256 void setWxsSuperType(const SchemaType::Ptr &type);
259 * Returns the base type of the complex type.
261 virtual SchemaType::Ptr wxsSuperType() const;
264 * Sets the context @p component of the complex type.
266 * The component is either an element declaration or a complex type definition.
268 void setContext(const NamedSchemaComponent::Ptr &component);
271 * Returns the context component of the complex type.
273 NamedSchemaComponent::Ptr context() const;
276 * Sets the derivation @p method of the complex type.
278 * The derivation method depends on whether the complex
279 * type object has an extension or restriction object as child.
281 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-derivation_method">Derivation Method Definition</a>
282 * @see DerivationMethod
284 void setDerivationMethod(DerivationMethod method);
287 * Returns the derivation method of the complex type.
289 virtual DerivationMethod derivationMethod() const;
292 * Sets whether the complex type is @p abstract.
294 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-abstract">Abstract Definition</a>
296 void setIsAbstract(bool abstract);
299 * Returns whether the complex type is abstract.
301 virtual bool isAbstract() const;
304 * Sets the list of all attribute @p uses of the complex type.
306 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-attribute_uses">Attribute Uses Declaration</a>
308 void setAttributeUses(const XsdAttributeUse::List &uses);
311 * Adds a new attribute @p use to the complex type.
313 void addAttributeUse(const XsdAttributeUse::Ptr &use);
316 * Returns the list of all attribute uses of the complex type.
318 XsdAttributeUse::List attributeUses() const;
321 * Sets the attribute @p wildcard of the complex type.
323 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-attribute_wildcard">Attribute Wildcard Declaration</a>
325 void setAttributeWildcard(const XsdWildcard::Ptr &wildcard);
328 * Returns the attribute wildcard of the complex type.
330 XsdWildcard::Ptr attributeWildcard() const;
333 * Always returns SchemaType::ComplexType
335 virtual TypeCategory category() const;
338 * Sets the content @p type of the complex type.
342 void setContentType(const ContentType::Ptr &type);
345 * Returns the content type of the complex type.
347 ContentType::Ptr contentType() const;
350 * Sets the prohibited @p substitutions of the complex type.
352 * Only ExtensionConstraint and RestrictionConstraint are allowed.
354 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-prohibited_substitutions">Prohibited Substitutions Definition</a>
356 void setProhibitedSubstitutions(const BlockingConstraints &substitutions);
359 * Returns the prohibited substitutions of the complex type.
361 BlockingConstraints prohibitedSubstitutions() const;
364 * Sets the @p assertions of the complex type.
366 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-assertions">Assertions Definition</a>
368 void setAssertions(const XsdAssertion::List &assertions);
371 * Adds an @p assertion to the complex type.
373 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ctd-assertions">Assertions Definition</a>
375 void addAssertion(const XsdAssertion::Ptr &assertion);
378 * Returns the assertions of the complex type.
380 XsdAssertion::List assertions() const;
383 * Always returns @c true.
385 virtual bool isDefinedBySchema() const;
388 SchemaType::Ptr m_superType;
389 NamedSchemaComponent::Ptr m_context;
390 DerivationMethod m_derivationMethod;
392 XsdAttributeUse::List m_attributeUses;
393 XsdWildcard::Ptr m_attributeWildcard;
394 ContentType::Ptr m_contentType;
395 BlockingConstraints m_prohibitedSubstitutions;
396 XsdAssertion::List m_assertions;