Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:15:19

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_SCHEMAELEMENTDECL_HPP)
0023 #define XERCESC_INCLUDE_GUARD_SCHEMAELEMENTDECL_HPP
0024 
0025 #include <xercesc/util/QName.hpp>
0026 #include <xercesc/validators/common/Grammar.hpp>
0027 #include <xercesc/validators/schema/ComplexTypeInfo.hpp>
0028 #include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
0029 #include <xercesc/validators/datatype/DatatypeValidator.hpp>
0030 #include <xercesc/validators/schema/PSVIDefs.hpp>
0031 
0032 XERCES_CPP_NAMESPACE_BEGIN
0033 
0034 class ContentSpecNode;
0035 class SchemaAttDefList;
0036 
0037 //
0038 //  This class is a derivative of the basic element decl. This one implements
0039 //  the virtuals so that they work for a Schema.
0040 //
0041 class VALIDATORS_EXPORT SchemaElementDecl : public XMLElementDecl
0042 {
0043 public :
0044 
0045     // -----------------------------------------------------------------------
0046     //  Class specific types
0047     //
0048     //  ModelTypes
0049     //      Indicates the type of content model that an element has. This
0050     //      indicates how the content model is represented and validated.
0051     // -----------------------------------------------------------------------
0052     enum ModelTypes
0053     {
0054         Empty
0055         , Any
0056         , Mixed_Simple
0057         , Mixed_Complex
0058         , Children
0059         , Simple
0060         , ElementOnlyEmpty
0061         , ModelTypes_Count
0062     };
0063 
0064     // -----------------------------------------------------------------------
0065     //  Constructors and Destructor
0066     // -----------------------------------------------------------------------
0067     SchemaElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0068     SchemaElementDecl
0069     (
0070           const XMLCh* const   prefix
0071         , const XMLCh* const   localPart
0072         , const int            uriId
0073         , const ModelTypes     modelType = Any
0074         , const unsigned int   enclosingScope = Grammar::TOP_LEVEL_SCOPE
0075         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0076     );
0077 
0078     SchemaElementDecl
0079     (
0080           const QName* const   elementName
0081         , const ModelTypes     modelType = Any
0082         , const unsigned int   enclosingScope = Grammar::TOP_LEVEL_SCOPE
0083         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0084     );
0085 
0086     ~SchemaElementDecl();
0087 
0088 
0089     // -----------------------------------------------------------------------
0090     //  The virtual element decl interface
0091     // -----------------------------------------------------------------------
0092     virtual XMLAttDefList& getAttDefList() const;
0093     virtual CharDataOpts getCharDataOpts() const;
0094     virtual bool hasAttDefs() const;
0095     virtual const ContentSpecNode* getContentSpec() const;
0096     virtual ContentSpecNode* getContentSpec();
0097     virtual void setContentSpec(ContentSpecNode* toAdopt);
0098     virtual XMLContentModel* getContentModel();
0099     virtual void setContentModel(XMLContentModel* const newModelToAdopt);
0100     virtual const XMLCh* getFormattedContentModel ()   const;
0101 
0102 
0103     // -----------------------------------------------------------------------
0104     //  Getter methods
0105     // -----------------------------------------------------------------------
0106     const SchemaAttDef* getAttDef(const XMLCh* const baseName, const int uriId) const;
0107     SchemaAttDef* getAttDef(const XMLCh* const baseName, const int uriId);
0108     const SchemaAttDef* getAttWildCard() const;
0109     SchemaAttDef* getAttWildCard();
0110     ModelTypes getModelType() const;
0111     PSVIDefs::PSVIScope getPSVIScope() const;
0112     DatatypeValidator* getDatatypeValidator() const;
0113     unsigned int getEnclosingScope() const;
0114     int getFinalSet() const;
0115     int getBlockSet() const;
0116     int getMiscFlags() const;
0117     XMLCh* getDefaultValue() const;
0118     ComplexTypeInfo* getComplexTypeInfo() const;
0119     virtual bool isGlobalDecl() const;
0120     SchemaElementDecl* getSubstitutionGroupElem() const;
0121 
0122     // -----------------------------------------------------------------------
0123     //  Setter methods
0124     // -----------------------------------------------------------------------
0125     void setModelType(const SchemaElementDecl::ModelTypes toSet);
0126     void setPSVIScope(const PSVIDefs::PSVIScope toSet);
0127     void setDatatypeValidator(DatatypeValidator* newDatatypeValidator);
0128     void setEnclosingScope(const unsigned int enclosingScope);
0129     void setFinalSet(const int finalSet);
0130     void setBlockSet(const int blockSet);
0131     void setMiscFlags(const int flags);
0132     void setDefaultValue(const XMLCh* const value);
0133     void setComplexTypeInfo(ComplexTypeInfo* const typeInfo);   
0134     void setAttWildCard(SchemaAttDef* const attWildCard);
0135     void setSubstitutionGroupElem(SchemaElementDecl* const elemDecl);  
0136 
0137     // -----------------------------------------------------------------------
0138     //  IC methods
0139     // -----------------------------------------------------------------------
0140     void addIdentityConstraint(IdentityConstraint* const ic);
0141     XMLSize_t getIdentityConstraintCount() const;
0142     IdentityConstraint* getIdentityConstraintAt(XMLSize_t index) const;
0143 
0144     /***
0145      * Support for Serialization/De-serialization
0146      ***/
0147     DECL_XSERIALIZABLE(SchemaElementDecl)
0148 
0149     virtual XMLElementDecl::objectType  getObjectType() const;
0150 
0151 private :
0152     // -----------------------------------------------------------------------
0153     //  Unimplemented constructors and operators
0154     // -----------------------------------------------------------------------
0155     SchemaElementDecl(const SchemaElementDecl&);
0156     SchemaElementDecl& operator=(const SchemaElementDecl&);
0157 
0158     // -----------------------------------------------------------------------
0159     //  Private data members
0160     //
0161     //  fModelType
0162     //      The content model type of this element. This tells us what kind
0163     //      of content model to create.
0164     //
0165     //  fDatatypeValidator
0166     //      The DatatypeValidator used to validate this element type.
0167     //
0168     //  fEnclosingScope
0169     //      The enclosing scope where this element is declared.
0170     //
0171     //  fFinalSet
0172     //      The value set of the 'final' attribute.
0173     //
0174     //  fBlockSet
0175     //      The value set of the 'block' attribute.
0176     //
0177     //  fMiscFlags
0178     //      Stores 'abstract/nullable' values
0179     //
0180     //  fDefaultValue
0181     //      The default/fixed value
0182     //
0183     //  fComplexTypeInfo
0184     //      Stores complex type information
0185     //      (no need to delete - handled by schema grammar)
0186     //
0187     //  fAttDefs
0188     //      The list of attributes that are faulted in for this element
0189     //      when ComplexTypeInfo does not exist.  We want to keep track
0190     //      of these faulted in attributes to avoid duplicate redundant
0191     //      error.      
0192     //      
0193     //  fIdentityConstraints
0194     //      Store information about an element identity constraints.
0195     //
0196     //  fAttWildCard
0197     //      Store wildcard attribute in the case of an element with a type of
0198     //      'anyType'.
0199     //
0200     //  fSubstitutionGroupElem
0201     //      The substitution group element declaration.   
0202     // -----------------------------------------------------------------------
0203 
0204     // -----------------------------------------------------------------------
0205     ModelTypes                         fModelType;
0206     PSVIDefs::PSVIScope                fPSVIScope;
0207 
0208     unsigned int                       fEnclosingScope;
0209     int                                fFinalSet;
0210     int                                fBlockSet;
0211     int                                fMiscFlags;    
0212     XMLCh*                             fDefaultValue;
0213     ComplexTypeInfo*                   fComplexTypeInfo;
0214     RefHash2KeysTableOf<SchemaAttDef>* fAttDefs;            
0215     RefVectorOf<IdentityConstraint>*   fIdentityConstraints;
0216     SchemaAttDef*                      fAttWildCard;
0217     SchemaElementDecl*                 fSubstitutionGroupElem;
0218     DatatypeValidator*                 fDatatypeValidator; 
0219 };
0220 
0221 // ---------------------------------------------------------------------------
0222 //  SchemaElementDecl: XMLElementDecl virtual interface implementation
0223 // ---------------------------------------------------------------------------
0224 inline ContentSpecNode* SchemaElementDecl::getContentSpec()
0225 {
0226     if (fComplexTypeInfo != 0) {
0227         return fComplexTypeInfo->getContentSpec();
0228     }
0229 
0230     return 0;
0231 }
0232 
0233 inline const ContentSpecNode* SchemaElementDecl::getContentSpec() const
0234 {
0235     if (fComplexTypeInfo != 0) {
0236         return fComplexTypeInfo->getContentSpec();
0237     }
0238 
0239     return 0;
0240 }
0241 
0242 inline void
0243 SchemaElementDecl::setContentSpec(ContentSpecNode*)
0244 {
0245     //Handled by complexType
0246 }
0247 
0248 inline XMLContentModel* SchemaElementDecl::getContentModel()
0249 {
0250     if (fComplexTypeInfo != 0) {
0251         return fComplexTypeInfo->getContentModel();
0252     }
0253     return 0;
0254 }
0255 
0256 inline void
0257 SchemaElementDecl::setContentModel(XMLContentModel* const)
0258 {
0259     //Handled by complexType
0260 }
0261 
0262 
0263 // ---------------------------------------------------------------------------
0264 //  SchemaElementDecl: Getter methods
0265 // ---------------------------------------------------------------------------
0266 inline SchemaElementDecl::ModelTypes SchemaElementDecl::getModelType() const
0267 {
0268     if (fComplexTypeInfo) {
0269         return (SchemaElementDecl::ModelTypes) fComplexTypeInfo->getContentType();
0270     }
0271 
0272     return fModelType;
0273 }
0274 
0275 inline PSVIDefs::PSVIScope SchemaElementDecl::getPSVIScope() const
0276 {
0277     return fPSVIScope;
0278 }
0279 
0280 inline DatatypeValidator* SchemaElementDecl::getDatatypeValidator() const
0281 {
0282     return fDatatypeValidator;
0283 }
0284 
0285 inline unsigned int SchemaElementDecl::getEnclosingScope() const
0286 {
0287     return fEnclosingScope;
0288 }
0289 
0290 inline int SchemaElementDecl::getFinalSet() const
0291 {
0292     return fFinalSet;
0293 }
0294 
0295 inline int SchemaElementDecl::getBlockSet() const
0296 {
0297     return fBlockSet;
0298 }
0299 
0300 inline int SchemaElementDecl::getMiscFlags() const
0301 {
0302     return fMiscFlags;
0303 }
0304 
0305 inline XMLCh* SchemaElementDecl::getDefaultValue() const
0306 {
0307     return fDefaultValue;
0308 }
0309 
0310 inline ComplexTypeInfo* SchemaElementDecl::getComplexTypeInfo() const
0311 {
0312     return fComplexTypeInfo;
0313 }
0314 
0315 inline const SchemaAttDef* SchemaElementDecl::getAttWildCard() const {
0316     return fAttWildCard;
0317 }
0318 
0319 inline SchemaAttDef* SchemaElementDecl::getAttWildCard() {
0320     return fAttWildCard;
0321 }
0322 
0323 inline bool SchemaElementDecl::isGlobalDecl() const {
0324 
0325     return (fEnclosingScope == Grammar::TOP_LEVEL_SCOPE);
0326 }
0327 
0328 inline SchemaElementDecl*
0329 SchemaElementDecl::getSubstitutionGroupElem() const {
0330 
0331     return fSubstitutionGroupElem;
0332 }
0333 
0334 // ---------------------------------------------------------------------------
0335 //  SchemaElementDecl: Setter methods
0336 // ---------------------------------------------------------------------------
0337 inline void
0338 SchemaElementDecl::setModelType(const SchemaElementDecl::ModelTypes toSet)
0339 {
0340     fModelType = toSet;
0341 }
0342 
0343 inline void
0344 SchemaElementDecl::setPSVIScope(const PSVIDefs::PSVIScope toSet)
0345 {
0346     fPSVIScope = toSet;
0347 }
0348 
0349 inline void SchemaElementDecl::setDatatypeValidator(DatatypeValidator* newDatatypeValidator)
0350 {
0351     fDatatypeValidator = newDatatypeValidator;
0352 }
0353 
0354 inline void SchemaElementDecl::setEnclosingScope(const unsigned int newEnclosingScope)
0355 {
0356     fEnclosingScope = newEnclosingScope;
0357 }
0358 
0359 inline void SchemaElementDecl::setFinalSet(const int finalSet)
0360 {
0361     fFinalSet = finalSet;
0362 }
0363 
0364 inline void SchemaElementDecl::setBlockSet(const int blockSet)
0365 {
0366     fBlockSet = blockSet;
0367 }
0368 
0369 inline void SchemaElementDecl::setMiscFlags(const int flags)
0370 {
0371     fMiscFlags = flags;
0372 }
0373 
0374 inline void SchemaElementDecl::setDefaultValue(const XMLCh* const value)
0375 {
0376     if (fDefaultValue) {
0377         getMemoryManager()->deallocate(fDefaultValue);//delete[] fDefaultValue;
0378     }
0379 
0380     fDefaultValue = XMLString::replicate(value, getMemoryManager());
0381 }
0382 
0383 inline void
0384 SchemaElementDecl::setComplexTypeInfo(ComplexTypeInfo* const typeInfo)
0385 {
0386     fComplexTypeInfo = typeInfo;
0387 }
0388 
0389 inline void
0390 SchemaElementDecl::setAttWildCard(SchemaAttDef* const attWildCard) {
0391 
0392     if (fAttWildCard)
0393         delete fAttWildCard;
0394 
0395     fAttWildCard = attWildCard;
0396 }
0397 
0398 inline void
0399 SchemaElementDecl::setSubstitutionGroupElem(SchemaElementDecl* const elemDecl) {
0400 
0401     fSubstitutionGroupElem = elemDecl;
0402 }
0403 
0404 // ---------------------------------------------------------------------------
0405 //  SchemaElementDecl: IC methods
0406 // ---------------------------------------------------------------------------
0407 inline void
0408 SchemaElementDecl::addIdentityConstraint(IdentityConstraint* const ic) {
0409 
0410     if (!fIdentityConstraints) {
0411         fIdentityConstraints = new (getMemoryManager()) RefVectorOf<IdentityConstraint>(16, true, getMemoryManager());
0412     }
0413 
0414     fIdentityConstraints->addElement(ic);
0415 }
0416 
0417 inline XMLSize_t SchemaElementDecl::getIdentityConstraintCount() const {
0418 
0419     if (fIdentityConstraints) {
0420         return fIdentityConstraints->size();
0421     }
0422 
0423     return 0;
0424 }
0425 
0426 inline IdentityConstraint*
0427 SchemaElementDecl::getIdentityConstraintAt(XMLSize_t index) const {
0428 
0429     if (fIdentityConstraints) {
0430         return fIdentityConstraints->elementAt(index);
0431     }
0432 
0433     return 0;
0434 }
0435 
0436 XERCES_CPP_NAMESPACE_END
0437 
0438 #endif