File indexing completed on 2025-01-18 10:15:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #if !defined(XERCESC_INCLUDE_GUARD_SCHEMAGRAMMAR_HPP)
0023 #define XERCESC_INCLUDE_GUARD_SCHEMAGRAMMAR_HPP
0024
0025 #include <xercesc/framework/XMLNotationDecl.hpp>
0026 #include <xercesc/util/RefHash3KeysIdPool.hpp>
0027 #include <xercesc/util/NameIdPool.hpp>
0028 #include <xercesc/util/StringPool.hpp>
0029 #include <xercesc/validators/common/Grammar.hpp>
0030 #include <xercesc/validators/schema/SchemaElementDecl.hpp>
0031 #include <xercesc/util/ValueVectorOf.hpp>
0032 #include <xercesc/validators/datatype/IDDatatypeValidator.hpp>
0033 #include <xercesc/validators/datatype/DatatypeValidatorFactory.hpp>
0034 #include <xercesc/framework/XMLSchemaDescription.hpp>
0035
0036 XERCES_CPP_NAMESPACE_BEGIN
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 class ComplexTypeInfo;
0051 class XercesGroupInfo;
0052 class XercesAttGroupInfo;
0053 class XSAnnotation;
0054
0055
0056
0057
0058 typedef ValueVectorOf<SchemaElementDecl*> ElemVector;
0059
0060
0061 class VALIDATORS_EXPORT SchemaGrammar : public Grammar
0062 {
0063 public:
0064
0065
0066
0067 SchemaGrammar(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0068 virtual ~SchemaGrammar();
0069
0070
0071
0072
0073 virtual Grammar::GrammarType getGrammarType() const;
0074 virtual const XMLCh* getTargetNamespace() const;
0075
0076
0077
0078
0079 virtual XMLElementDecl* findOrAddElemDecl
0080 (
0081 const unsigned int uriId
0082 , const XMLCh* const baseName
0083 , const XMLCh* const prefixName
0084 , const XMLCh* const qName
0085 , unsigned int scope
0086 , bool& wasAdded
0087 ) ;
0088
0089 virtual XMLSize_t getElemId
0090 (
0091 const unsigned int uriId
0092 , const XMLCh* const baseName
0093 , const XMLCh* const qName
0094 , unsigned int scope
0095 ) const ;
0096
0097 virtual const XMLElementDecl* getElemDecl
0098 (
0099 const unsigned int uriId
0100 , const XMLCh* const baseName
0101 , const XMLCh* const qName
0102 , unsigned int scope
0103 ) const ;
0104
0105 virtual XMLElementDecl* getElemDecl
0106 (
0107 const unsigned int uriId
0108 , const XMLCh* const baseName
0109 , const XMLCh* const qName
0110 , unsigned int scope
0111 );
0112
0113 virtual const XMLElementDecl* getElemDecl
0114 (
0115 const unsigned int elemId
0116 ) const;
0117
0118 virtual XMLElementDecl* getElemDecl
0119 (
0120 const unsigned int elemId
0121 );
0122
0123 virtual const XMLNotationDecl* getNotationDecl
0124 (
0125 const XMLCh* const notName
0126 ) const;
0127
0128 virtual XMLNotationDecl* getNotationDecl
0129 (
0130 const XMLCh* const notName
0131 );
0132
0133 virtual bool getValidated() const;
0134
0135 virtual XMLElementDecl* putElemDecl
0136 (
0137 const unsigned int uriId
0138 , const XMLCh* const baseName
0139 , const XMLCh* const prefixName
0140 , const XMLCh* const qName
0141 , unsigned int scope
0142 , const bool notDeclared = false
0143 );
0144
0145 virtual XMLSize_t putElemDecl
0146 (
0147 XMLElementDecl* const elemDecl
0148 , const bool notDeclared = false
0149 ) ;
0150
0151 virtual XMLSize_t putNotationDecl
0152 (
0153 XMLNotationDecl* const notationDecl
0154 ) const;
0155
0156 virtual void setValidated(const bool newState);
0157
0158 virtual void reset();
0159
0160
0161
0162
0163 RefHash3KeysIdPoolEnumerator<SchemaElementDecl> getElemEnumerator() const;
0164 NameIdPoolEnumerator<XMLNotationDecl> getNotationEnumerator() const;
0165 RefHashTableOf<XMLAttDef>* getAttributeDeclRegistry() const;
0166 RefHashTableOf<ComplexTypeInfo>* getComplexTypeRegistry() const;
0167 RefHashTableOf<XercesGroupInfo>* getGroupInfoRegistry() const;
0168 RefHashTableOf<XercesAttGroupInfo>* getAttGroupInfoRegistry() const;
0169 DatatypeValidatorFactory* getDatatypeRegistry();
0170 RefHash2KeysTableOf<ElemVector>* getValidSubstitutionGroups() const;
0171
0172
0173
0174
0175 void setTargetNamespace(const XMLCh* const targetNamespace);
0176 void setAttributeDeclRegistry(RefHashTableOf<XMLAttDef>* const attReg);
0177 void setComplexTypeRegistry(RefHashTableOf<ComplexTypeInfo>* const other);
0178 void setGroupInfoRegistry(RefHashTableOf<XercesGroupInfo>* const other);
0179 void setAttGroupInfoRegistry(RefHashTableOf<XercesAttGroupInfo>* const other);
0180 void setValidSubstitutionGroups(RefHash2KeysTableOf<ElemVector>* const);
0181
0182 virtual void setGrammarDescription( XMLGrammarDescription*);
0183 virtual XMLGrammarDescription* getGrammarDescription() const;
0184
0185
0186
0187
0188 XMLSize_t putGroupElemDecl
0189 (
0190 XMLElementDecl* const elemDecl
0191 ) const;
0192
0193
0194
0195
0196
0197
0198
0199 void putAnnotation(void* key, XSAnnotation* const annotation);
0200
0201
0202
0203
0204
0205
0206 void addAnnotation(XSAnnotation* const annotation);
0207
0208
0209
0210
0211
0212
0213
0214 XSAnnotation* getAnnotation(const void* const key);
0215
0216
0217
0218
0219
0220
0221
0222 const XSAnnotation* getAnnotation(const void* const key) const;
0223
0224
0225
0226
0227 XSAnnotation* getAnnotation();
0228 const XSAnnotation* getAnnotation() const;
0229
0230
0231
0232
0233 RefHashTableOf<XSAnnotation, PtrHasher>* getAnnotations();
0234 const RefHashTableOf<XSAnnotation, PtrHasher>* getAnnotations() const;
0235
0236
0237
0238
0239 unsigned int getScopeCount () const;
0240 void setScopeCount (unsigned int);
0241
0242
0243
0244
0245 unsigned int getAnonTypeCount () const;
0246 void setAnonTypeCount (unsigned int);
0247
0248
0249
0250
0251 DECL_XSERIALIZABLE(SchemaGrammar)
0252
0253 private:
0254
0255
0256
0257 SchemaGrammar(const SchemaGrammar&);
0258 SchemaGrammar& operator=(const SchemaGrammar&);
0259
0260
0261
0262
0263 void cleanUp();
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319 XMLCh* fTargetNamespace;
0320 RefHash3KeysIdPool<SchemaElementDecl>* fElemDeclPool;
0321 RefHash3KeysIdPool<SchemaElementDecl>* fElemNonDeclPool;
0322 RefHash3KeysIdPool<SchemaElementDecl>* fGroupElemDeclPool;
0323 NameIdPool<XMLNotationDecl>* fNotationDeclPool;
0324 RefHashTableOf<XMLAttDef>* fAttributeDeclRegistry;
0325 RefHashTableOf<ComplexTypeInfo>* fComplexTypeRegistry;
0326 RefHashTableOf<XercesGroupInfo>* fGroupInfoRegistry;
0327 RefHashTableOf<XercesAttGroupInfo>* fAttGroupInfoRegistry;
0328 RefHash2KeysTableOf<ElemVector>* fValidSubstitutionGroups;
0329 MemoryManager* fMemoryManager;
0330 XMLSchemaDescription* fGramDesc;
0331 RefHashTableOf<XSAnnotation, PtrHasher>* fAnnotations;
0332
0333 bool fValidated;
0334 DatatypeValidatorFactory fDatatypeRegistry;
0335
0336 unsigned int fScopeCount;
0337 unsigned int fAnonTypeCount;
0338 };
0339
0340
0341
0342
0343
0344 inline RefHash3KeysIdPoolEnumerator<SchemaElementDecl>
0345 SchemaGrammar::getElemEnumerator() const
0346 {
0347 return RefHash3KeysIdPoolEnumerator<SchemaElementDecl>(fElemDeclPool, false, fMemoryManager);
0348 }
0349
0350 inline NameIdPoolEnumerator<XMLNotationDecl>
0351 SchemaGrammar::getNotationEnumerator() const
0352 {
0353 return NameIdPoolEnumerator<XMLNotationDecl>(fNotationDeclPool, fMemoryManager);
0354 }
0355
0356 inline RefHashTableOf<XMLAttDef>* SchemaGrammar::getAttributeDeclRegistry() const {
0357
0358 return fAttributeDeclRegistry;
0359 }
0360
0361 inline RefHashTableOf<ComplexTypeInfo>*
0362 SchemaGrammar::getComplexTypeRegistry() const {
0363
0364 return fComplexTypeRegistry;
0365 }
0366
0367 inline RefHashTableOf<XercesGroupInfo>*
0368 SchemaGrammar::getGroupInfoRegistry() const {
0369
0370 return fGroupInfoRegistry;
0371 }
0372
0373 inline RefHashTableOf<XercesAttGroupInfo>*
0374 SchemaGrammar::getAttGroupInfoRegistry() const {
0375
0376 return fAttGroupInfoRegistry;
0377 }
0378
0379 inline DatatypeValidatorFactory* SchemaGrammar::getDatatypeRegistry() {
0380
0381 return &fDatatypeRegistry;
0382 }
0383
0384 inline RefHash2KeysTableOf<ElemVector>*
0385 SchemaGrammar::getValidSubstitutionGroups() const {
0386
0387 return fValidSubstitutionGroups;
0388 }
0389
0390 inline XMLGrammarDescription* SchemaGrammar::getGrammarDescription() const
0391 {
0392 return fGramDesc;
0393 }
0394
0395 inline XSAnnotation* SchemaGrammar::getAnnotation(const void* const key)
0396 {
0397 return fAnnotations->get(key);
0398 }
0399
0400 inline const XSAnnotation* SchemaGrammar::getAnnotation(const void* const key) const
0401 {
0402 return fAnnotations->get(key);
0403 }
0404
0405 inline XSAnnotation* SchemaGrammar::getAnnotation()
0406 {
0407 return fAnnotations->get(this);
0408 }
0409
0410 inline const XSAnnotation* SchemaGrammar::getAnnotation() const
0411 {
0412 return fAnnotations->get(this);
0413 }
0414
0415 inline RefHashTableOf<XSAnnotation, PtrHasher>* SchemaGrammar::getAnnotations()
0416 {
0417 return fAnnotations;
0418 }
0419
0420 inline const RefHashTableOf<XSAnnotation, PtrHasher>* SchemaGrammar::getAnnotations() const
0421 {
0422 return fAnnotations;
0423 }
0424
0425
0426
0427 inline void SchemaGrammar::setTargetNamespace(const XMLCh* const targetNamespace)
0428 {
0429 if (fTargetNamespace)
0430 fMemoryManager->deallocate(fTargetNamespace);
0431 fTargetNamespace = XMLString::replicate(targetNamespace, fMemoryManager);
0432 }
0433
0434 inline void
0435 SchemaGrammar::setAttributeDeclRegistry(RefHashTableOf<XMLAttDef>* const attReg) {
0436
0437 fAttributeDeclRegistry = attReg;
0438 }
0439
0440 inline void
0441 SchemaGrammar::setComplexTypeRegistry(RefHashTableOf<ComplexTypeInfo>* const other) {
0442
0443 fComplexTypeRegistry = other;
0444 }
0445
0446 inline void
0447 SchemaGrammar::setGroupInfoRegistry(RefHashTableOf<XercesGroupInfo>* const other) {
0448
0449 fGroupInfoRegistry = other;
0450 }
0451
0452 inline void
0453 SchemaGrammar::setAttGroupInfoRegistry(RefHashTableOf<XercesAttGroupInfo>* const other) {
0454
0455 fAttGroupInfoRegistry = other;
0456 }
0457
0458 inline void
0459 SchemaGrammar::setValidSubstitutionGroups(RefHash2KeysTableOf<ElemVector>* const other) {
0460
0461 fValidSubstitutionGroups = other;
0462 }
0463
0464
0465
0466
0467
0468 inline Grammar::GrammarType SchemaGrammar::getGrammarType() const {
0469 return Grammar::SchemaGrammarType;
0470 }
0471
0472 inline const XMLCh* SchemaGrammar::getTargetNamespace() const {
0473 return fTargetNamespace;
0474 }
0475
0476
0477 inline XMLSize_t SchemaGrammar::getElemId (const unsigned int uriId
0478 , const XMLCh* const baseName
0479 , const XMLCh* const
0480 , unsigned int scope ) const
0481 {
0482
0483
0484
0485
0486 const SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope);
0487 if (!decl) {
0488
0489 decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope);
0490
0491 if (!decl)
0492 return XMLElementDecl::fgInvalidElemId;
0493 }
0494 return decl->getId();
0495 }
0496
0497 inline const XMLElementDecl* SchemaGrammar::getElemDecl( const unsigned int uriId
0498 , const XMLCh* const baseName
0499 , const XMLCh* const
0500 , unsigned int scope ) const
0501 {
0502 const SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope);
0503
0504 if (!decl) {
0505
0506 decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope);
0507
0508 if (!decl && fElemNonDeclPool)
0509 decl = fElemNonDeclPool->getByKey(baseName, uriId, scope);
0510 }
0511
0512 return decl;
0513 }
0514
0515 inline XMLElementDecl* SchemaGrammar::getElemDecl (const unsigned int uriId
0516 , const XMLCh* const baseName
0517 , const XMLCh* const
0518 , unsigned int scope )
0519 {
0520 SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope);
0521
0522 if (!decl) {
0523
0524 decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope);
0525
0526 if (!decl && fElemNonDeclPool)
0527 decl = fElemNonDeclPool->getByKey(baseName, uriId, scope);
0528 }
0529
0530 return decl;
0531 }
0532
0533 inline const XMLElementDecl* SchemaGrammar::getElemDecl(const unsigned int elemId) const
0534 {
0535
0536 const SchemaElementDecl* decl = fElemDeclPool->getById(elemId);
0537
0538 if (!decl)
0539 decl = fGroupElemDeclPool->getById(elemId);
0540
0541 return decl;
0542 }
0543
0544 inline XMLElementDecl* SchemaGrammar::getElemDecl(const unsigned int elemId)
0545 {
0546
0547 SchemaElementDecl* decl = fElemDeclPool->getById(elemId);
0548
0549 if (!decl)
0550 decl = fGroupElemDeclPool->getById(elemId);
0551
0552 return decl;
0553 }
0554
0555 inline XMLSize_t
0556 SchemaGrammar::putElemDecl(XMLElementDecl* const elemDecl,
0557 const bool notDeclared)
0558 {
0559 if (notDeclared)
0560 {
0561 if(!fElemNonDeclPool)
0562 fElemNonDeclPool = new (fMemoryManager) RefHash3KeysIdPool<SchemaElementDecl>(29, true, 128, fMemoryManager);
0563 return fElemNonDeclPool->put(elemDecl->getBaseName(), elemDecl->getURI(), ((SchemaElementDecl* )elemDecl)->getEnclosingScope(), (SchemaElementDecl*) elemDecl);
0564 }
0565
0566 return fElemDeclPool->put(elemDecl->getBaseName(), elemDecl->getURI(), ((SchemaElementDecl* )elemDecl)->getEnclosingScope(), (SchemaElementDecl*) elemDecl);
0567 }
0568
0569 inline XMLSize_t SchemaGrammar::putGroupElemDecl (XMLElementDecl* const elemDecl) const
0570 {
0571 return fGroupElemDeclPool->put(elemDecl->getBaseName(), elemDecl->getURI(), ((SchemaElementDecl* )elemDecl)->getEnclosingScope(), (SchemaElementDecl*) elemDecl);
0572 }
0573
0574
0575 inline const XMLNotationDecl* SchemaGrammar::getNotationDecl(const XMLCh* const notName) const
0576 {
0577 return fNotationDeclPool->getByKey(notName);
0578 }
0579
0580 inline XMLNotationDecl* SchemaGrammar::getNotationDecl(const XMLCh* const notName)
0581 {
0582 return fNotationDeclPool->getByKey(notName);
0583 }
0584
0585 inline XMLSize_t SchemaGrammar::putNotationDecl(XMLNotationDecl* const notationDecl) const
0586 {
0587 return fNotationDeclPool->put(notationDecl);
0588 }
0589
0590 inline bool SchemaGrammar::getValidated() const
0591 {
0592 return fValidated;
0593 }
0594
0595 inline void SchemaGrammar::setValidated(const bool newState)
0596 {
0597 fValidated = newState;
0598 }
0599
0600 inline unsigned int
0601 SchemaGrammar::getScopeCount () const
0602 {
0603 return fScopeCount;
0604 }
0605
0606 inline void
0607 SchemaGrammar::setScopeCount (unsigned int scopeCount)
0608 {
0609 fScopeCount = scopeCount;
0610 }
0611
0612 inline unsigned int
0613 SchemaGrammar::getAnonTypeCount () const
0614 {
0615 return fAnonTypeCount;
0616 }
0617
0618 inline void
0619 SchemaGrammar::setAnonTypeCount (unsigned int count)
0620 {
0621 fAnonTypeCount = count;
0622 }
0623
0624 XERCES_CPP_NAMESPACE_END
0625
0626 #endif