Schema.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 Lesser 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 Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser 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 terralib/xsd/Schema.h
22 
23  \brief A class that models an XML Schema (XSD).
24 */
25 
26 #ifndef __TERRALIB_XSD_INTERNAL_SCHEMA_H
27 #define __TERRALIB_XSD_INTERNAL_SCHEMA_H
28 
29 // TerraLib
30 #include "Annotation.h"
31 #include "Attribute.h"
32 #include "AttributeGroup.h"
33 #include "ComplexType.h"
34 #include "Element.h"
35 #include "Enums.h"
36 #include "Group.h"
37 #include "Identifiable.h"
38 #include "Import.h"
39 #include "Include.h"
40 #include "Notation.h"
41 #include "Redefine.h"
42 #include "Schema.h"
43 #include "SimpleType.h"
44 
45 // Boost
46 #include <boost/bimap.hpp>
47 #include <boost/noncopyable.hpp>
48 #include <boost/ptr_container/ptr_vector.hpp>
49 
50 namespace te
51 {
52  namespace xsd
53  {
54  /*!
55  \class Schema
56 
57  \brief A class that models a XML schema (XSD).
58 
59  \sa Identifiable, Include, Import, Redefine, Annotation,
60  SimpleType, ComplexType, Group, AttributeGroup,
61  Element, Attribute, Notation
62  */
63  class TEXSDEXPORT Schema : public Identifiable, public boost::noncopyable
64  {
65  public:
66 
67  Schema(std::string* id);
68 
69  ~Schema();
70 
71  Form getAttributeFormDefault() const { return m_attributeFormDefault; }
72 
73  void setAttributeFormDefault(Form f) { m_attributeFormDefault = f; }
74 
75  Form getElementFormDefault() const { return m_elementFormDefault; }
76 
77  void setElementFormDefault(Form f) { m_elementFormDefault = f; }
78 
79  int getBlockDefault() const { return m_blockDefault; }
80 
81  void setBlockDefault(int bdf) { m_blockDefault = bdf; }
82 
83  int getFinalDefault() const { return m_finalDefault; }
84 
85  void setFinalDefault(int fdf) { m_finalDefault = fdf; }
86 
87  const std::string& getTargetNamespace() const { return m_targetNamespace; }
88 
89  void setTargetNamespace(const std::string& tns) { m_targetNamespace = tns; }
90 
91  const std::string& getVersion() const { return m_version; }
92 
93  void setVersion(const std::string& v) { m_version = v; }
94 
95  const boost::bimap<std::string, std::string>& getNamespaces() const { return m_xmlns; }
96 
97  boost::bimap<std::string, std::string>& getNamespaces() { return m_xmlns; }
98 
99  const boost::ptr_vector<Include>& getIncludes() const;
100 
101  const boost::ptr_vector<Import>& getImports() const;
102 
103  const boost::ptr_vector<Redefine>& getRedefines() const;
104 
105  const boost::ptr_vector<Annotation>& getAnnotations() const;
106 
107  const boost::ptr_vector<SimpleType>& getSimpleTypes() const;
108 
109  const boost::ptr_vector<ComplexType>& getComplexTypes() const;
110 
111  const boost::ptr_vector<Group>& getGroups() const;
112 
113  const boost::ptr_vector<AttributeGroup>& getAttributeGroups() const;
114 
115  const boost::ptr_vector<AbstractAttribute>& getAttributes() const;
116 
117  const boost::ptr_vector<Element>& getElements() const;
118 
119  const boost::ptr_vector<Notation>& getNotations() const;
120 
121  void addNamespace(const std::string& ns, const std::string& nsprefix);
122 
123  void addInclude(Include* i);
124 
125  void addImport(Import* i);
126 
127  void addRedefine(Redefine* r);
128 
129  void addAnnotation(Annotation* a);
130 
131  void addSimpleType(SimpleType* s);
132 
133  void addComplexType(ComplexType* c);
134 
135  void addGroup(Group* g);
136 
137  void addAttributeGroup(AttributeGroup* ag);
138 
139  void addAttribute(AbstractAttribute* a);
140 
141  void addElement(Element* e);
142 
143  void addNotation(Notation* n);
144 
145  private:
146 
147  Form m_attributeFormDefault; //!< Tells if attributes declared in this schema must use the namespace prefix or not. Default: Unqualified. (Optional)
148  Form m_elementFormDefault; //!< Tells if elements declared in this schema must use the namespace prefix or not. Default: Unqualified. (Optional)
149 
150  int m_blockDefault; // (Optional)
151  int m_finalDefault; // (Optional)
152 
153  std::string m_targetNamespace; //!< The URI namespace of the schema. (Mandatory)
154  std::string m_version; //!< The schema version. (Optional)
155 
156  boost::bimap<std::string, std::string> m_xmlns; //!< A list of one or more namespaces for use in this schema. Mandatory only if attributeFormDefault or elementFormDefault is set to Qualified.
157 
158  boost::ptr_vector<Include> m_includeVec; //!< The list of include declarations at schema root.
159  boost::ptr_vector<Import> m_importVec; //!< The list of import declarations at schema root.
160  boost::ptr_vector<Redefine> m_redefineVec; //!< The list of redefine declarations at schema root.
161  boost::ptr_vector<Annotation> m_annotationVec; //!< The list of annotation declarations at schema root.
162  boost::ptr_vector<SimpleType> m_simpleTypeVec; //!< The list of simple type declarations at schema root.
163  boost::ptr_vector<ComplexType> m_complexTypeVec; //!< The list of complex type declarations at schema root.
164  boost::ptr_vector<Group> m_groupVec; //!< The list of group declarations at schema root.
165  boost::ptr_vector<AttributeGroup> m_attributeGroupVec; //!< The list of attributes at schema root.
166  boost::ptr_vector<Element> m_elementVec; //!< The list of elements declarations at schema root.
167  boost::ptr_vector<AbstractAttribute> m_attributeVec; //!< The list of attributes at schema root.
168  boost::ptr_vector<Notation> m_notationVec; //!< The list of notation declarations at schema root.
169  };
170 
171  } // end namespace xsd
172 } // end namespace te
173 
174 #endif // __TERRALIB_XSD_INTERNAL_SCHEMA_H
175 
It models a XML Schema attribute group.
void setAttributeFormDefault(Form f)
Definition: Schema.h:73
Form m_elementFormDefault
Tells if elements declared in this schema must use the namespace prefix or not. Default: Unqualified...
Definition: Schema.h:148
boost::ptr_vector< SimpleType > m_simpleTypeVec
The list of simple type declarations at schema root.
Definition: Schema.h:162
This class models a group element in a XML Schema.
A class that models a XML schema (XSD).
Definition: Schema.h:63
void setFinalDefault(int fdf)
Definition: Schema.h:85
It models a XML Schema import.
Definition: Import.h:47
A class that models an XML Schema (XSD).
This class models the element of a XML Schema.
Definition: Element.h:56
It models a XML Schema include.
Definition: Include.h:46
void setBlockDefault(int bdf)
Definition: Schema.h:81
boost::ptr_vector< AttributeGroup > m_attributeGroupVec
The list of attributes at schema root.
Definition: Schema.h:165
It models a XML Schema SimpleType element.
This class models a notation element from a XML Schema.
boost::ptr_vector< Element > m_elementVec
The list of elements declarations at schema root.
Definition: Schema.h:166
std::string m_targetNamespace
The URI namespace of the schema. (Mandatory)
Definition: Schema.h:153
boost::bimap< std::string, std::string > m_xmlns
A list of one or more namespaces for use in this schema. Mandatory only if attributeFormDefault or el...
Definition: Schema.h:156
It models a XML Schema redefine.
Definition: Redefine.h:52
A class that models a XSD annotation element.
It models a XML Schema import.
int m_finalDefault
Definition: Schema.h:151
int getBlockDefault() const
Definition: Schema.h:79
boost::ptr_vector< Include > m_includeVec
The list of include declarations at schema root.
Definition: Schema.h:158
This is the base class for XML Schema Attribute classes.
It models a XML Schema Complex Type definition.
It models a XML Schema redefine.
It models a XML Schema Complex Type definition.
Definition: ComplexType.h:56
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
URI C++ Library.
boost::ptr_vector< Redefine > m_redefineVec
The list of redefine declarations at schema root.
Definition: Schema.h:160
boost::ptr_vector< ComplexType > m_complexTypeVec
The list of complex type declarations at schema root.
Definition: Schema.h:163
const std::string & getTargetNamespace() const
Definition: Schema.h:87
boost::ptr_vector< Import > m_importVec
The list of import declarations at schema root.
Definition: Schema.h:159
const boost::bimap< std::string, std::string > & getNamespaces() const
Definition: Schema.h:95
void setElementFormDefault(Form f)
Definition: Schema.h:77
Form getElementFormDefault() const
Definition: Schema.h:75
Form getAttributeFormDefault() const
Definition: Schema.h:71
void setTargetNamespace(const std::string &tns)
Definition: Schema.h:89
boost::ptr_vector< Group > m_groupVec
The list of group declarations at schema root.
Definition: Schema.h:164
A base class for XSD classes that must provide a unique ID property.
const std::string & getVersion() const
Definition: Schema.h:91
std::string m_version
The schema version. (Optional)
Definition: Schema.h:154
#define TEXSDEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:57
It models a XML Schema include.
boost::ptr_vector< Notation > m_notationVec
The list of notation declarations at schema root.
Definition: Schema.h:168
void setVersion(const std::string &v)
Definition: Schema.h:93
boost::ptr_vector< Annotation > m_annotationVec
The list of annotation declarations at schema root.
Definition: Schema.h:161
boost::ptr_vector< AbstractAttribute > m_attributeVec
The list of attributes at schema root.
Definition: Schema.h:167
int m_blockDefault
Definition: Schema.h:150
int getFinalDefault() const
Definition: Schema.h:83
It models a XML Schema attribute.
A class that models a XSD annotation element.
Definition: Annotation.h:55
This class models a notation element from a XML Schema.
Definition: Notation.h:44
It models a XML Schema SimpleType element.
Definition: SimpleType.h:54
Form m_attributeFormDefault
Tells if attributes declared in this schema must use the namespace prefix or not. Default: Unqualifie...
Definition: Schema.h:147
This class models a group element in a XML Schema.
Definition: Group.h:52
boost::bimap< std::string, std::string > & getNamespaces()
Definition: Schema.h:97