1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 2003 The Apache Software Foundation. All rights
|
---|
5 | * reserved.
|
---|
6 | *
|
---|
7 | * Redistribution and use in source and binary forms, with or without
|
---|
8 | * modification, are permitted provided that the following conditions
|
---|
9 | * are met:
|
---|
10 | *
|
---|
11 | * 1. Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | *
|
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
15 | * notice, this list of conditions and the following disclaimer in
|
---|
16 | * the documentation and/or other materials provided with the
|
---|
17 | * distribution.
|
---|
18 | *
|
---|
19 | * 3. The end-user documentation included with the redistribution,
|
---|
20 | * if any, must include the following acknowledgment:
|
---|
21 | * "This product includes software developed by the
|
---|
22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
25 | *
|
---|
26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
27 | * not be used to endorse or promote products derived from this
|
---|
28 | * software without prior written permission. For written
|
---|
29 | * permission, please contact apache\@apache.org.
|
---|
30 | *
|
---|
31 | * 5. Products derived from this software may not be called "Apache",
|
---|
32 | * nor may "Apache" appear in their name, without prior written
|
---|
33 | * permission of the Apache Software Foundation.
|
---|
34 | *
|
---|
35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
46 | * SUCH DAMAGE.
|
---|
47 | * ====================================================================
|
---|
48 | *
|
---|
49 | * This software consists of voluntary contributions made by many
|
---|
50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
51 | * originally based on software copyright (c) 1999, International
|
---|
52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
53 | * on the Apache Software Foundation, please see
|
---|
54 | * <http://www.apache.org/>.
|
---|
55 | */
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * $Log: XSElementDeclaration.hpp,v $
|
---|
59 | * Revision 1.9 2003/12/24 17:42:02 knoaman
|
---|
60 | * Misc. PSVI updates
|
---|
61 | *
|
---|
62 | * Revision 1.8 2003/12/01 23:23:26 neilg
|
---|
63 | * fix for bug 25118; thanks to Jeroen Witmond
|
---|
64 | *
|
---|
65 | * Revision 1.7 2003/12/01 20:41:25 neilg
|
---|
66 | * fix for infinite loop between XSComplexTypeDefinitions and XSElementDeclarations; from David Cargill
|
---|
67 | *
|
---|
68 | * Revision 1.6 2003/11/23 16:20:16 knoaman
|
---|
69 | * PSVI: pass scope and enclosing type during construction.
|
---|
70 | *
|
---|
71 | * Revision 1.5 2003/11/21 17:29:53 knoaman
|
---|
72 | * PSVI update
|
---|
73 | *
|
---|
74 | * Revision 1.4 2003/11/14 22:47:53 neilg
|
---|
75 | * fix bogus log message from previous commit...
|
---|
76 | *
|
---|
77 | * Revision 1.3 2003/11/14 22:33:30 neilg
|
---|
78 | * Second phase of schema component model implementation.
|
---|
79 | * Implement XSModel, XSNamespaceItem, and the plumbing necessary
|
---|
80 | * to connect them to the other components.
|
---|
81 | * Thanks to David Cargill.
|
---|
82 | *
|
---|
83 | * Revision 1.2 2003/11/06 15:30:04 neilg
|
---|
84 | * first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse.
|
---|
85 | *
|
---|
86 | * Revision 1.1 2003/09/16 14:33:36 neilg
|
---|
87 | * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
|
---|
88 | *
|
---|
89 | */
|
---|
90 |
|
---|
91 | #if !defined(XSELEMENTDECLARATION_HPP)
|
---|
92 | #define XSELEMENTDECLARATION_HPP
|
---|
93 |
|
---|
94 | #include <xercesc/framework/psvi/XSObject.hpp>
|
---|
95 | #include <xercesc/framework/psvi/XSNamedMap.hpp>
|
---|
96 |
|
---|
97 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * This class describes all properties of a Schema Element Declaration
|
---|
101 | * component.
|
---|
102 | * This is *always* owned by the validator /parser object from which
|
---|
103 | * it is obtained.
|
---|
104 | */
|
---|
105 |
|
---|
106 | // forward declarations
|
---|
107 | class XSAnnotation;
|
---|
108 | class XSComplexTypeDefinition;
|
---|
109 | class XSIDCDefinition;
|
---|
110 | class XSTypeDefinition;
|
---|
111 | class SchemaElementDecl;
|
---|
112 |
|
---|
113 | class XMLPARSER_EXPORT XSElementDeclaration : public XSObject
|
---|
114 | {
|
---|
115 | public:
|
---|
116 |
|
---|
117 | // Constructors and Destructor
|
---|
118 | // -----------------------------------------------------------------------
|
---|
119 | /** @name Constructors */
|
---|
120 | //@{
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * The default constructor
|
---|
124 | *
|
---|
125 | * @param schemaElementDecl
|
---|
126 | * @param typeDefinition
|
---|
127 | * @param substitutionGroupAffiliation
|
---|
128 | * @param annot
|
---|
129 | * @param identityConstraints
|
---|
130 | * @param xsModel
|
---|
131 | * @param elemScope
|
---|
132 | * @param enclosingTypeDefinition
|
---|
133 | * @param manager The configurable memory manager
|
---|
134 | */
|
---|
135 | XSElementDeclaration
|
---|
136 | (
|
---|
137 | SchemaElementDecl* const schemaElementDecl
|
---|
138 | , XSTypeDefinition* const typeDefinition
|
---|
139 | , XSElementDeclaration* const substitutionGroupAffiliation
|
---|
140 | , XSAnnotation* const annot
|
---|
141 | , XSNamedMap<XSIDCDefinition>* const identityConstraints
|
---|
142 | , XSModel* const xsModel
|
---|
143 | , XSConstants::SCOPE elemScope = XSConstants::SCOPE_ABSENT
|
---|
144 | , XSComplexTypeDefinition* const enclosingTypeDefinition = 0
|
---|
145 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
146 | );
|
---|
147 |
|
---|
148 | //@};
|
---|
149 |
|
---|
150 | /** @name Destructor */
|
---|
151 | //@{
|
---|
152 | ~XSElementDeclaration();
|
---|
153 | //@}
|
---|
154 |
|
---|
155 | //---------------------
|
---|
156 | /** @name overridden XSXSObject methods */
|
---|
157 |
|
---|
158 | //@{
|
---|
159 |
|
---|
160 | /**
|
---|
161 | * The name of type <code>NCName</code> of this declaration as defined in
|
---|
162 | * XML Namespaces.
|
---|
163 | */
|
---|
164 | const XMLCh* getName();
|
---|
165 |
|
---|
166 | /**
|
---|
167 | * The [target namespace] of this object, or <code>null</code> if it is
|
---|
168 | * unspecified.
|
---|
169 | */
|
---|
170 | const XMLCh* getNamespace();
|
---|
171 |
|
---|
172 | /**
|
---|
173 | * A namespace schema information item corresponding to the target
|
---|
174 | * namespace of the component, if it's globally declared; or null
|
---|
175 | * otherwise.
|
---|
176 | */
|
---|
177 | XSNamespaceItem *getNamespaceItem();
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * Return a unique identifier for a component within this XSModel, to
|
---|
181 | * optimize querying.
|
---|
182 | * @return id unique for this type of component within this XSModel.
|
---|
183 | */
|
---|
184 | unsigned int getId() const;
|
---|
185 |
|
---|
186 | //@}
|
---|
187 |
|
---|
188 | //---------------------
|
---|
189 | /** @name XSElementDeclaration methods */
|
---|
190 |
|
---|
191 | //@{
|
---|
192 |
|
---|
193 | /**
|
---|
194 | * [type definition]: either a simple type definition or a complex type
|
---|
195 | * definition.
|
---|
196 | */
|
---|
197 | XSTypeDefinition *getTypeDefinition() const;
|
---|
198 |
|
---|
199 | /**
|
---|
200 | * Optional. One of <code>SCOPE_GLOBAL</code>, <code>SCOPE_LOCAL</code>,
|
---|
201 | * or <code>SCOPE_ABSENT</code>. If the scope is local, then the
|
---|
202 | * <code>enclosingCTDefinition</code> is present.
|
---|
203 | */
|
---|
204 | XSConstants::SCOPE getScope() const;
|
---|
205 |
|
---|
206 | /**
|
---|
207 | * The complex type definition for locally scoped declarations (see
|
---|
208 | * <code>scope</code>).
|
---|
209 | */
|
---|
210 | XSComplexTypeDefinition *getEnclosingCTDefinition() const;
|
---|
211 |
|
---|
212 | /**
|
---|
213 | * [Value constraint]: one of <code>VC_NONE, VC_DEFAULT, VC_FIXED</code>.
|
---|
214 | */
|
---|
215 | XSConstants::VALUE_CONSTRAINT getConstraintType() const;
|
---|
216 |
|
---|
217 | /**
|
---|
218 | * [Value constraint]: the actual value with respect to the [type
|
---|
219 | * definition].
|
---|
220 | */
|
---|
221 | const XMLCh *getConstraintValue();
|
---|
222 |
|
---|
223 | /**
|
---|
224 | * If nillable is true, then an element may also be valid if it carries
|
---|
225 | * the namespace qualified attribute with local name <code>nil</code>
|
---|
226 | * from namespace <code>http://www.w3.org/2001/XMLSchema-instance</code>
|
---|
227 | * and value <code>true</code> (xsi:nil) even if it has no text or
|
---|
228 | * element content despite a <code>content type</code> which would
|
---|
229 | * otherwise require content.
|
---|
230 | */
|
---|
231 | bool getNillable() const;
|
---|
232 |
|
---|
233 | /**
|
---|
234 | * identity-constraint definitions: a set of constraint definitions.
|
---|
235 | */
|
---|
236 | XSNamedMap <XSIDCDefinition> *getIdentityConstraints();
|
---|
237 |
|
---|
238 | /**
|
---|
239 | * [substitution group affiliation]: optional. A top-level element
|
---|
240 | * definition.
|
---|
241 | */
|
---|
242 | XSElementDeclaration *getSubstitutionGroupAffiliation() const;
|
---|
243 |
|
---|
244 | /**
|
---|
245 | * Convenience method. Check if <code>exclusion</code> is a substitution
|
---|
246 | * group exclusion for this element declaration.
|
---|
247 | * @param exclusion
|
---|
248 | * <code>DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code> or
|
---|
249 | * <code>DERIVATION_NONE</code>. Represents final set for the element.
|
---|
250 | * @return True if <code>exclusion</code> is a part of the substitution
|
---|
251 | * group exclusion subset.
|
---|
252 | */
|
---|
253 | bool isSubstitutionGroupExclusion(XSConstants::DERIVATION_TYPE exclusion);
|
---|
254 |
|
---|
255 | /**
|
---|
256 | * [substitution group exclusions]: the returned value is a bit
|
---|
257 | * combination of the subset of {
|
---|
258 | * <code>DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code>} or
|
---|
259 | * <code>DERIVATION_NONE</code>.
|
---|
260 | */
|
---|
261 | short getSubstitutionGroupExclusions() const;
|
---|
262 |
|
---|
263 | /**
|
---|
264 | * Convenience method. Check if <code>disallowed</code> is a disallowed
|
---|
265 | * substitution for this element declaration.
|
---|
266 | * @param disallowed {
|
---|
267 | * <code>DERIVATION_SUBSTITUTION, DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code>
|
---|
268 | * } or <code>DERIVATION_NONE</code>. Represents a block set for the
|
---|
269 | * element.
|
---|
270 | * @return True if <code>disallowed</code> is a part of the substitution
|
---|
271 | * group exclusion subset.
|
---|
272 | */
|
---|
273 | bool isDisallowedSubstitution(XSConstants::DERIVATION_TYPE disallowed);
|
---|
274 |
|
---|
275 | /**
|
---|
276 | * [disallowed substitutions]: the returned value is a bit combination of
|
---|
277 | * the subset of {
|
---|
278 | * <code>DERIVATION_SUBSTITUTION, DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code>
|
---|
279 | * } corresponding to substitutions disallowed by this
|
---|
280 | * <code>XSElementDeclaration</code> or <code>DERIVATION_NONE</code>.
|
---|
281 | */
|
---|
282 | short getDisallowedSubstitutions() const;
|
---|
283 |
|
---|
284 | /**
|
---|
285 | * {abstract} A boolean.
|
---|
286 | */
|
---|
287 | bool getAbstract() const;
|
---|
288 |
|
---|
289 | /**
|
---|
290 | * Optional. Annotation.
|
---|
291 | */
|
---|
292 | XSAnnotation *getAnnotation() const;
|
---|
293 |
|
---|
294 | //@}
|
---|
295 |
|
---|
296 | //----------------------------------
|
---|
297 | /** methods needed by implementation */
|
---|
298 |
|
---|
299 | //@{
|
---|
300 | /**
|
---|
301 | * Set the id to be returned on getId().
|
---|
302 | */
|
---|
303 | void setId(unsigned int id);
|
---|
304 |
|
---|
305 | void setTypeDefinition(XSTypeDefinition* typeDefinition);
|
---|
306 |
|
---|
307 | //@}
|
---|
308 | private:
|
---|
309 |
|
---|
310 | void setEnclosingCTDefinition(XSComplexTypeDefinition* const toSet);
|
---|
311 | friend class XSObjectFactory;
|
---|
312 |
|
---|
313 | // -----------------------------------------------------------------------
|
---|
314 | // Unimplemented constructors and operators
|
---|
315 | // -----------------------------------------------------------------------
|
---|
316 | XSElementDeclaration(const XSElementDeclaration&);
|
---|
317 | XSElementDeclaration & operator=(const XSElementDeclaration &);
|
---|
318 |
|
---|
319 | protected:
|
---|
320 |
|
---|
321 | // -----------------------------------------------------------------------
|
---|
322 | // data members
|
---|
323 | // -----------------------------------------------------------------------
|
---|
324 | short fDisallowedSubstitutions;
|
---|
325 | short fSubstitutionGroupExclusions;
|
---|
326 | unsigned int fId;
|
---|
327 | XSConstants::SCOPE fScope;
|
---|
328 | SchemaElementDecl* fSchemaElementDecl;
|
---|
329 | XSTypeDefinition* fTypeDefinition;
|
---|
330 | XSComplexTypeDefinition* fEnclosingTypeDefinition;
|
---|
331 | XSElementDeclaration* fSubstitutionGroupAffiliation;
|
---|
332 | XSAnnotation* fAnnotation;
|
---|
333 | XSNamedMap<XSIDCDefinition>* fIdentityConstraints;
|
---|
334 | };
|
---|
335 |
|
---|
336 | inline XSTypeDefinition* XSElementDeclaration::getTypeDefinition() const
|
---|
337 | {
|
---|
338 | return fTypeDefinition;
|
---|
339 | }
|
---|
340 |
|
---|
341 | inline XSNamedMap<XSIDCDefinition>* XSElementDeclaration::getIdentityConstraints()
|
---|
342 | {
|
---|
343 | return fIdentityConstraints;
|
---|
344 | }
|
---|
345 |
|
---|
346 | inline XSElementDeclaration* XSElementDeclaration::getSubstitutionGroupAffiliation() const
|
---|
347 | {
|
---|
348 | return fSubstitutionGroupAffiliation;
|
---|
349 | }
|
---|
350 |
|
---|
351 | inline short XSElementDeclaration::getSubstitutionGroupExclusions() const
|
---|
352 | {
|
---|
353 | return fSubstitutionGroupExclusions;
|
---|
354 | }
|
---|
355 |
|
---|
356 | inline short XSElementDeclaration::getDisallowedSubstitutions() const
|
---|
357 | {
|
---|
358 | return fDisallowedSubstitutions;
|
---|
359 | }
|
---|
360 |
|
---|
361 | inline XSAnnotation *XSElementDeclaration::getAnnotation() const
|
---|
362 | {
|
---|
363 | return fAnnotation;
|
---|
364 | }
|
---|
365 |
|
---|
366 | inline void XSElementDeclaration::setId(unsigned int id)
|
---|
367 | {
|
---|
368 | fId = id;
|
---|
369 | }
|
---|
370 |
|
---|
371 | inline XSConstants::SCOPE XSElementDeclaration::getScope() const
|
---|
372 | {
|
---|
373 | return fScope;
|
---|
374 | }
|
---|
375 |
|
---|
376 | inline XSComplexTypeDefinition *XSElementDeclaration::getEnclosingCTDefinition() const
|
---|
377 | {
|
---|
378 | return fEnclosingTypeDefinition;
|
---|
379 | }
|
---|
380 |
|
---|
381 | inline void XSElementDeclaration::setTypeDefinition(XSTypeDefinition* typeDefinition)
|
---|
382 | {
|
---|
383 | fTypeDefinition = typeDefinition;
|
---|
384 | }
|
---|
385 |
|
---|
386 | inline void XSElementDeclaration::setEnclosingCTDefinition(XSComplexTypeDefinition* const toSet)
|
---|
387 | {
|
---|
388 | fEnclosingTypeDefinition = toSet;
|
---|
389 | }
|
---|
390 |
|
---|
391 | XERCES_CPP_NAMESPACE_END
|
---|
392 |
|
---|
393 | #endif
|
---|