1
/****************************************************************************
3
** Copyright (C) 2008 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
** 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
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.
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.
28
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
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_XsdElement_H
53
#define Patternist_XsdElement_H
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"
61
#include <QtCore/QList>
62
#include <QtCore/QSet>
71
* @short Represents a XSD element object.
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>.
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).
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>
83
class XsdElement : public XsdTerm
86
typedef QExplicitlySharedDataPointer<XsdElement> Ptr;
87
typedef QList<XsdElement::Ptr> List;
91
* Describes the <a href="http://www.w3.org/TR/xmlschema11-1/#ed-value_constraint">constraint type</a> of the element.
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.
101
* Describes the scope of an element.
103
* @see <a href="http://www.w3.org/TR/xmlschema11-1/#sc_e">Scope Definition</a>
105
class Scope : public QSharedData
108
typedef QExplicitlySharedDataPointer<Scope> Ptr;
111
* Describes the <a href="http://www.w3.org/TR/xmlschema11-1/#ad-scope">scope</a> of an attribute.
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.
120
* Sets the @p variety of the element scope.
122
void setVariety(Variety variety);
125
* Returns the variety of the element scope.
127
Variety variety() const;
130
* Sets the @p parent complex type or model group definition of the element scope.
132
void setParent(const NamedSchemaComponent::Ptr &parent);
135
* Returns the parent complex type or model group definition of the element scope.
137
NamedSchemaComponent::Ptr parent() const;
141
NamedSchemaComponent::Ptr m_parent;
145
* Describes a type table of an element.
147
* @see <a href="http://www.w3.org/TR/xmlschema11-1/#tt">Type Table Definition</a>
149
class TypeTable : public QSharedData
152
typedef QExplicitlySharedDataPointer<TypeTable> Ptr;
155
* Adds an @p alternative to the type table.
157
void addAlternative(const XsdAlternative::Ptr &alternative);
160
* Returns the alternatives of the type table.
162
XsdAlternative::List alternatives() const;
165
* Sets the default @p type definition.
167
void setDefaultTypeDefinition(const XsdAlternative::Ptr &type);
170
* Returns the default type definition.
172
XsdAlternative::Ptr defaultTypeDefinition() const;
175
XsdAlternative::List m_alternatives;
176
XsdAlternative::Ptr m_defaultTypeDefinition;
181
* Describes the value constraint of an element.
183
* @see <a href="http://www.w3.org/TR/xmlschema11-1/#vc_e">Value Constraint Definition</a>
185
class ValueConstraint : public QSharedData
188
typedef QExplicitlySharedDataPointer<ValueConstraint> Ptr;
191
* Describes the <a href="http://www.w3.org/TR/xmlschema11-1/#ed-value_constraint">value constraint</a> of an element.
195
Default, ///< The element has a default value set.
196
Fixed ///< The element has a fixed value set.
200
* Sets the @p variety of the element value constraint.
202
void setVariety(Variety variety);
205
* Returns the variety of the element value constraint.
207
Variety variety() const;
210
* Sets the @p value of the constraint.
212
void setValue(const QString &value);
215
* Returns the value of the constraint.
217
QString value() const;
220
* Sets the lexical @p form of the constraint.
222
void setLexicalForm(const QString &form);
225
* Returns the lexical form of the constraint.
227
QString lexicalForm() const;
232
QString m_lexicalForm;
236
* Creates a new element object.
241
* Always returns @c true, used to avoid dynamic casts.
243
virtual bool isElement() const;
246
* Sets the @p type of the element.
248
* @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-type_definition">Type Definition</a>
250
void setType(const SchemaType::Ptr &type);
253
* Returns the type of the element.
255
SchemaType::Ptr type() const;
258
* Sets the @p scope of the element.
260
* @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-scope">Scope Definition</a>
262
void setScope(const Scope::Ptr &scope);
265
* Returns the scope of the element.
267
Scope::Ptr scope() const;
270
* Sets the value @p constraint of the element.
272
* @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-value_constraint">Value Constraint Definition</a>
274
void setValueConstraint(const ValueConstraint::Ptr &constraint);
277
* Returns the value constraint of the element.
279
ValueConstraint::Ptr valueConstraint() const;
282
* Sets the type table of the element.
284
* @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-type_table">Type Table Definition</a>
286
void setTypeTable(const TypeTable::Ptr &table);
289
* Returns the type table of the element.
291
TypeTable::Ptr typeTable() const;
294
* Sets whether the element is @p abstract.
296
* @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-abstract">Abstract Definition</a>
298
void setIsAbstract(bool abstract);
301
* Returns whether the element is abstract.
303
bool isAbstract() const;
306
* Sets whether the element is @p nillable.
308
* @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-nillable">Nillable Definition</a>
310
void setIsNillable(bool nillable);
313
* Returns whether the element is nillable.
315
bool isNillable() const;
318
* Sets the disallowed @p substitutions of the element.
320
* Only ExtensionConstraint, RestrictionConstraint and SubstitutionConstraint are allowed.
322
* @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-disallowed_substitutions">Disallowed Substitutions Definition</a>
324
void setDisallowedSubstitutions(const BlockingConstraints &substitutions);
327
* Returns the disallowed substitutions of the element.
329
BlockingConstraints disallowedSubstitutions() const;
332
* Sets the substitution group @p exclusions of the element.
334
* Only SchemaType::ExtensionConstraint and SchemaType::RestrictionConstraint are allowed.
336
* @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-substitution_group_exclusions">Substitution Group Exclusions Definition</a>
338
void setSubstitutionGroupExclusions(const SchemaType::DerivationConstraints &exclusions);
341
* Returns the substitution group exclusions of the element.
343
SchemaType::DerivationConstraints substitutionGroupExclusions() const;
346
* Sets the identity @p constraints of the element.
348
* @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-identity-constraint_definitions">Identity Constraint Definition</a>
350
void setIdentityConstraints(const XsdIdentityConstraint::List &constraints);
353
* Adds a new identity @p constraint to the element.
355
void addIdentityConstraint(const XsdIdentityConstraint::Ptr &constraint);
358
* Returns a list of all identity constraints of the element.
360
XsdIdentityConstraint::List identityConstraints() const;
363
* Sets the substitution group @p affiliations of the element.
365
* @see <a href="http://www.w3.org/TR/xmlschema11-1/#ed-substituion_group_affiliations">Substitution Group Affiliations</a>
367
void setSubstitutionGroupAffiliations(const XsdElement::List &affiliations);
370
* Returns the substitution group affiliations of the element.
372
XsdElement::List substitutionGroupAffiliations() const;
375
* Adds a substitution group to the element.
377
void addSubstitutionGroup(const XsdElement::Ptr &elements);
380
* Returns the substitution groups of the element.
382
XsdElement::List substitutionGroups() const;
385
SchemaType::Ptr m_type;
387
ValueConstraint::Ptr m_valueConstraint;
388
TypeTable::Ptr m_typeTable;
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;