Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:52

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_XSELEMENTDECLARATION_HPP)
0023 #define XERCESC_INCLUDE_GUARD_XSELEMENTDECLARATION_HPP
0024 
0025 #include <xercesc/framework/psvi/XSObject.hpp>
0026 #include <xercesc/framework/psvi/XSNamedMap.hpp>
0027 
0028 XERCES_CPP_NAMESPACE_BEGIN
0029 
0030 /**
0031  * This class describes all properties of a Schema Element Declaration
0032  * component.
0033  * This is *always* owned by the validator /parser object from which
0034  * it is obtained.  
0035  */
0036 
0037 // forward declarations
0038 class XSAnnotation;
0039 class XSComplexTypeDefinition;
0040 class XSIDCDefinition;
0041 class XSTypeDefinition;
0042 class SchemaElementDecl;
0043 
0044 class XMLPARSER_EXPORT XSElementDeclaration : public XSObject
0045 {
0046 public:
0047 
0048     //  Constructors and Destructor
0049     // -----------------------------------------------------------------------
0050     /** @name Constructors */
0051     //@{
0052 
0053     /**
0054       * The default constructor 
0055       *
0056       * @param  schemaElementDecl
0057       * @param  typeDefinition
0058       * @param  substitutionGroupAffiliation
0059       * @param  annot
0060       * @param  identityConstraints
0061       * @param  xsModel
0062       * @param  elemScope
0063       * @param  enclosingTypeDefinition
0064       * @param  manager     The configurable memory manager
0065       */
0066     XSElementDeclaration
0067     (
0068         SchemaElementDecl* const             schemaElementDecl
0069         , XSTypeDefinition* const            typeDefinition
0070         , XSElementDeclaration* const        substitutionGroupAffiliation
0071         , XSAnnotation* const                annot
0072         , XSNamedMap<XSIDCDefinition>* const identityConstraints
0073         , XSModel* const                     xsModel
0074         , XSConstants::SCOPE                 elemScope = XSConstants::SCOPE_ABSENT
0075         , XSComplexTypeDefinition* const     enclosingTypeDefinition = 0
0076         , MemoryManager* const               manager = XMLPlatformUtils::fgMemoryManager
0077     );
0078 
0079     //@};
0080 
0081     /** @name Destructor */
0082     //@{
0083     ~XSElementDeclaration();
0084     //@}
0085 
0086     //---------------------
0087     /** @name overridden XSXSObject methods */
0088 
0089     //@{
0090 
0091     /**
0092      * The name of type <code>NCName</code> of this declaration as defined in 
0093      * XML Namespaces.
0094      */
0095     const XMLCh* getName() const;
0096 
0097     /**
0098      *  The [target namespace] of this object, or <code>null</code> if it is 
0099      * unspecified. 
0100      */
0101     const XMLCh* getNamespace() const;
0102 
0103     /**
0104      * A namespace schema information item corresponding to the target 
0105      * namespace of the component, if it's globally declared; or null 
0106      * otherwise.
0107      */
0108     XSNamespaceItem *getNamespaceItem();
0109 
0110     //@}
0111 
0112     //---------------------
0113     /** @name XSElementDeclaration methods */
0114 
0115     //@{
0116 
0117     /**
0118      * [type definition]: either a simple type definition or a complex type 
0119      * definition. 
0120      */
0121     XSTypeDefinition *getTypeDefinition() const;
0122 
0123     /**
0124      * Optional. One of <code>SCOPE_GLOBAL</code>, <code>SCOPE_LOCAL</code>, 
0125      * or <code>SCOPE_ABSENT</code>. If the scope is local, then the 
0126      * <code>enclosingCTDefinition</code> is present. 
0127      */
0128     XSConstants::SCOPE getScope() const;
0129 
0130     /**
0131      * The complex type definition for locally scoped declarations (see 
0132      * <code>scope</code>). 
0133      */
0134     XSComplexTypeDefinition *getEnclosingCTDefinition() const;
0135 
0136     /**
0137      * [Value constraint]: one of <code>VC_NONE, VC_DEFAULT, VC_FIXED</code>. 
0138      */
0139     XSConstants::VALUE_CONSTRAINT getConstraintType() const;
0140 
0141     /**
0142      * [Value constraint]: the actual value with respect to the [type 
0143      * definition]. 
0144      */
0145     const XMLCh *getConstraintValue();
0146 
0147     /**
0148      * If nillable is true, then an element may also be valid if it carries 
0149      * the namespace qualified attribute with local name <code>nil</code> 
0150      * from namespace <code>http://www.w3.org/2001/XMLSchema-instance</code> 
0151      * and value <code>true</code> (xsi:nil) even if it has no text or 
0152      * element content despite a <code>content type</code> which would 
0153      * otherwise require content. 
0154      */
0155     bool getNillable() const;
0156 
0157     /**
0158      * identity-constraint definitions: a set of constraint definitions. 
0159      */
0160     XSNamedMap <XSIDCDefinition> *getIdentityConstraints();
0161 
0162     /**
0163      * [substitution group affiliation]: optional. A top-level element 
0164      * definition. 
0165      */
0166     XSElementDeclaration *getSubstitutionGroupAffiliation() const;
0167 
0168     /**
0169      * Convenience method. Check if <code>exclusion</code> is a substitution 
0170      * group exclusion for this element declaration. 
0171      * @param exclusion  
0172      *   <code>DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code> or 
0173      *   <code>DERIVATION_NONE</code>. Represents final set for the element.
0174      * @return True if <code>exclusion</code> is a part of the substitution 
0175      *   group exclusion subset. 
0176      */
0177     bool isSubstitutionGroupExclusion(XSConstants::DERIVATION_TYPE exclusion);
0178 
0179     /**
0180      * [substitution group exclusions]: the returned value is a bit 
0181      * combination of the subset of {
0182      * <code>DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code>} or 
0183      * <code>DERIVATION_NONE</code>. 
0184      */
0185     short getSubstitutionGroupExclusions() const;
0186 
0187     /**
0188      * Convenience method. Check if <code>disallowed</code> is a disallowed 
0189      * substitution for this element declaration. 
0190      * @param disallowed {
0191      *   <code>DERIVATION_SUBSTITUTION, DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code>
0192      *   } or <code>DERIVATION_NONE</code>. Represents a block set for the 
0193      *   element.
0194      * @return True if <code>disallowed</code> is a part of the substitution 
0195      *   group exclusion subset. 
0196      */
0197     bool isDisallowedSubstitution(XSConstants::DERIVATION_TYPE disallowed);
0198 
0199     /**
0200      * [disallowed substitutions]: the returned value is a bit combination of 
0201      * the subset of {
0202      * <code>DERIVATION_SUBSTITUTION, DERIVATION_EXTENSION, DERIVATION_RESTRICTION</code>
0203      * } corresponding to substitutions disallowed by this 
0204      * <code>XSElementDeclaration</code> or <code>DERIVATION_NONE</code>. 
0205      */
0206     short getDisallowedSubstitutions() const;
0207 
0208     /**
0209      * {abstract} A boolean. 
0210      */
0211     bool getAbstract() const;
0212 
0213     /**
0214      * Optional. Annotation. 
0215      */
0216     XSAnnotation *getAnnotation() const;
0217 
0218     //@}
0219 
0220     //----------------------------------
0221     /** methods needed by implementation */
0222 
0223     //@{
0224 
0225     void setTypeDefinition(XSTypeDefinition* typeDefinition);
0226 
0227     //@}
0228 private:
0229 
0230     void setEnclosingCTDefinition(XSComplexTypeDefinition* const toSet);
0231     friend class XSObjectFactory;
0232 
0233     // -----------------------------------------------------------------------
0234     //  Unimplemented constructors and operators
0235     // -----------------------------------------------------------------------
0236     XSElementDeclaration(const XSElementDeclaration&);
0237     XSElementDeclaration & operator=(const XSElementDeclaration &);
0238 
0239 protected:
0240 
0241     // -----------------------------------------------------------------------
0242     //  data members
0243     // -----------------------------------------------------------------------
0244     short                         fDisallowedSubstitutions;
0245     short                         fSubstitutionGroupExclusions;    
0246     XSConstants::SCOPE            fScope;
0247     SchemaElementDecl*            fSchemaElementDecl;
0248     XSTypeDefinition*             fTypeDefinition;
0249     XSComplexTypeDefinition*      fEnclosingTypeDefinition;
0250     XSElementDeclaration*         fSubstitutionGroupAffiliation;
0251     XSAnnotation*                 fAnnotation;
0252     XSNamedMap<XSIDCDefinition>*  fIdentityConstraints;
0253 };
0254 
0255 inline XSTypeDefinition* XSElementDeclaration::getTypeDefinition() const
0256 {
0257     return fTypeDefinition;
0258 }
0259 
0260 inline XSNamedMap<XSIDCDefinition>* XSElementDeclaration::getIdentityConstraints()
0261 {
0262     return fIdentityConstraints;
0263 }
0264 
0265 inline XSElementDeclaration* XSElementDeclaration::getSubstitutionGroupAffiliation() const
0266 {
0267     return fSubstitutionGroupAffiliation;
0268 }
0269 
0270 inline short XSElementDeclaration::getSubstitutionGroupExclusions() const
0271 {
0272     return fSubstitutionGroupExclusions;
0273 }
0274 
0275 inline short XSElementDeclaration::getDisallowedSubstitutions() const
0276 {
0277     return fDisallowedSubstitutions;
0278 }
0279 
0280 inline XSAnnotation *XSElementDeclaration::getAnnotation() const
0281 {
0282     return fAnnotation;
0283 }
0284 
0285 inline XSConstants::SCOPE XSElementDeclaration::getScope() const
0286 {
0287     return fScope;
0288 }
0289 
0290 inline XSComplexTypeDefinition *XSElementDeclaration::getEnclosingCTDefinition() const
0291 {
0292     return fEnclosingTypeDefinition;
0293 }
0294 
0295 inline void XSElementDeclaration::setTypeDefinition(XSTypeDefinition* typeDefinition)
0296 {
0297     fTypeDefinition = typeDefinition;
0298 }
0299 
0300 inline void XSElementDeclaration::setEnclosingCTDefinition(XSComplexTypeDefinition* const toSet)
0301 {
0302     fEnclosingTypeDefinition = toSet;
0303 }
0304 
0305 XERCES_CPP_NAMESPACE_END
0306 
0307 #endif