1 | /* |
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
3 | * contributor license agreements. See the NOTICE file distributed with |
---|
4 | * this work for additional information regarding copyright ownership. |
---|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
6 | * (the "License"); you may not use this file except in compliance with |
---|
7 | * the License. You may obtain a copy of the License at |
---|
8 | * |
---|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
10 | * |
---|
11 | * Unless required by applicable law or agreed to in writing, software |
---|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
14 | * See the License for the specific language governing permissions and |
---|
15 | * limitations under the License. |
---|
16 | */ |
---|
17 | |
---|
18 | /* |
---|
19 | * $Id: XSComplexTypeDefinition.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | #if !defined(XSCOMPLEXTYPEDEFINITION_HPP) |
---|
23 | #define XSCOMPLEXTYPEDEFINITION_HPP |
---|
24 | |
---|
25 | #include <xercesc/framework/psvi/XSTypeDefinition.hpp> |
---|
26 | |
---|
27 | XERCES_CPP_NAMESPACE_BEGIN |
---|
28 | |
---|
29 | /** |
---|
30 | * This class represents a complexType definition |
---|
31 | * schema component. |
---|
32 | * This is *always* owned by the validator /parser object from which |
---|
33 | * it is obtained. |
---|
34 | * |
---|
35 | */ |
---|
36 | |
---|
37 | // forward declarations |
---|
38 | class XSAnnotation; |
---|
39 | class XSAttributeUse; |
---|
40 | class XSSimpleTypeDefinition; |
---|
41 | class XSParticle; |
---|
42 | class XSWildcard; |
---|
43 | class ComplexTypeInfo; |
---|
44 | |
---|
45 | class XMLPARSER_EXPORT XSComplexTypeDefinition : public XSTypeDefinition |
---|
46 | { |
---|
47 | public: |
---|
48 | |
---|
49 | // Content Model Types |
---|
50 | enum CONTENT_TYPE { |
---|
51 | /** |
---|
52 | * Represents an empty content type. A content type with the distinguished |
---|
53 | * value empty validates elements with no character or element |
---|
54 | * information item children. |
---|
55 | */ |
---|
56 | CONTENTTYPE_EMPTY = 0, |
---|
57 | /** |
---|
58 | * Represents a simple content type. A content type which is a simple |
---|
59 | * validates elements with character-only children. |
---|
60 | */ |
---|
61 | CONTENTTYPE_SIMPLE = 1, |
---|
62 | /** |
---|
63 | * Represents an element-only content type. An element-only content type |
---|
64 | * validates elements with children that conform to the supplied content |
---|
65 | * model. |
---|
66 | */ |
---|
67 | CONTENTTYPE_ELEMENT = 2, |
---|
68 | /** |
---|
69 | * Represents a mixed content type. |
---|
70 | */ |
---|
71 | CONTENTTYPE_MIXED = 3 |
---|
72 | }; |
---|
73 | |
---|
74 | // Constructors and Destructor |
---|
75 | // ----------------------------------------------------------------------- |
---|
76 | /** @name Constructors */ |
---|
77 | //@{ |
---|
78 | |
---|
79 | /** |
---|
80 | * The default constructor |
---|
81 | * |
---|
82 | * @param complexTypeInfo |
---|
83 | * @param xsWildcard |
---|
84 | * @param xsSimpleType |
---|
85 | * @param xsAttList |
---|
86 | * @param xsBaseType |
---|
87 | * @param xsParticle |
---|
88 | * @param headAnnot |
---|
89 | * @param xsModel |
---|
90 | * @param manager The configurable memory manager |
---|
91 | */ |
---|
92 | XSComplexTypeDefinition |
---|
93 | ( |
---|
94 | ComplexTypeInfo* const complexTypeInfo |
---|
95 | , XSWildcard* const xsWildcard |
---|
96 | , XSSimpleTypeDefinition* const xsSimpleType |
---|
97 | , XSAttributeUseList* const xsAttList |
---|
98 | , XSTypeDefinition* const xsBaseType |
---|
99 | , XSParticle* const xsParticle |
---|
100 | , XSAnnotation* const headAnnot |
---|
101 | , XSModel* const xsModel |
---|
102 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
103 | ); |
---|
104 | |
---|
105 | //@}; |
---|
106 | |
---|
107 | /** @name Destructor */ |
---|
108 | //@{ |
---|
109 | ~XSComplexTypeDefinition(); |
---|
110 | //@} |
---|
111 | |
---|
112 | //--------------------- |
---|
113 | /** @name XSComplexTypeDefinition methods */ |
---|
114 | |
---|
115 | //@{ |
---|
116 | |
---|
117 | /** |
---|
118 | * [derivation method]: either <code>DERIVATION_EXTENSION</code>, |
---|
119 | * <code>DERIVATION_RESTRICTION</code>, or <code>DERIVATION_NONE</code> |
---|
120 | * (see <code>XSObject</code>). |
---|
121 | */ |
---|
122 | XSConstants::DERIVATION_TYPE getDerivationMethod() const; |
---|
123 | |
---|
124 | /** |
---|
125 | * [abstract]: a boolean. Complex types for which <code>abstract</code> is |
---|
126 | * true must not be used as the type definition for the validation of |
---|
127 | * element information items. |
---|
128 | */ |
---|
129 | bool getAbstract() const; |
---|
130 | |
---|
131 | /** |
---|
132 | * A set of attribute uses. |
---|
133 | */ |
---|
134 | XSAttributeUseList *getAttributeUses(); |
---|
135 | |
---|
136 | /** |
---|
137 | * Optional.An attribute wildcard. |
---|
138 | */ |
---|
139 | XSWildcard *getAttributeWildcard() const; |
---|
140 | |
---|
141 | /** |
---|
142 | * [content type]: one of empty (<code>CONTENTTYPE_EMPTY</code>), a simple |
---|
143 | * type definition (<code>CONTENTTYPE_SIMPLE</code>), mixed ( |
---|
144 | * <code>CONTENTTYPE_MIXED</code>), or element-only ( |
---|
145 | * <code>CONTENTTYPE_ELEMENT</code>). |
---|
146 | */ |
---|
147 | CONTENT_TYPE getContentType() const; |
---|
148 | |
---|
149 | /** |
---|
150 | * A simple type definition corresponding to simple content model, |
---|
151 | * otherwise <code>null</code> |
---|
152 | */ |
---|
153 | XSSimpleTypeDefinition *getSimpleType() const; |
---|
154 | |
---|
155 | /** |
---|
156 | * A particle for mixed or element-only content model, otherwise |
---|
157 | * <code>null</code> |
---|
158 | */ |
---|
159 | XSParticle *getParticle() const; |
---|
160 | |
---|
161 | /** |
---|
162 | * [prohibited substitutions]: a subset of {extension, restriction} |
---|
163 | * @param toTest Extention or restriction constants (see |
---|
164 | * <code>XSObject</code>). |
---|
165 | * @return True if toTest is a prohibited substitution, otherwise |
---|
166 | * false. |
---|
167 | */ |
---|
168 | bool isProhibitedSubstitution(XSConstants::DERIVATION_TYPE toTest); |
---|
169 | |
---|
170 | /** |
---|
171 | * [prohibited substitutions]: A subset of {extension, restriction} or |
---|
172 | * <code>DERIVATION_NONE</code> represented as a bit flag (see |
---|
173 | * <code>XSObject</code>). |
---|
174 | */ |
---|
175 | short getProhibitedSubstitutions() const; |
---|
176 | |
---|
177 | /** |
---|
178 | * A set of [annotations]. |
---|
179 | */ |
---|
180 | XSAnnotationList *getAnnotations(); |
---|
181 | |
---|
182 | /** |
---|
183 | * The name of type <code>NCName</code> of this declaration as defined in |
---|
184 | * XML Namespaces. |
---|
185 | */ |
---|
186 | const XMLCh* getName(); |
---|
187 | |
---|
188 | /** |
---|
189 | * The [target namespace] of this object, or <code>null</code> if it is |
---|
190 | * unspecified. |
---|
191 | */ |
---|
192 | const XMLCh* getNamespace(); |
---|
193 | |
---|
194 | /** |
---|
195 | * A namespace schema information item corresponding to the target |
---|
196 | * namespace of the component, if it's globally declared; or null |
---|
197 | * otherwise. |
---|
198 | */ |
---|
199 | XSNamespaceItem *getNamespaceItem(); |
---|
200 | |
---|
201 | /** |
---|
202 | * A boolean that specifies if the type definition is |
---|
203 | * anonymous. Convenience attribute. |
---|
204 | */ |
---|
205 | bool getAnonymous() const; |
---|
206 | |
---|
207 | /** |
---|
208 | * {base type definition}: either a simple type definition or a complex |
---|
209 | * type definition. |
---|
210 | */ |
---|
211 | XSTypeDefinition *getBaseType(); |
---|
212 | |
---|
213 | /** |
---|
214 | * Convenience method: check if this type is derived from the given |
---|
215 | * <code>ancestorType</code>. |
---|
216 | * @param ancestorType An ancestor type definition. |
---|
217 | * @return Return true if this type is derived from |
---|
218 | * <code>ancestorType</code>. |
---|
219 | */ |
---|
220 | bool derivedFromType(const XSTypeDefinition* const ancestorType); |
---|
221 | |
---|
222 | //@} |
---|
223 | |
---|
224 | //---------------------------------- |
---|
225 | /** methods needed by implementation */ |
---|
226 | |
---|
227 | //@{ |
---|
228 | |
---|
229 | |
---|
230 | //@} |
---|
231 | |
---|
232 | private: |
---|
233 | |
---|
234 | /** |
---|
235 | * Set the base type |
---|
236 | */ |
---|
237 | void setBaseType(XSTypeDefinition* const xsBaseType); |
---|
238 | friend class XSObjectFactory; |
---|
239 | |
---|
240 | // ----------------------------------------------------------------------- |
---|
241 | // Unimplemented constructors and operators |
---|
242 | // ----------------------------------------------------------------------- |
---|
243 | XSComplexTypeDefinition(const XSComplexTypeDefinition&); |
---|
244 | XSComplexTypeDefinition & operator=(const XSComplexTypeDefinition &); |
---|
245 | |
---|
246 | protected: |
---|
247 | |
---|
248 | // ----------------------------------------------------------------------- |
---|
249 | // data members |
---|
250 | // ----------------------------------------------------------------------- |
---|
251 | ComplexTypeInfo* fComplexTypeInfo; |
---|
252 | XSWildcard* fXSWildcard; |
---|
253 | XSAttributeUseList* fXSAttributeUseList; |
---|
254 | XSSimpleTypeDefinition* fXSSimpleTypeDefinition; |
---|
255 | XSAnnotationList* fXSAnnotationList; |
---|
256 | XSParticle* fParticle; |
---|
257 | short fProhibitedSubstitution; |
---|
258 | }; |
---|
259 | |
---|
260 | |
---|
261 | inline XSAttributeUseList* XSComplexTypeDefinition::getAttributeUses() |
---|
262 | { |
---|
263 | return fXSAttributeUseList; |
---|
264 | } |
---|
265 | |
---|
266 | inline XSWildcard* XSComplexTypeDefinition::getAttributeWildcard() const |
---|
267 | { |
---|
268 | return fXSWildcard; |
---|
269 | } |
---|
270 | |
---|
271 | inline XSSimpleTypeDefinition* XSComplexTypeDefinition::getSimpleType() const |
---|
272 | { |
---|
273 | return fXSSimpleTypeDefinition; |
---|
274 | } |
---|
275 | |
---|
276 | inline short XSComplexTypeDefinition::getProhibitedSubstitutions() const |
---|
277 | { |
---|
278 | return fProhibitedSubstitution; |
---|
279 | } |
---|
280 | |
---|
281 | inline XSParticle *XSComplexTypeDefinition::getParticle() const |
---|
282 | { |
---|
283 | return fParticle; |
---|
284 | } |
---|
285 | |
---|
286 | inline void |
---|
287 | XSComplexTypeDefinition::setBaseType(XSTypeDefinition* const xsBaseType) |
---|
288 | { |
---|
289 | fBaseType = xsBaseType; |
---|
290 | } |
---|
291 | |
---|
292 | XERCES_CPP_NAMESPACE_END |
---|
293 | |
---|
294 | #endif |
---|