1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
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 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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_XsdAttribute_H
53 #define Patternist_XsdAttribute_H
55 #include <private/qanysimpletype_p.h>
56 #include <private/qnamedschemacomponent_p.h>
57 #include <private/qxsdannotated_p.h>
59 #include <QtCore/QList>
68 * @short Represents a XSD attribute object.
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>.
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).
77 * All other occurrences of the <em>attribute</em> object are represented by the XsdAttributeUse class.
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 <tobias.koenig@nokia.com>
83 class XsdAttribute : public NamedSchemaComponent, public XsdAnnotated
86 typedef QExplicitlySharedDataPointer<XsdAttribute> Ptr;
87 typedef QList<XsdAttribute::Ptr> List;
90 * @short Describes the scope of an attribute.
92 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#sc_a">Scope Definition</a>
94 class Scope : public QSharedData
97 typedef QExplicitlySharedDataPointer<Scope> Ptr;
100 * Describes the <a href="http://www.w3.org/TR/xmlschema11-1/#ad-scope">scope</a> of an attribute.
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.
109 * Sets the @p variety of the attribute scope.
111 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#sc_a-variety">Variety Definition</a>
113 void setVariety(Variety variety);
116 * Returns the variety of the attribute scope.
118 Variety variety() const;
121 * Sets the @p parent complex type or attribute group definition of the attribute scope.
123 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#sc_a-parent">Parent Definition</a>
125 void setParent(const NamedSchemaComponent::Ptr &parent);
128 * Returns the parent complex type or attribute group definition of the attribute scope.
130 NamedSchemaComponent::Ptr parent() const;
134 NamedSchemaComponent::Ptr m_parent;
139 * @short Describes the value constraint of an attribute.
141 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#vc_a">Value Constraint Definition</a>
143 class ValueConstraint : public QSharedData
146 typedef QExplicitlySharedDataPointer<ValueConstraint> Ptr;
149 * Describes the <a href="http://www.w3.org/TR/xmlschema11-1/#ad-value_constraint">value constraint</a> of an attribute.
153 Default, ///< The attribute has a default value set.
154 Fixed ///< The attribute has a fixed value set.
158 * Sets the @p variety of the attribute value constraint.
160 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#vc_a-variety">Variety Definition</a>
162 void setVariety(Variety variety);
165 * Returns the variety of the attribute value constraint.
167 Variety variety() const;
170 * Sets the @p value of the constraint.
172 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#vc_a-value">Value Definition</a>
174 void setValue(const QString &value);
177 * Returns the value of the constraint.
179 QString value() const;
182 * Sets the lexical @p form of the constraint.
184 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#vc_a-lexical_form">Lexical Form Definition</a>
186 void setLexicalForm(const QString &form);
189 * Returns the lexical form of the constraint.
191 QString lexicalForm() const;
196 QString m_lexicalForm;
200 * Sets the simple @p type definition of the attribute.
202 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ad-type_definition">Simple Type Definition</a>
204 void setType(const AnySimpleType::Ptr &type);
207 * Returns the simple type definition of the attribute.
209 AnySimpleType::Ptr type() const;
212 * Sets the @p scope of the attribute.
214 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ad-scope">Scope Definition</a>
216 void setScope(const Scope::Ptr &scope);
219 * Returns the scope of the attribute.
221 Scope::Ptr scope() const;
224 * Sets the value @p constraint of the attribute.
226 * @see <a href="http://www.w3.org/TR/xmlschema11-1/#ad-value_constraint">Value Constraint Definition</a>
228 void setValueConstraint(const ValueConstraint::Ptr &constraint);
231 * Returns the value constraint of the attribute.
233 ValueConstraint::Ptr valueConstraint() const;
236 AnySimpleType::Ptr m_type;
238 ValueConstraint::Ptr m_valueConstraint;