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_SCHEMAINFO_HPP)
0023 #define XERCESC_INCLUDE_GUARD_SCHEMAINFO_HPP
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 #include <xercesc/dom/DOMElement.hpp>
0042 #include <xercesc/util/RefVectorOf.hpp>
0043 #include <xercesc/util/ValueVectorOf.hpp>
0044 #include <xercesc/util/RefHashTableOf.hpp>
0045
0046 XERCES_CPP_NAMESPACE_BEGIN
0047
0048
0049
0050
0051 class XMLScanner;
0052 class ValidationContext;
0053 class NamespaceScope;
0054
0055 class VALIDATORS_EXPORT SchemaInfo : public XMemory
0056 {
0057 public:
0058
0059 enum ListType {
0060
0061 IMPORT = 1,
0062 INCLUDE = 2
0063 };
0064
0065 enum {
0066 C_ComplexType,
0067 C_SimpleType,
0068 C_Group,
0069 C_Attribute,
0070 C_AttributeGroup,
0071 C_Element,
0072 C_Notation,
0073
0074 C_Count
0075 };
0076
0077
0078
0079
0080 SchemaInfo(const unsigned short fElemAttrDefaultQualified,
0081 const int blockDefault,
0082 const int finalDefault,
0083 const int targetNSURI,
0084 const NamespaceScope* const currNamespaceScope,
0085 const XMLCh* const schemaURL,
0086 const XMLCh* const targetNSURIString,
0087 const DOMElement* const root,
0088 XMLScanner* xmlScanner,
0089 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0090 ~SchemaInfo();
0091
0092
0093
0094
0095
0096 XMLCh* getCurrentSchemaURL() const;
0097 const XMLCh* getTargetNSURIString() const;
0098 const DOMElement* getRoot() const;
0099 bool getProcessed() const;
0100 int getBlockDefault() const;
0101 int getFinalDefault() const;
0102 int getTargetNSURI() const;
0103 NamespaceScope* getNamespaceScope() const;
0104 unsigned short getElemAttrDefaultQualified() const;
0105 BaseRefVectorEnumerator<SchemaInfo> getImportingListEnumerator() const;
0106 ValueVectorOf<const DOMElement*>* getRecursingAnonTypes() const;
0107 ValueVectorOf<const XMLCh*>* getRecursingTypeNames() const;
0108 ValueVectorOf<DOMNode*>* getNonXSAttList() const;
0109 ValidationContext* getValidationContext() const;
0110
0111
0112
0113
0114 void setProcessed(const bool aValue = true);
0115 void setBlockDefault(const int aValue);
0116 void setFinalDefault(const int aValue);
0117 void setElemAttrDefaultQualified(const unsigned short aValue);
0118 void resetRoot ();
0119
0120
0121
0122
0123 void addSchemaInfo(SchemaInfo* const toAdd, const ListType aListType);
0124 bool containsInfo(const SchemaInfo* const toCheck, const ListType aListType) const;
0125 SchemaInfo* getImportInfo(const unsigned int namespaceURI) const;
0126 DOMElement* getTopLevelComponent(const unsigned short compCategory,
0127 const XMLCh* const compName,
0128 const XMLCh* const name);
0129 DOMElement* getTopLevelComponent(const unsigned short compCategory,
0130 const XMLCh* const compName,
0131 const XMLCh* const name,
0132 SchemaInfo** enclosingSchema);
0133 void updateImportingInfo(SchemaInfo* const importingInfo);
0134 bool circularImportExist(const unsigned int nameSpaceURI);
0135 bool isFailedRedefine(const DOMElement* const anElem);
0136 void addFailedRedefine(const DOMElement* const anElem);
0137 void addRecursingType(const DOMElement* const elem, const XMLCh* const name);
0138
0139 private:
0140
0141
0142
0143 SchemaInfo(const SchemaInfo&);
0144 SchemaInfo& operator=(const SchemaInfo&);
0145
0146
0147
0148
0149 void clearTopLevelComponents();
0150
0151
0152
0153
0154 bool fAdoptInclude;
0155 bool fProcessed;
0156 unsigned short fElemAttrDefaultQualified;
0157 int fBlockDefault;
0158 int fFinalDefault;
0159 int fTargetNSURI;
0160 NamespaceScope* fNamespaceScope;
0161 XMLCh* fCurrentSchemaURL;
0162 XMLCh* fTargetNSURIString;
0163 const DOMElement* fSchemaRootElement;
0164 RefVectorOf<SchemaInfo>* fIncludeInfoList;
0165 RefVectorOf<SchemaInfo>* fImportedInfoList;
0166 RefVectorOf<SchemaInfo>* fImportingInfoList;
0167 ValueVectorOf<const DOMElement*>* fFailedRedefineList;
0168 ValueVectorOf<const DOMElement*>* fRecursingAnonTypes;
0169 ValueVectorOf<const XMLCh*>* fRecursingTypeNames;
0170 RefHashTableOf<DOMElement>* fTopLevelComponents[C_Count];
0171 DOMElement* fLastTopLevelComponent[C_Count];
0172 ValueVectorOf<DOMNode*>* fNonXSAttList;
0173 ValidationContext* fValidationContext;
0174 MemoryManager* fMemoryManager;
0175 };
0176
0177
0178
0179
0180 inline unsigned short SchemaInfo::getElemAttrDefaultQualified() const {
0181
0182 return fElemAttrDefaultQualified;
0183 }
0184
0185 inline bool SchemaInfo::getProcessed() const {
0186
0187 return fProcessed;
0188 }
0189
0190 inline int SchemaInfo::getBlockDefault() const {
0191
0192 return fBlockDefault;
0193 }
0194
0195 inline int SchemaInfo::getFinalDefault() const {
0196
0197 return fFinalDefault;
0198 }
0199
0200 inline NamespaceScope* SchemaInfo::getNamespaceScope() const {
0201 return fNamespaceScope;
0202 }
0203
0204 inline XMLCh* SchemaInfo::getCurrentSchemaURL() const {
0205
0206 return fCurrentSchemaURL;
0207 }
0208
0209 inline const XMLCh* SchemaInfo::getTargetNSURIString() const {
0210
0211 return fTargetNSURIString;
0212 }
0213
0214 inline const DOMElement* SchemaInfo::getRoot() const {
0215
0216 return fSchemaRootElement;
0217 }
0218
0219 inline int SchemaInfo::getTargetNSURI() const {
0220
0221 return fTargetNSURI;
0222 }
0223
0224 inline BaseRefVectorEnumerator<SchemaInfo>
0225 SchemaInfo::getImportingListEnumerator() const {
0226
0227 return BaseRefVectorEnumerator<SchemaInfo>(fImportingInfoList);
0228 }
0229
0230 inline ValueVectorOf<const DOMElement*>*
0231 SchemaInfo::getRecursingAnonTypes() const {
0232
0233 return fRecursingAnonTypes;
0234 }
0235
0236
0237 inline ValueVectorOf<const XMLCh*>*
0238 SchemaInfo::getRecursingTypeNames() const {
0239
0240 return fRecursingTypeNames;
0241 }
0242
0243 inline ValueVectorOf<DOMNode*>* SchemaInfo::getNonXSAttList() const
0244 {
0245 return fNonXSAttList;
0246 }
0247
0248
0249
0250
0251 inline void SchemaInfo::setBlockDefault(const int aValue) {
0252
0253 fBlockDefault = aValue;
0254 }
0255
0256 inline void SchemaInfo::setFinalDefault(const int aValue) {
0257
0258 fFinalDefault = aValue;
0259 }
0260
0261 inline void SchemaInfo::setElemAttrDefaultQualified(const unsigned short aValue) {
0262
0263 fElemAttrDefaultQualified = aValue;
0264 }
0265
0266 inline void SchemaInfo::setProcessed(const bool aValue) {
0267
0268 fProcessed = aValue;
0269
0270
0271
0272
0273
0274
0275
0276
0277 }
0278
0279 inline void SchemaInfo::resetRoot ()
0280 {
0281 fSchemaRootElement = 0;
0282 }
0283
0284
0285
0286
0287 inline void SchemaInfo::addSchemaInfo(SchemaInfo* const toAdd,
0288 const ListType aListType) {
0289
0290 if (aListType == IMPORT) {
0291
0292 if (!fImportedInfoList)
0293 fImportedInfoList = new (fMemoryManager) RefVectorOf<SchemaInfo>(4, false, fMemoryManager);
0294
0295 if (!fImportedInfoList->containsElement(toAdd)) {
0296
0297 fImportedInfoList->addElement(toAdd);
0298 toAdd->updateImportingInfo(this);
0299 }
0300 }
0301 else {
0302
0303 if (!fIncludeInfoList) {
0304
0305 fIncludeInfoList = new (fMemoryManager) RefVectorOf<SchemaInfo>(8, false, fMemoryManager);
0306 fAdoptInclude = true;
0307 }
0308
0309 if (!fIncludeInfoList->containsElement(toAdd)) {
0310
0311 fIncludeInfoList->addElement(toAdd);
0312
0313
0314
0315
0316
0317 if (toAdd->fIncludeInfoList) {
0318 if (toAdd->fIncludeInfoList != fIncludeInfoList) {
0319 XMLSize_t size = toAdd->fIncludeInfoList->size();
0320 for (XMLSize_t i=0; i<size; i++) {
0321 if (!fIncludeInfoList->containsElement(toAdd->fIncludeInfoList->elementAt(i))) {
0322 fIncludeInfoList->addElement(toAdd->fIncludeInfoList->elementAt(i));
0323 }
0324 }
0325 size = fIncludeInfoList->size();
0326 for (XMLSize_t j=0; j<size; j++) {
0327 if (!toAdd->fIncludeInfoList->containsElement(fIncludeInfoList->elementAt(j))) {
0328 toAdd->fIncludeInfoList->addElement(fIncludeInfoList->elementAt(j));
0329 }
0330 }
0331 }
0332 }
0333 else {
0334 toAdd->fIncludeInfoList = fIncludeInfoList;
0335 }
0336 }
0337 }
0338 }
0339
0340 inline SchemaInfo* SchemaInfo::getImportInfo(const unsigned int namespaceURI) const {
0341
0342 XMLSize_t importSize = (fImportedInfoList) ? fImportedInfoList->size() : 0;
0343 SchemaInfo* currInfo = 0;
0344
0345 for (XMLSize_t i=0; i < importSize; i++) {
0346
0347 currInfo = fImportedInfoList->elementAt(i);
0348
0349 if (currInfo->getTargetNSURI() == (int) namespaceURI)
0350 return currInfo;
0351 }
0352
0353 return 0;
0354 }
0355
0356 inline ValidationContext* SchemaInfo::getValidationContext() const {
0357
0358 return fValidationContext;
0359 }
0360
0361 inline bool SchemaInfo::containsInfo(const SchemaInfo* const toCheck,
0362 const ListType aListType) const {
0363
0364 if ((aListType == INCLUDE) && fIncludeInfoList) {
0365 return fIncludeInfoList->containsElement(toCheck);
0366 }
0367 else if ((aListType == IMPORT) && fImportedInfoList) {
0368 return fImportedInfoList->containsElement(toCheck);
0369 }
0370
0371 return false;
0372 }
0373
0374 inline bool SchemaInfo::circularImportExist(const unsigned int namespaceURI) {
0375
0376 XMLSize_t importSize = fImportingInfoList->size();
0377
0378 for (XMLSize_t i=0; i < importSize; i++) {
0379 if (fImportingInfoList->elementAt(i)->getTargetNSURI() == (int) namespaceURI) {
0380 return true;
0381 }
0382 }
0383
0384 return false;
0385 }
0386
0387 inline bool SchemaInfo::isFailedRedefine(const DOMElement* const anElem) {
0388
0389 if (fFailedRedefineList)
0390 return (fFailedRedefineList->containsElement(anElem));
0391
0392 return false;
0393 }
0394
0395 inline void SchemaInfo::addFailedRedefine(const DOMElement* const anElem) {
0396
0397 if (!fFailedRedefineList) {
0398 fFailedRedefineList = new (fMemoryManager) ValueVectorOf<const DOMElement*>(4, fMemoryManager);
0399 }
0400
0401 fFailedRedefineList->addElement(anElem);
0402 }
0403
0404 inline void SchemaInfo::addRecursingType(const DOMElement* const elem,
0405 const XMLCh* const name) {
0406
0407 if (!fRecursingAnonTypes) {
0408 fRecursingAnonTypes = new (fMemoryManager) ValueVectorOf<const DOMElement*>(8, fMemoryManager);
0409 fRecursingTypeNames = new (fMemoryManager) ValueVectorOf<const XMLCh*>(8, fMemoryManager);
0410 }
0411
0412 fRecursingAnonTypes->addElement(elem);
0413 fRecursingTypeNames->addElement(name);
0414 }
0415
0416 inline void SchemaInfo::clearTopLevelComponents() {
0417
0418 for (unsigned int i = 0; i < C_Count; i++) {
0419
0420 delete fTopLevelComponents[i];
0421 fTopLevelComponents[i] = 0;
0422 fLastTopLevelComponent[i] = 0;
0423 }
0424 }
0425
0426 XERCES_CPP_NAMESPACE_END
0427
0428 #endif
0429
0430
0431
0432