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_XsdAttribute_H
|
---|
53 | #define Patternist_XsdAttribute_H
|
---|
54 |
|
---|
55 | #include "qanysimpletype_p.h"
|
---|
56 | #include "qnamedschemacomponent_p.h"
|
---|
57 | #include "qxsdannotated_p.h"
|
---|
58 |
|
---|
59 | #include <QtCore/QList>
|
---|
60 |
|
---|
61 | QT_BEGIN_HEADER
|
---|
62 |
|
---|
63 | QT_BEGIN_NAMESPACE
|
---|
64 |
|
---|
65 | namespace QPatternist
|
---|
66 | {
|
---|
67 | /**
|
---|
68 | * @short Represents a XSD attribute object.
|
---|
69 | *
|
---|
70 | * This class represents the <em>attribute</em> object of a XML schema as described
|
---|
71 | * <a href="http://www.w3.org/TR/xmlschema11-1/#cAttribute_Declarations">here</a>.
|
---|
72 | *
|
---|
73 | * It contains information from either a top-level attribute declaration (as child of
|
---|
74 | * a <em>schema</em> object) or of a local attribute declaration (as child of <em>complexType</em>
|
---|
75 | * or <em>attributeGroup</em> object without a 'ref' attribute).
|
---|
76 | *
|
---|
77 | * All other occurrences of the <em>attribute</em> object are represented by the XsdAttributeUse class.
|
---|
78 | *
|
---|
79 | * @see <a href="http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040309/xml-schema-api.html#Interface-XSAttributeDeclaration">XML Schema API reference</a>
|
---|
80 | * @ingroup Patternist_schema
|
---|
81 | * @author Tobias Koenig <[email protected]>
|
---|
82 | */
|
---|
83 | class XsdAttribute : public NamedSchemaComponent, public XsdAnnotated
|
---|
84 | {
|
---|
85 | public:
|
---|
86 | typedef QExplicitlySharedDataPointer<XsdAttribute> Ptr;
|
---|
87 | typedef QList<XsdAttribute::Ptr> List;
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * @short Describes the scope of an attribute.
|
---|
91 | *
|
---|
92 | * @see <a href="http://www.w3.org/TR/xmlschema11-1/#sc_a">Scope Definition</a>
|
---|
93 | */
|
---|
94 | class Scope : public QSharedData
|
---|
95 | {
|
---|
96 | public:
|
---|
97 | typedef QExplicitlySharedDataPointer<Scope> Ptr;
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Describes the <a href="http://www.w3.org/TR/xmlschema11-1/#ad-scope">scope</a> of an attribute.
|
---|
101 | */
|
---|
102 | enum Variety
|
---|
103 | {
|
---|
104 | Global, ///< The attribute is defined globally as child of the <em>schema</em> object.
|
---|
105 | Local ///< The attribute is defined locally as child of a complex type or attribute group definition.
|
---|
106 | };
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * Sets the @p variety of the attribute scope.
|
---|
110 | *
|
---|
111 | * @see <a href="http://www.w3.org/TR/xmlschema11-1/#sc_a-variety">Variety Definition</a>
|
---|
112 | */
|
---|
113 | void setVariety(Variety variety);
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * Returns the variety of the attribute scope.
|
---|
117 | */
|
---|
118 | Variety variety() const;
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * Sets the @p parent complex type or attribute group definition of the attribute scope.
|
---|
122 | *
|
---|
123 | * @see <a href="http://www.w3.org/TR/xmlschema11-1/#sc_a-parent">Parent Definition</a>
|
---|
124 | */
|
---|
125 | void setParent(const NamedSchemaComponent::Ptr &parent);
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * Returns the parent complex type or attribute group definition of the attribute scope.
|
---|
129 | */
|
---|
130 | NamedSchemaComponent::Ptr parent() const;
|
---|
131 |
|
---|
132 | private:
|
---|
133 | Variety m_variety;
|
---|
134 | NamedSchemaComponent::Ptr m_parent;
|
---|
135 | };
|
---|
136 |
|
---|
137 |
|
---|
138 | /**
|
---|
139 | * @short Describes the value constraint of an attribute.
|
---|
140 | *
|
---|
141 | * @see <a href="http://www.w3.org/TR/xmlschema11-1/#vc_a">Value Constraint Definition</a>
|
---|
142 | */
|
---|
143 | class ValueConstraint : public QSharedData
|
---|
144 | {
|
---|
145 | public:
|
---|
146 | typedef QExplicitlySharedDataPointer<ValueConstraint> Ptr;
|
---|
147 |
|
---|
148 | /**
|
---|
149 | * Describes the <a href="http://www.w3.org/TR/xmlschema11-1/#ad-value_constraint">value constraint</a> of an attribute.
|
---|
150 | */
|
---|
151 | enum Variety
|
---|
152 | {
|
---|
153 | Default, ///< The attribute has a default value set.
|
---|
154 | Fixed ///< The attribute has a fixed value set.
|
---|
155 | };
|
---|
156 |
|
---|
157 | /**
|
---|
158 | * Sets the @p variety of the attribute value constraint.
|
---|
159 | *
|
---|
160 | * @see <a href="http://www.w3.org/TR/xmlschema11-1/#vc_a-variety">Variety Definition</a>
|
---|
161 | */
|
---|
162 | void setVariety(Variety variety);
|
---|
163 |
|
---|
164 | /**
|
---|
165 | * Returns the variety of the attribute value constraint.
|
---|
166 | */
|
---|
167 | Variety variety() const;
|
---|
168 |
|
---|
169 | /**
|
---|
170 | * Sets the @p value of the constraint.
|
---|
171 | *
|
---|
172 | * @see <a href="http://www.w3.org/TR/xmlschema11-1/#vc_a-value">Value Definition</a>
|
---|
173 | */
|
---|
174 | void setValue(const QString &value);
|
---|
175 |
|
---|
176 | /**
|
---|
177 | * Returns the value of the constraint.
|
---|
178 | */
|
---|
179 | QString value() const;
|
---|
180 |
|
---|
181 | /**
|
---|
182 | * Sets the lexical @p form of the constraint.
|
---|
183 | *
|
---|
184 | * @see <a href="http://www.w3.org/TR/xmlschema11-1/#vc_a-lexical_form">Lexical Form Definition</a>
|
---|
185 | */
|
---|
186 | void setLexicalForm(const QString &form);
|
---|
187 |
|
---|
188 | /**
|
---|
189 | * Returns the lexical form of the constraint.
|
---|
190 | */
|
---|
191 | QString lexicalForm() const;
|
---|
192 |
|
---|
193 | private:
|
---|
194 | Variety m_variety;
|
---|
195 | QString m_value;
|
---|
196 | QString m_lexicalForm;
|
---|
197 | };
|
---|
198 |
|
---|
199 | /**
|
---|
200 | * Sets the simple @p type definition of the attribute.
|
---|
201 | *
|
---|
202 | * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ad-type_definition">Simple Type Definition</a>
|
---|
203 | */
|
---|
204 | void setType(const AnySimpleType::Ptr &type);
|
---|
205 |
|
---|
206 | /**
|
---|
207 | * Returns the simple type definition of the attribute.
|
---|
208 | */
|
---|
209 | AnySimpleType::Ptr type() const;
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * Sets the @p scope of the attribute.
|
---|
213 | *
|
---|
214 | * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ad-scope">Scope Definition</a>
|
---|
215 | */
|
---|
216 | void setScope(const Scope::Ptr &scope);
|
---|
217 |
|
---|
218 | /**
|
---|
219 | * Returns the scope of the attribute.
|
---|
220 | */
|
---|
221 | Scope::Ptr scope() const;
|
---|
222 |
|
---|
223 | /**
|
---|
224 | * Sets the value @p constraint of the attribute.
|
---|
225 | *
|
---|
226 | * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ad-value_constraint">Value Constraint Definition</a>
|
---|
227 | */
|
---|
228 | void setValueConstraint(const ValueConstraint::Ptr &constraint);
|
---|
229 |
|
---|
230 | /**
|
---|
231 | * Returns the value constraint of the attribute.
|
---|
232 | */
|
---|
233 | ValueConstraint::Ptr valueConstraint() const;
|
---|
234 |
|
---|
235 | private:
|
---|
236 | AnySimpleType::Ptr m_type;
|
---|
237 | Scope::Ptr m_scope;
|
---|
238 | ValueConstraint::Ptr m_valueConstraint;
|
---|
239 | };
|
---|
240 | }
|
---|
241 |
|
---|
242 | QT_END_NAMESPACE
|
---|
243 |
|
---|
244 | QT_END_HEADER
|
---|
245 |
|
---|
246 | #endif
|
---|