source: NonGTP/Xerces/xerces/include/xercesc/framework/psvi/XSElementDeclaration.hpp @ 358

Revision 358, 11.0 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 2003,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Log: XSElementDeclaration.hpp,v $
19 * Revision 1.11  2004/09/08 13:56:08  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.10  2004/05/04 19:02:40  cargilld
23 * Enable IDs to work on all kinds of schema components
24 *
25 * Revision 1.9  2003/12/24 17:42:02  knoaman
26 * Misc. PSVI updates
27 *
28 * Revision 1.8  2003/12/01 23:23:26  neilg
29 * fix for bug 25118; thanks to Jeroen Witmond
30 *
31 * Revision 1.7  2003/12/01 20:41:25  neilg
32 * fix for infinite loop between XSComplexTypeDefinitions and XSElementDeclarations; from David Cargill
33 *
34 * Revision 1.6  2003/11/23 16:20:16  knoaman
35 * PSVI: pass scope and enclosing type during construction.
36 *
37 * Revision 1.5  2003/11/21 17:29:53  knoaman
38 * PSVI update
39 *
40 * Revision 1.4  2003/11/14 22:47:53  neilg
41 * fix bogus log message from previous commit...
42 *
43 * Revision 1.3  2003/11/14 22:33:30  neilg
44 * Second phase of schema component model implementation. 
45 * Implement XSModel, XSNamespaceItem, and the plumbing necessary
46 * to connect them to the other components.
47 * Thanks to David Cargill.
48 *
49 * Revision 1.2  2003/11/06 15:30:04  neilg
50 * 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.
51 *
52 * Revision 1.1  2003/09/16 14:33:36  neilg
53 * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
54 *
55 */
56
57#if !defined(XSELEMENTDECLARATION_HPP)
58#define XSELEMENTDECLARATION_HPP
59
60#include <xercesc/framework/psvi/XSObject.hpp>
61#include <xercesc/framework/psvi/XSNamedMap.hpp>
62
63XERCES_CPP_NAMESPACE_BEGIN
64
65/**
66 * This class describes all properties of a Schema Element Declaration
67 * component.
68 * This is *always* owned by the validator /parser object from which
69 * it is obtained. 
70 */
71
72// forward declarations
73class XSAnnotation;
74class XSComplexTypeDefinition;
75class XSIDCDefinition;
76class XSTypeDefinition;
77class SchemaElementDecl;
78
79class XMLPARSER_EXPORT XSElementDeclaration : public XSObject
80{
81public:
82
83    //  Constructors and Destructor
84    // -----------------------------------------------------------------------
85    /** @name Constructors */
86    //@{
87
88    /**
89      * The default constructor
90      *
91      * @param  schemaElementDecl
92      * @param  typeDefinition
93      * @param  substitutionGroupAffiliation
94      * @param  annot
95      * @param  identityConstraints
96      * @param  xsModel
97      * @param  elemScope
98      * @param  enclosingTypeDefinition
99      * @param  manager     The configurable memory manager
100      */
101    XSElementDeclaration
102    (
103        SchemaElementDecl* const             schemaElementDecl
104        , XSTypeDefinition* const            typeDefinition
105        , XSElementDeclaration* const        substitutionGroupAffiliation
106        , XSAnnotation* const                annot
107        , XSNamedMap<XSIDCDefinition>* const identityConstraints
108        , XSModel* const                     xsModel
109        , XSConstants::SCOPE                 elemScope = XSConstants::SCOPE_ABSENT
110        , XSComplexTypeDefinition* const     enclosingTypeDefinition = 0
111        , MemoryManager* const               manager = XMLPlatformUtils::fgMemoryManager
112    );
113
114    //@};
115
116    /** @name Destructor */
117    //@{
118    ~XSElementDeclaration();
119    //@}
120
121    //---------------------
122    /** @name overridden XSXSObject methods */
123
124    //@{
125
126    /**
127     * The name of type <code>NCName</code> of this declaration as defined in
128     * XML Namespaces.
129     */
130    const XMLCh* getName();
131
132    /**
133     *  The [target namespace] of this object, or <code>null</code> if it is
134     * unspecified.
135     */
136    const XMLCh* getNamespace();
137
138    /**
139     * A namespace schema information item corresponding to the target
140     * namespace of the component, if it's globally declared; or null
141     * otherwise.
142     */
143    XSNamespaceItem *getNamespaceItem();
144
145    //@}
146
147    //---------------------
148    /** @name XSElementDeclaration methods */
149
150    //@{
151
152    /**
153     * [type definition]: either a simple type definition or a complex type
154     * definition.
155     */
156    XSTypeDefinition *getTypeDefinition() const;
157
158    /**
159     * Optional. One of <code>SCOPE_GLOBAL</code>, <code>SCOPE_LOCAL</code>,
160     * or <code>SCOPE_ABSENT</code>. If the scope is local, then the
161     * <code>enclosingCTDefinition</code> is present.
162     */
163    XSConstants::SCOPE getScope() const;
164
165    /**
166     * The complex type definition for locally scoped declarations (see
167     * <code>scope</code>).
168     */
169    XSComplexTypeDefinition *getEnclosingCTDefinition() const;
170
171    /**
172     * [Value constraint]: one of <code>VC_NONE, VC_DEFAULT, VC_FIXED</code>.
173     */
174    XSConstants::VALUE_CONSTRAINT getConstraintType() const;
175
176    /**
177     * [Value constraint]: the actual value with respect to the [type
178     * definition].
179     */
180    const XMLCh *getConstraintValue();
181
182    /**
183     * If nillable is true, then an element may also be valid if it carries
184     * the namespace qualified attribute with local name <code>nil</code>
185     * from namespace <code>http://www.w3.org/2001/XMLSchema-instance</code>
186     * and value <code>true</code> (xsi:nil) even if it has no text or
187     * element content despite a <code>content type</code> which would
188     * otherwise require content.
189     */
190    bool getNillable() const;
191
192    /**
193     * identity-constraint definitions: a set of constraint definitions.
194     */
195    XSNamedMap <XSIDCDefinition> *getIdentityConstraints();
196
197    /**
198     * [substitution group affiliation]: optional. A top-level element
199     * definition.
200     */
201    XSElementDeclaration *getSubstitutionGroupAffiliation() const;
202
203    /**
204     * Convenience method. Check if <code>exclusion</code> is a substitution
205     * group exclusion for this element declaration.
206     * @param exclusion 
207     *   <code>DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code> or
208     *   <code>DERIVATION_NONE</code>. Represents final set for the element.
209     * @return True if <code>exclusion</code> is a part of the substitution
210     *   group exclusion subset.
211     */
212    bool isSubstitutionGroupExclusion(XSConstants::DERIVATION_TYPE exclusion);
213
214    /**
215     * [substitution group exclusions]: the returned value is a bit
216     * combination of the subset of {
217     * <code>DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code>} or
218     * <code>DERIVATION_NONE</code>.
219     */
220    short getSubstitutionGroupExclusions() const;
221
222    /**
223     * Convenience method. Check if <code>disallowed</code> is a disallowed
224     * substitution for this element declaration.
225     * @param disallowed {
226     *   <code>DERIVATION_SUBSTITUTION, DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code>
227     *   } or <code>DERIVATION_NONE</code>. Represents a block set for the
228     *   element.
229     * @return True if <code>disallowed</code> is a part of the substitution
230     *   group exclusion subset.
231     */
232    bool isDisallowedSubstitution(XSConstants::DERIVATION_TYPE disallowed);
233
234    /**
235     * [disallowed substitutions]: the returned value is a bit combination of
236     * the subset of {
237     * <code>DERIVATION_SUBSTITUTION, DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code>
238     * } corresponding to substitutions disallowed by this
239     * <code>XSElementDeclaration</code> or <code>DERIVATION_NONE</code>.
240     */
241    short getDisallowedSubstitutions() const;
242
243    /**
244     * {abstract} A boolean.
245     */
246    bool getAbstract() const;
247
248    /**
249     * Optional. Annotation.
250     */
251    XSAnnotation *getAnnotation() const;
252
253    //@}
254
255    //----------------------------------
256    /** methods needed by implementation */
257
258    //@{
259
260    void setTypeDefinition(XSTypeDefinition* typeDefinition);
261
262    //@}
263private:
264
265    void setEnclosingCTDefinition(XSComplexTypeDefinition* const toSet);
266    friend class XSObjectFactory;
267
268    // -----------------------------------------------------------------------
269    //  Unimplemented constructors and operators
270    // -----------------------------------------------------------------------
271    XSElementDeclaration(const XSElementDeclaration&);
272    XSElementDeclaration & operator=(const XSElementDeclaration &);
273
274protected:
275
276    // -----------------------------------------------------------------------
277    //  data members
278    // -----------------------------------------------------------------------
279    short                         fDisallowedSubstitutions;
280    short                         fSubstitutionGroupExclusions;   
281    XSConstants::SCOPE            fScope;
282    SchemaElementDecl*            fSchemaElementDecl;
283    XSTypeDefinition*             fTypeDefinition;
284    XSComplexTypeDefinition*      fEnclosingTypeDefinition;
285    XSElementDeclaration*         fSubstitutionGroupAffiliation;
286    XSAnnotation*                 fAnnotation;
287    XSNamedMap<XSIDCDefinition>*  fIdentityConstraints;
288};
289
290inline XSTypeDefinition* XSElementDeclaration::getTypeDefinition() const
291{
292    return fTypeDefinition;
293}
294
295inline XSNamedMap<XSIDCDefinition>* XSElementDeclaration::getIdentityConstraints()
296{
297    return fIdentityConstraints;
298}
299
300inline XSElementDeclaration* XSElementDeclaration::getSubstitutionGroupAffiliation() const
301{
302    return fSubstitutionGroupAffiliation;
303}
304
305inline short XSElementDeclaration::getSubstitutionGroupExclusions() const
306{
307    return fSubstitutionGroupExclusions;
308}
309
310inline short XSElementDeclaration::getDisallowedSubstitutions() const
311{
312    return fDisallowedSubstitutions;
313}
314
315inline XSAnnotation *XSElementDeclaration::getAnnotation() const
316{
317    return fAnnotation;
318}
319
320inline XSConstants::SCOPE XSElementDeclaration::getScope() const
321{
322    return fScope;
323}
324
325inline XSComplexTypeDefinition *XSElementDeclaration::getEnclosingCTDefinition() const
326{
327    return fEnclosingTypeDefinition;
328}
329
330inline void XSElementDeclaration::setTypeDefinition(XSTypeDefinition* typeDefinition)
331{
332    fTypeDefinition = typeDefinition;
333}
334
335inline void XSElementDeclaration::setEnclosingCTDefinition(XSComplexTypeDefinition* const toSet)
336{
337    fEnclosingTypeDefinition = toSet;
338}
339
340XERCES_CPP_NAMESPACE_END
341
342#endif
Note: See TracBrowser for help on using the repository browser.