~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/xmlpatterns/schema/qxsdelement_p.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
 
4
** All rights reserved.
 
5
** Contact: Nokia Corporation (qt-info@nokia.com)
 
6
**
 
7
** This file is part of the QtXmlPatterns module of the Qt Toolkit.
 
8
**
 
9
** $QT_BEGIN_LICENSE:LGPL$
 
10
** No Commercial Usage
 
11
** This file contains pre-release code and may not be distributed.
 
12
** You may use this file in accordance with the terms and conditions
 
13
** contained in the Technology Preview License Agreement accompanying
 
14
** this package.
 
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
** If you have questions regarding the use of this file, please contact
 
29
** Nokia at qt-info@nokia.com.
 
30
**
 
31
**
 
32
**
 
33
**
 
34
**
 
35
**
 
36
**
 
37
**
 
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_XsdElement_H
 
53
#define Patternist_XsdElement_H
 
54
 
 
55
#include "qschemacomponent_p.h"
 
56
#include "qschematype_p.h"
 
57
#include "qxsdalternative_p.h"
 
58
#include "qxsdidentityconstraint_p.h"
 
59
#include "qxsdcomplextype_p.h"
 
60
 
 
61
#include <QtCore/QList>
 
62
#include <QtCore/QSet>
 
63
 
 
64
QT_BEGIN_HEADER
 
65
 
 
66
QT_BEGIN_NAMESPACE
 
67
 
 
68
namespace QPatternist
 
