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: XSElementDeclaration.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | #if !defined(XSELEMENTDECLARATION_HPP) |
---|
23 | #define XSELEMENTDECLARATION_HPP |
---|
24 | |
---|
25 | #include <xercesc/framework/psvi/XSObject.hpp> |
---|
26 | #include <xercesc/framework/psvi/XSNamedMap.hpp> |
---|
27 | |
---|
28 | XERCES_CPP_NAMESPACE_BEGIN |
---|
29 | |
---|
30 | /** |
---|
31 | * This class describes all properties of a Schema Element Declaration |
---|
32 | * component. |
---|
33 | * This is *always* owned by the validator /parser object from which |
---|
34 | * it is obtained. |
---|
35 | */ |
---|
36 | |
---|
37 | // forward declarations |
---|
38 | class XSAnnotation; |
---|
39 | class XSComplexTypeDefinition; |
---|
40 | class XSIDCDefinition; |
---|
41 | class XSTypeDefinition; |
---|
42 | class SchemaElementDecl; |
---|
43 | |
---|
44 | class XMLPARSER_EXPORT XSElementDeclaration : public XSObject |
---|
45 | { |
---|
46 | public: |
---|
47 | |
---|
48 | // Constructors and Destructor |
---|
49 | // ----------------------------------------------------------------------- |
---|
50 | /** @name Constructors */ |
---|
51 | //@{ |
---|
52 | |
---|
53 | /** |
---|
54 | * The default constructor |
---|
55 | * |
---|
56 | * @param schemaElementDecl |
---|
57 | * @param typeDefinition |
---|
58 | * @param substitutionGroupAffiliation |
---|
59 | * @param annot |
---|
60 | * @param identityConstraints |
---|
61 | * @param xsModel |
---|
62 | * @param elemScope |
---|
63 | * @param enclosingTypeDefinition |
---|
64 | * @param manager The configurable memory manager |
---|
65 | */ |
---|
66 | XSElementDeclaration |
---|
67 | ( |
---|
68 | SchemaElementDecl* const schemaElementDecl |
---|
69 | , XSTypeDefinition* const typeDefinition |
---|
70 | , XSElementDeclaration* const substitutionGroupAffiliation |
---|
71 | , XSAnnotation* const annot |
---|
72 | , XSNamedMap<XSIDCDefinition>* const identityConstraints |
---|
73 | , XSModel* const xsModel |
---|
74 | , XSConstants::SCOPE elemScope = XSConstants::SCOPE_ABSENT |
---|
75 | , XSComplexTypeDefinition* const enclosingTypeDefinition = 0 |
---|
76 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
77 | ); |
---|
78 | |
---|
79 | //@}; |
---|
80 | |
---|
81 | /** @name Destructor */ |
---|
82 | //@{ |
---|
83 | ~XSElementDeclaration(); |
---|
84 | //@} |
---|
85 | |
---|
86 | //--------------------- |
---|
87 | /** @name overridden XSXSObject methods */ |
---|
88 | |
---|
89 | //@{ |
---|
90 | |
---|
91 | /** |
---|
92 | * The name of type <code>NCName</code> of this declaration as defined in |
---|
93 | * XML Namespaces. |
---|
94 | */ |
---|
95 | const XMLCh* getName(); |
---|
96 | |
---|
97 | /** |
---|
98 | * The [target namespace] of this object, or <code>null</code> if it is |
---|
99 | * unspecified. |
---|
100 | */ |
---|
101 | const XMLCh* getNamespace(); |
---|
102 | |
---|
103 | /** |
---|
104 | * A namespace schema information item corresponding to the target |
---|
105 | * namespace of the component, if it's globally declared; or null |
---|
106 | * otherwise. |
---|
107 | */ |
---|
108 | XSNamespaceItem *getNamespaceItem(); |
---|
109 | |
---|
110 | //@} |
---|
111 | |
---|
112 | //--------------------- |
---|
113 | /** @name XSElementDeclaration methods */ |
---|
114 | |
---|
115 | //@{ |
---|
116 | |
---|
117 | /** |
---|
118 | * [type definition]: either a simple type definition or a complex type |
---|
119 | * definition. |
---|
120 | */ |
---|
121 | XSTypeDefinition *getTypeDefinition() const; |
---|
122 | |
---|
123 | /** |
---|
124 | * Optional. One of <code>SCOPE_GLOBAL</code>, <code>SCOPE_LOCAL</code>, |
---|
125 | * or <code>SCOPE_ABSENT</code>. If the scope is local, then the |
---|
126 | * <code>enclosingCTDefinition</code> is present. |
---|
127 | */ |
---|
128 | XSConstants::SCOPE getScope() const; |
---|
129 | |
---|
130 | /** |
---|
131 | * The complex type definition for locally scoped declarations (see |
---|
132 | * <code>scope</code>). |
---|
133 | */ |
---|
134 | XSComplexTypeDefinition *getEnclosingCTDefinition() const; |
---|
135 | |
---|
136 | /** |
---|
137 | * [Value constraint]: one of <code>VC_NONE, VC_DEFAULT, VC_FIXED</code>. |
---|
138 | */ |
---|
139 | XSConstants::VALUE_CONSTRAINT getConstraintType() const; |
---|
140 | |
---|
141 | /** |
---|
142 | * [Value constraint]: the actual value with respect to the [type |
---|
143 | * definition]. |
---|
144 | */ |
---|
145 | const XMLCh *getConstraintValue(); |
---|
146 | |
---|
147 | /** |
---|
148 | * If nillable is true, then an element may also be valid if it carries |
---|
149 | * the namespace qualified attribute with local name <code>nil</code> |
---|
150 | * from namespace <code>http://www.w3.org/2001/XMLSchema-instance</code> |
---|
151 | * and value <code>true</code> (xsi:nil) even if it has no text or |
---|
152 | * element content despite a <code>content type</code> which would |
---|
153 | * otherwise require content. |
---|
154 | */ |
---|
155 | bool getNillable() const; |
---|
156 | |
---|
157 | /** |
---|
158 | * identity-constraint definitions: a set of constraint definitions. |
---|
159 | */ |
---|
160 | XSNamedMap <XSIDCDefinition> *getIdentityConstraints(); |
---|
161 | |
---|
162 | /** |
---|
163 | * [substitution group affiliation]: optional. A top-level element |
---|
164 | * definition. |
---|
165 | */ |
---|
166 | XSElementDeclaration *getSubstitutionGroupAffiliation() const; |
---|
167 | |
---|
168 | /** |
---|
169 | * Convenience method. Check if <code>exclusion</code> is a substitution |
---|
170 | * group exclusion for this element declaration. |
---|
171 | * @param exclusion |
---|
172 | * <code>DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code> or |
---|
173 | * <code>DERIVATION_NONE</code>. Represents final set for the element. |
---|
174 | * @return True if <code>exclusion</code> is a part of the substitution |
---|
175 | * group exclusion subset. |
---|
176 | */ |
---|
177 | bool isSubstitutionGroupExclusion(XSConstants::DERIVATION_TYPE exclusion); |
---|
178 | |
---|
179 | /** |
---|
180 | * [substitution group exclusions]: the returned value is a bit |
---|
181 | * combination of the subset of { |
---|
182 | * <code>DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code>} or |
---|
183 | * <code>DERIVATION_NONE</code>. |
---|
184 | */ |
---|
185 | short getSubstitutionGroupExclusions() const; |
---|
186 | |
---|
187 | /** |
---|
188 | * Convenience method. Check if <code>disallowed</code> is a disallowed |
---|
189 | * substitution for this element declaration. |
---|
190 | * @param disallowed { |
---|
191 | * <code>DERIVATION_SUBSTITUTION, DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code> |
---|
192 | * } or <code>DERIVATION_NONE</code>. Represents a block set for the |
---|
193 | * element. |
---|
194 | * @return True if <code>disallowed</code> is a part of the substitution |
---|
195 | * group exclusion subset. |
---|
196 | */ |
---|
197 | bool isDisallowedSubstitution(XSConstants::DERIVATION_TYPE disallowed); |
---|
198 | |
---|
199 | /** |
---|
200 | * [disallowed substitutions]: the returned value is a bit combination of |
---|
201 | * the subset of { |
---|
202 | * <code>DERIVATION_SUBSTITUTION, DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code> |
---|
203 | * } corresponding to substitutions disallowed by this |
---|
204 | * <code>XSElementDeclaration</code> or <code>DERIVATION_NONE</code>. |
---|
205 | */ |
---|
206 | short getDisallowedSubstitutions() const; |
---|
207 | |
---|
208 | /** |
---|
209 | * {abstract} A boolean. |
---|
210 | */ |
---|
211 | bool getAbstract() const; |
---|
212 | |
---|
213 | /** |
---|
214 | * Optional. Annotation. |
---|
215 | */ |
---|
216 | XSAnnotation *getAnnotation() const; |
---|
217 | |
---|
218 | //@} |
---|
219 | |
---|
220 | //---------------------------------- |
---|
221 | /** methods needed by implementation */ |
---|
222 | |
---|
223 | //@{ |
---|
224 | |
---|
225 | void setTypeDefinition(XSTypeDefinition* typeDefinition); |
---|
226 | |
---|
227 | //@} |
---|
228 | private: |
---|
229 | |
---|
230 | void setEnclosingCTDefinition(XSComplexTypeDefinition* const toSet); |
---|
231 | friend class XSObjectFactory; |
---|
232 | |
---|
233 | // ----------------------------------------------------------------------- |
---|
234 | // Unimplemented constructors and operators |
---|
235 | // ----------------------------------------------------------------------- |
---|
236 | XSElementDeclaration(const XSElementDeclaration&); |
---|
237 | XSElementDeclaration & operator=(const XSElementDeclaration &); |
---|
238 | |
---|
239 | protected: |
---|
240 | |
---|
241 | // ----------------------------------------------------------------------- |
---|
242 | // data members |
---|
243 | // ----------------------------------------------------------------------- |
---|
244 | short fDisallowedSubstitutions; |
---|
245 | short fSubstitutionGroupExclusions; |
---|
246 | XSConstants::SCOPE fScope; |
---|
247 | SchemaElementDecl* fSchemaElementDecl; |
---|
248 | XSTypeDefinition* fTypeDefinition; |
---|
249 | XSComplexTypeDefinition* fEnclosingTypeDefinition; |
---|
250 | XSElementDeclaration* fSubstitutionGroupAffiliation; |
---|
251 | XSAnnotation* fAnnotation; |
---|
252 | XSNamedMap<XSIDCDefinition>* fIdentityConstraints; |
---|
253 | }; |
---|
254 | |
---|
255 | inline XSTypeDefinition* XSElementDeclaration::getTypeDefinition() const |
---|
256 | { |
---|
257 | return fTypeDefinition; |
---|
258 | } |
---|
259 | |
---|
260 | inline XSNamedMap<XSIDCDefinition>* XSElementDeclaration::getIdentityConstraints() |
---|
261 | { |
---|
262 | return fIdentityConstraints; |
---|
263 | } |
---|
264 | |
---|
265 | inline XSElementDeclaration* XSElementDeclaration::getSubstitutionGroupAffiliation() const |
---|
266 | { |
---|
267 | return fSubstitutionGroupAffiliation; |
---|
268 | } |
---|
269 | |
---|
270 | inline short XSElementDeclaration::getSubstitutionGroupExclusions() const |
---|
271 | { |
---|
272 | return fSubstitutionGroupExclusions; |
---|
273 | } |
---|
274 | |
---|
275 | inline short XSElementDeclaration::getDisallowedSubstitutions() const |
---|
276 | { |
---|
277 | return fDisallowedSubstitutions; |
---|
278 | } |
---|
279 | |
---|
280 | inline XSAnnotation *XSElementDeclaration::getAnnotation() const |
---|
281 | { |
---|
282 | return fAnnotation; |
---|
283 | } |
---|
284 | |
---|
285 | inline XSConstants::SCOPE XSElementDeclaration::getScope() const |
---|
286 | { |
---|
287 | return fScope; |
---|
288 | } |
---|
289 | |
---|
290 | inline XSComplexTypeDefinition *XSElementDeclaration::getEnclosingCTDefinition() const |
---|
291 | { |
---|
292 | return fEnclosingTypeDefinition; |
---|
293 | } |
---|
294 | |
---|
295 | inline void XSElementDeclaration::setTypeDefinition(XSTypeDefinition* typeDefinition) |
---|
296 | { |
---|
297 | fTypeDefinition = typeDefinition; |
---|
298 | } |
---|
299 | |
---|
300 | inline void XSElementDeclaration::setEnclosingCTDefinition(XSComplexTypeDefinition* const toSet) |
---|
301 | { |
---|
302 | fEnclosingTypeDefinition = toSet; |
---|
303 | } |
---|
304 | |
---|
305 | XERCES_CPP_NAMESPACE_END |
---|
306 | |
---|
307 | #endif |
---|