All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Element.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file Element.h
22 
23  \brief This class models the element of a XML Schema.
24 */
25 
26 #ifndef __TERRALIB_XSD_INTERNAL_ELEMENT_H
27 #define __TERRALIB_XSD_INTERNAL_ELEMENT_H
28 
29 // TerraLib
30 #include "Config.h"
31 #include "Annotated.h"
32 #include "Enums.h"
33 #include "Identifiable.h"
34 #include "Occurs.h"
35 
36 // Boost
37 #include <boost/ptr_container/ptr_vector.hpp>
38 
39 namespace te
40 {
41  namespace xsd
42  {
43 // Forward declarations
44  class IdentityConstraint;
45  class QName;
46  class Type;
47  class Unique;
48 
49  /*!
50  \class Element
51 
52  \brief This class models the element of a XML Schema.
53 
54  \note Parent elements: schema, choice, all, sequence, group.
55  */
56  class TEXSDEXPORT Element : public Occurs, public Identifiable, public Annotated
57  {
58  public:
59 
60  /*!
61  \brief Constructor.
62 
63  \param id It specifies a unique ID for the element. It can be a NULL value.
64  */
65  Element(unsigned int minOccurs = 1, unsigned int maxOccurs = 1, Annotation* ann = 0, std::string* id = 0);
66 
67  /*!
68  \brief Copy constructor.
69 
70  \param rhs Right-hand-side object.
71 
72  \todo Implement!
73  */
74  Element(const Element& rhs);
75 
76  /*!
77  \brief Destructor.
78 
79  \todo Implement!
80  */
81  ~Element();
82 
83  /*!
84  \brief Assignment operator.
85 
86  \param rhs Right-hand-side object.
87 
88  \return A reference to this object.
89 
90  \todo Implement!
91  */
92  Element& operator=(const Element& rhs);
93 
94  /*!
95  \brief It returns the name of a built-in data type, or the name of a simpleType or complexType element.
96 
97  \return The name of a built-in data type, or the name of a simpleType or complexType element.
98  */
99  QName* getType() const;
100 
101  /*!
102  \brief It returns the default value for the element.
103 
104  \return The default value for the element.
105  */
106  std::string* getDefaultValue() const;
107 
108  /*!
109  \brief It returns the fixed value for the element.
110 
111  \return The fixed value for the element.
112  */
113  std::string* getFixedValue() const;
114 
115  /*!
116  \brief If the element is "nillable" or not.
117 
118  \return True if the element is "nillable" and false if not.
119  */
120  bool isNillable();
121 
122  /*!
123  \brief If the element is "abstract" or not.
124 
125  \return True if the element is "abstract" and false if not.
126  */
127  bool isAbstract();
128 
129  /*!
130  \brief It returns the block value for the element. It prevents an element with a specified type of derivation from being used in place of this element.
131 
132  \return The block value. It can be: #all | list of (extension|restriction).
133  */
134  int getBlock();
135 
136  /*!
137  \brief It sets the element type.
138 
139  \param t The element type.
140 
141  \note The element will take the ownership of the given type.
142  */
143  void setType(QName* t);
144 
145  /*!
146  \brief It sets the default value for the element.
147 
148  \param v The element default value.
149 
150  \note The element will take the ownership of the given value.
151  */
152  void setDefaultValue(std::string* v);
153 
154  /*!
155  \brief It sets a fixed value for the element.
156 
157  \param v A fixed value for the element.
158 
159  \note The element will take the ownership of the given value.
160  */
161  void setFixedValue(std::string* v);
162 
163  /*!
164  \brief It specifies whether an explicit null value can be assigned to the element.
165 
166  \param v True enables an instance of the element to have the null attribute set to true.
167  */
168  void setAsNillable(bool v);
169 
170  /*!
171  \brief It specifies whether the element can be used in an instance document.
172 
173  \param v True indicates that the element cannot appear in the instance document. Instead, another element whose substitutionGroup attribute contains the qualified name (QName) of this element must appear in this element's place.
174  */
175  void setAsAbstract(bool v);
176 
177  /*!
178  \brief It prevents an element with a specified type of derivation from being used in place of this element.
179 
180  \param v It can be: #all|list of (extension|restriction).
181  */
182  void setBlock(int v);
183 
184  /*!
185  \brief It returns the element name or NULL if it doesn't have one.
186 
187  \return The element name or NULL if it doesn't have one.
188  */
189  std::string* getName() const;
190 
191  /*!
192  \brief It returns the reference to a name of another element.
193 
194  \return The reference to a name of another element.
195  */
196  QName* getRef() const;
197 
198  /*!
199  \brief It sets the element name.
200 
201  \param name The element name.
202 
203  \note The element will take the ownership of the given name.
204  \note Setting a name will turn to NULL the reference property.
205  */
206  void setName(std::string* name);
207 
208  /*!
209  \brief It sets a reference to a name of another element.
210 
211  \param ref A reference to a name of another element.
212 
213  \note Setting a reference property will turn to NULL the name.
214  \note The LocalElement object will take the ownership of the given pointer.
215  */
216  void setRef(QName* ref);
217 
218  /*!
219  \brief It sets the substitution group.
220 
221  \param g The substitution group.
222 
223  \note The element will take the ownership of the given substitution group.
224  */
225  void setSubstitutionGroup(QName* g);
226 
227  /*!
228  \brief It sets the default value of the final attribute on the element element.
229 
230  \param v It can be: #all|list of (extension|restriction).
231  */
232  void setFinal(int v);
233 
234  /*!
235  \brief It sets the content type of the element.
236 
237  \param t The content type of the element.
238 
239  \note The element will take the ownership of the given type.
240  */
241  void setContentType(Type* t);
242 
243  /*!
244  \brief It adds an IdentityConstraint to the element.
245 
246  \param ic The IdentityConstraint that will be added.
247 
248  \note The element will take the ownership of the given constraint.
249  */
250  void addIdentityConstraint(IdentityConstraint* ic);
251 
252  private:
253 
254  std::string* m_name; //!< It specifies a name for the element. (Optional)
255  QName* m_ref; //!< It refers to the name of another element. The ref attribute can include a namespace prefix.
256  QName* m_type; //!< It specifies either the name of a built-in data type, or the name of a simpleType or complexType element. (Optional)
257  QName* m_substitutionGroup; //!< It specifies the element that can be substituted with this element.
258  std::string* m_default; //!< It specifies a default value for the element (can only be used if the element's content is a simple type or text only).
259  std::string* m_fixed; //!< It ensures that the elements are set to particular value.
260  Form m_form; //!< Here, "unqualified" indicates that this attribute is not required to be qualified with the namespace prefix. "qualified" indicates that this attribute must be qualified with the namespace prefix. The default value is the value of the elementFormDefault attribute of the schema element. (Optional)
261  bool m_nillable; //!< It specifies whether an explicit null value can be assigned to the element. True enables an instance of the element to have the null attribute set to true. The null attribute is defined as part of the XML Schema namespace for instances. Default is false.
262  bool m_abstract; //!< It specifies whether the element can be used in an instance document. True indicates that the element cannot appear in the instance document. Instead, another element whose substitutionGroup attribute contains the qualified name (QName) of this element must appear in this element's place. Default is false.
263  int m_block; //!< It prevents an element with a specified type of derivation from being used in place of this element. (Optional)
264  int m_final; //!< It sets the default value of the final attribute on the element element.
265  Type* m_contentType; //!< A content of this element. A simpleType or complexType element can be present as a child only if both the ref and type attributes are not present.
266  boost::ptr_vector<IdentityConstraint> m_identityConstraintVec; //!< The list of elements related to identity constraint - (key | keyref | unique)*. (Optional)
267  };
268 
269  } // end namespace xsd
270 } // end namespace te
271 
272 #endif // __TERRALIB_XSD_INTERNAL_ELEMENT_H
273 
Configuration flags for the XSD Module of TerraLib.
A base class for XSD classes that may allow annotation.
Definition: Annotated.h:49
A base class for XSD classes that have occurs attributes.
Definition: Occurs.h:43
A base class for XSD classes that may allow annotation.
This class models the element of a XML Schema.
Definition: Element.h:56
Type * m_contentType
A content of this element. A simpleType or complexType element can be present as a child only if both...
Definition: Element.h:265
bool m_nillable
It specifies whether an explicit null value can be assigned to the element. True enables an instance ...
Definition: Element.h:261
std::string * m_fixed
It ensures that the elements are set to particular value.
Definition: Element.h:259
boost::ptr_vector< IdentityConstraint > m_identityConstraintVec
The list of elements related to identity constraint - (key | keyref | unique)*. (Optional) ...
Definition: Element.h:266
QName * m_ref
It refers to the name of another element. The ref attribute can include a namespace prefix...
Definition: Element.h:255
QName * m_type
It specifies either the name of a built-in data type, or the name of a simpleType or complexType elem...
Definition: Element.h:256
A base class for XSD classes that must provide a unique ID property.
Definition: Identifiable.h:46
Form
It specifies the form for the attribute.
Definition: Enums.h:112
bool m_abstract
It specifies whether the element can be used in an instance document. True indicates that the element...
Definition: Element.h:262
Form m_form
Here, "unqualified" indicates that this attribute is not required to be qualified with the namespace ...
Definition: Element.h:260
This is the base class for XML Schema elements that are related to identity constraint.
A base class for XSD classes that have occurs attributes.
A base class for XSD classes that must provide a unique ID property.
#define TEXSDEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:60
std::string * m_name
It specifies a name for the element. (Optional)
Definition: Element.h:254
A class to be used to represent XML qualified names.
Definition: QName.h:49
int m_block
It prevents an element with a specified type of derivation from being used in place of this element...
Definition: Element.h:263
A class that models a XSD annotation element.
Definition: Annotation.h:55
QName * m_substitutionGroup
It specifies the element that can be substituted with this element.
Definition: Element.h:257
int m_final
It sets the default value of the final attribute on the element element.
Definition: Element.h:264
std::string * m_default
It specifies a default value for the element (can only be used if the element's content is a simple t...
Definition: Element.h:258
An abstract class for modeling the definition of a new XML Schema Type.
Definition: Type.h:65