69
{
 
70
    /**
 
71
     * @short Represents a XSD element object.
 
72
     *
 
73
     * This class represents the <em>element</em> object of a XML schema as described
 
74
     * <a href="http://www.w3.org/TR/xmlschema11-1/#cElement_Declarations">here</a>.
 
75
     *
 
76
     * It contains information from either a top-level element declaration (as child of a <em>schema</em> object)
 
77
     * or a local element declaration (as descendant of an <em>complexType</em> object).
 
78
     *
 
79
     * @see <a href="http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040309/xml-schema-api.html#Interface-XSElementDecl">XML Schema API reference</a>
 
80
     * @ingroup Patternist_schema
 
81
     * @author Tobias Koenig <tobias.koenig@nokia.com>
 
82
     */
 
83
    class XsdElement : public XsdTerm
 
84
    {
 
85
        public:
 
86
            typedef QExplicitlySharedDataPointer<XsdElement> Ptr;
 
87
            typedef QList<XsdElement::Ptr> List;
 
88
 
 
89
 
 
90
            /**
 
91
             * Describes the <a href="http://www.w3.org/TR/xmlschema11-1/#ed-value_constraint">constraint type</a> of the element.
 
92
             */
 
93
            enum ConstraintType
 
94
            {
 
95
                NoneConstraint,     ///< The value of the element has no constraints.
 
96
                DefaultConstraint,  ///< The element has a default value set.
 
97
                FixedConstraint     ///< The element has a fixed value set.
 
98
            };
 
99
 
 
100
            /**
 
101
             * Describes the scope of an element.
 
102
             *
 
103
             * @see <a href="http://www.w3.org/TR/xmlschema11-1/#sc_e">Scope Definition</a>
 
104
             */
 
105
            class Scope : public QSharedData
 
106
            {
 
107
                public:
 
108
                    typedef QExplicitlySharedDataPointer<Scope> Ptr;
 
109
 
 
110
                    /**
 
111
                     * Describes the <a href="http://www.w3.org/TR/xmlschema11-1/#ad-scope">scope</a> of an attribute.
 
112
                     */
 
113
                    enum Variety
 
114
                    {
 
115
                        Global,    ///< The element is defined globally as child of the <em>schema</em> object.
 
116
                        Local      ///< The element is defined locally as child of a complex type or model group definition.
 
117
                    };
 
118
 
 
119
                    /**
 
120
                     * Sets the @p variety of the element scope.
 
121
                     */
 
122
                    void setVariety(Variety variety);
 
123
 
 
124
                    /**
 
125
                     * Returns the variety of the element scope.
 
126
                     */
 
127
                    Variety variety() const;
 
128
 
 
129
                    /**
 
130
                     * Sets the @p parent complex type or model group definition of the element scope.
 
131
                     */
 
132
                    void setParent(const NamedSchemaComponent::Ptr &parent);
 
133
 
 
134
                    /**
 
135
                     * Returns the parent complex type or model group definition of the element scope.
 
136
                     */
 
137
                    NamedSchemaComponent::Ptr parent() const;
 
138
 
 
139
                private:
 
140
                    Variety                   m_variety;
 
141
                    NamedSchemaComponent::Ptr m_parent;
 
142
            };
 
143
 
 
144
            /**
 
145
             * Describes a type table of an element.
 
146
             *
 
147
             * @see <a href="http://www.w3.org/TR/xmlschema11-1/#tt">Type Table Definition</a>
 
148
             */
 
149
            class TypeTable : public QSharedData
 
150
            {
 
151
                public:
 
152
                    typedef QExplicitlySharedDataPointer<TypeTable> Ptr;
 
153
 
 
154
                    /**
 
155
                     * Adds an @p alternative to the type table.
 
156
                     */
 
157
                    void addAlternative(const XsdAlternative::Ptr &alternative);
 
158
 
 
159
                    /**
 
160
                     * Returns the alternatives of the type table.
 
161
                     */
 
162
                    XsdAlternative::List alternatives() const;
 
163
 
 
164
                    /**
 
165
                     * Sets the default @p type definition.
 
166
                     */
 
167
                    void setDefaultTypeDefinition(const XsdAlternative::Ptr &type);
 
168
 
 
169
                    /**
 
170
                     * Returns the default type definition.
 
171
                     */
 
172
                    XsdAlternative::Ptr defaultTypeDefinition() const;
 
173
 
 
174
                private:
 
175
                    XsdAlternative::List m_alternatives;
 
176
                    XsdAlternative::Ptr  m_defaultTypeDefinition;
 
177
            };
 
178
 
 
179
 
 
180
            /**
 
181
             * Describes the value constraint of an element.
 
182
             *
 
183
             * @see <a href="http://www.w3.org/TR/xmlschema11-1/#vc_e">Value Constraint Definition</a>
 
184
             */
 
185
            class ValueConstraint : public QSharedData
 
186
            {
 
187
                public:
 
188
                    typedef QExplicitlySharedDataPointer<ValueConstraint> Ptr;
 
189
 
 
190
                    /**
 
191
                     * Describes the <a href="http://www.w3.org/TR/xmlschema11-1/#ed-value_constraint">value constraint</a> of an element.
 
192
                     */
 
193
                    enum Variety
 
194
                    {
 
195
                        Default,  ///< The element has a default value set.
 
196
                        Fixed     ///< The element has a fixed value set.
 
197
                    };
 
198
 
 
199
                    /**
 
200
                     * Sets the @p variety of the element value constraint.
 
201
                     */
 
202
                    void setVariety(Variety variety);
 
203
 
 
204
                    /**
 
205
                     * Returns the variety of the element value constraint.
 
206
                     */
 
207
                    Variety variety() const;
 
208
 
 
209
                    /**
 
210
                     * Sets the @p value of the constraint.
 
211
                     */
 
212
                    void setValue(const QString &value);
 
213
 
 
214
                    /**
 
215
                     * Returns the value of the constraint.
 
216
                     */
 
217
                    QString value() const;
 
218
 
 
219
                    /**
 
220
                     * Sets the lexical @p form of the constraint.
 
221
                     */
 
222
                    void setLexicalForm(const QString &form);
 
223
 
 
224
                    /**
 
225
                     * Returns the lexical form of the constraint.
 
226
                     */
 
227
                    QString lexicalForm() const;
 
228
 
 
229
                private:
 
230
                    Variety m_variety;
 
231
                    QString m_value;
 
232
                    QString m_lexicalForm;
 
233
            };
 
234
 
 
235
            /**
 
236
             * Creates a new element object.
 
237
             */
 
238
            XsdElement();
 
239
 
 
240
            /**
 
241
             * Always returns @c true, used to avoid dynamic casts.
 
242
             */
 
243
            virtual bool isElement() const;
 
244
 
 
245
            /**
 
246
             * Sets the @p type of the element.
 
247
             *
 
248
             * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-type_definition">Type Definition</a>
 
249
             */
 
250
            void setType(const SchemaType::Ptr &type);
 
251
 
 
252
            /**
 
253
             * Returns the type of the element.
 
254
             */
 
255
            SchemaType::Ptr type() const;
 
256
 
 
257
            /**
 
258
             * Sets the @p scope of the element.
 
259
             *
 
260
             * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-scope">Scope Definition</a>
 
261
             */
 
262
            void setScope(const Scope::Ptr &scope);
 
263
 
 
264
            /**
 
265
             * Returns the scope of the element.
 
266
             */
 
267
            Scope::Ptr scope() const;
 
268
 
 
269
            /**
 
270
             * Sets the value @p constraint of the element.
 
271
             *
 
272
             * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-value_constraint">Value Constraint Definition</a>
 
273
             */
 
274
            void setValueConstraint(const ValueConstraint::Ptr &constraint);
 
275
 
 
276
            /**
 
277
             * Returns the value constraint of the element.
 
278
             */
 
279
            ValueConstraint::Ptr valueConstraint() const;
 
280
 
 
281
            /**
 
282
             * Sets the type table of the element.
 
283
             *
 
284
             * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-type_table">Type Table Definition</a>
 
285
             */
 
286
            void setTypeTable(const TypeTable::Ptr &table);
 
287
 
 
288
            /**
 
289
             * Returns the type table of the element.
 
290
             */
 
291
            TypeTable::Ptr typeTable() const;
 
292
 
 
293
            /**
 
294
             * Sets whether the element is @p abstract.
 
295
             *
 
296
             * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-abstract">Abstract Definition</a>
 
297
             */
 
298
            void setIsAbstract(bool abstract);
 
299
 
 
300
            /**
 
301
             * Returns whether the element is abstract.
 
302
             */
 
303
            bool isAbstract() const;
 
304
 
 
305
            /**
 
306
             * Sets whether the element is @p nillable.
 
307
             *
 
308
             * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-nillable">Nillable Definition</a>
 
309
             */
 
310
            void setIsNillable(bool nillable);
 
311
 
 
312
            /**
 
313
             * Returns whether the element is nillable.
 
314
             */
 
315
            bool isNillable() const;
 
316
 
 
317
            /**
 
318
             * Sets the disallowed @p substitutions of the element.
 
319
             *
 
320
             * Only ExtensionConstraint, RestrictionConstraint and SubstitutionConstraint are allowed.
 
321
             *
 
322
             * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-disallowed_substitutions">Disallowed Substitutions Definition</a>
 
323
             */
 
324
            void setDisallowedSubstitutions(const BlockingConstraints &substitutions);
 
325
 
 
326
            /**
 
327
             * Returns the disallowed substitutions of the element.
 
328
             */
 
329
            BlockingConstraints disallowedSubstitutions() const;
 
330
 
 
331
            /**
 
332
             * Sets the substitution group @p exclusions of the element.
 
333
             *
 
334
             * Only SchemaType::ExtensionConstraint and SchemaType::RestrictionConstraint are allowed.
 
335
             *
 
336
             * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-substitution_group_exclusions">Substitution Group Exclusions Definition</a>
 
337
             */
 
338
            void setSubstitutionGroupExclusions(const SchemaType::DerivationConstraints &exclusions);
 
339
 
 
340
            /**
 
341
             * Returns the substitution group exclusions of the element.
 
342
             */
 
343
            SchemaType::DerivationConstraints substitutionGroupExclusions() const;
 
344
 
 
345
            /**
 
346
             * Sets the identity @p constraints of the element.
 
347
             *
 
348
             * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-identity-constraint_definitions">Identity Constraint Definition</a>
 
349
             */
 
350
            void setIdentityConstraints(const XsdIdentityConstraint::List &constraints);
 
351
 
 
352
            /**
 
353
             * Adds a new identity @p constraint to the element.
 
354
             */
 
355
            void addIdentityConstraint(const XsdIdentityConstraint::Ptr &constraint);
 
356
 
 
357
            /**
 
358
             * Returns a list of all identity constraints of the element.
 
359
             */
 
360
            XsdIdentityConstraint::List identityConstraints() const;
 
361
 
 
362
            /**
 
363
             * Sets the substitution group @p affiliations of the element.
 
364
             *
 
365
             * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-substituion_group_affiliations">Substitution Group Affiliations</a>
 
366
             */
 
367
            void setSubstitutionGroupAffiliations(const XsdElement::List &affiliations);
 
368
 
 
369
            /**
 
370
             * Returns the substitution group affiliations of the element.
 
371
             */
 
372
            XsdElement::List substitutionGroupAffiliations() const;
 
373
 
 
374
            /**
 
375
             * Adds a substitution group to the element.
 
376
             */
 
377
            void addSubstitutionGroup(const XsdElement::Ptr &elements);
 
378
 
 
379
            /**
 
380
             * Returns the substitution groups of the element.
 
381
             */
 
382
            XsdElement::List substitutionGroups() const;
 
383
 
 
384
        private:
 
385
            SchemaType::Ptr                   m_type;
 
386
            Scope::Ptr                        m_scope;
 
387
            ValueConstraint::Ptr              m_valueConstraint;
 
388
            TypeTable::Ptr                    m_typeTable;
 
389
            bool                              m_isAbstract;
 
390
            bool                              m_isNillable;
 
391
            BlockingConstraints               m_disallowedSubstitutions;
 
392
            SchemaType::DerivationConstraints m_substitutionGroupExclusions;
 
393
            XsdIdentityConstraint::List       m_identityConstraints;
 
394
            XsdElement::List                  m_substitutionGroupAffiliations;
 
395
            QSet<XsdElement::Ptr>             m_substitutionGroups;
 
396
    };
 
397
}
 
398
 
 
399
QT_END_NAMESPACE
 
400
 
 
401
QT_END_HEADER
 
402
 
 
403
#endif