[2674] | 1 | /* |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 3 | * contributor license agreements. See the NOTICE file distributed with |
---|
| 4 | * this work for additional information regarding copyright ownership. |
---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 6 | * (the "License"); you may not use this file except in compliance with |
---|
| 7 | * the License. You may obtain a copy of the License at |
---|
| 8 | * |
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | * |
---|
| 11 | * Unless required by applicable law or agreed to in writing, software |
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | * See the License for the specific language governing permissions and |
---|
| 15 | * limitations under the License. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | /* |
---|
| 19 | * $Id: SchemaGrammar.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | #if !defined(SCHEMAGRAMMAR_HPP) |
---|
| 25 | #define SCHEMAGRAMMAR_HPP |
---|
| 26 | |
---|
| 27 | #include <xercesc/framework/XMLNotationDecl.hpp> |
---|
| 28 | #include <xercesc/util/RefHash3KeysIdPool.hpp> |
---|
| 29 | #include <xercesc/util/NameIdPool.hpp> |
---|
| 30 | #include <xercesc/util/StringPool.hpp> |
---|
| 31 | #include <xercesc/validators/common/Grammar.hpp> |
---|
| 32 | #include <xercesc/validators/schema/SchemaElementDecl.hpp> |
---|
| 33 | #include <xercesc/util/ValueVectorOf.hpp> |
---|
| 34 | #include <xercesc/validators/datatype/IDDatatypeValidator.hpp> |
---|
| 35 | #include <xercesc/validators/datatype/DatatypeValidatorFactory.hpp> |
---|
| 36 | #include <xercesc/framework/XMLSchemaDescription.hpp> |
---|
| 37 | #include <xercesc/framework/ValidationContext.hpp> |
---|
| 38 | |
---|
| 39 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 40 | |
---|
| 41 | // |
---|
| 42 | // This class stores the Schema information |
---|
| 43 | // NOTE: Schemas are not namespace aware, so we just use regular NameIdPool |
---|
| 44 | // data structures to store element and attribute decls. They are all set |
---|
| 45 | // to be in the global namespace and the full QName is used as the base name |
---|
| 46 | // of the decl. This means that all the URI parameters below are expected |
---|
| 47 | // to be null pointers (and anything else will cause an exception.) |
---|
| 48 | // |
---|
| 49 | |
---|
| 50 | // --------------------------------------------------------------------------- |
---|
| 51 | // Forward Declarations |
---|
| 52 | // --------------------------------------------------------------------------- |
---|
| 53 | class ComplexTypeInfo; |
---|
| 54 | class NamespaceScope; |
---|
| 55 | class XercesGroupInfo; |
---|
| 56 | class XercesAttGroupInfo; |
---|
| 57 | class XSAnnotation; |
---|
| 58 | |
---|
| 59 | // --------------------------------------------------------------------------- |
---|
| 60 | // typedef declaration |
---|
| 61 | // --------------------------------------------------------------------------- |
---|
| 62 | typedef ValueVectorOf<SchemaElementDecl*> ElemVector; |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | class VALIDATORS_EXPORT SchemaGrammar : public Grammar |
---|
| 66 | { |
---|
| 67 | public: |
---|
| 68 | // ----------------------------------------------------------------------- |
---|
| 69 | // Constructors and Destructor |
---|
| 70 | // ----------------------------------------------------------------------- |
---|
| 71 | SchemaGrammar(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
| 72 | virtual ~SchemaGrammar(); |
---|
| 73 | |
---|
| 74 | // ----------------------------------------------------------------------- |
---|
| 75 | // Implementation of Virtual Interface |
---|
| 76 | // ----------------------------------------------------------------------- |
---|
| 77 | virtual Grammar::GrammarType getGrammarType() const; |
---|
| 78 | virtual const XMLCh* getTargetNamespace() const; |
---|
| 79 | |
---|
| 80 | // this method should only be used while the grammar is being |
---|
| 81 | // constructed, not while it is being used |
---|
| 82 | // in a validation episode! |
---|
| 83 | virtual XMLElementDecl* findOrAddElemDecl |
---|
| 84 | ( |
---|
| 85 | const unsigned int uriId |
---|
| 86 | , const XMLCh* const baseName |
---|
| 87 | , const XMLCh* const prefixName |
---|
| 88 | , const XMLCh* const qName |
---|
| 89 | , unsigned int scope |
---|
| 90 | , bool& wasAdded |
---|
| 91 | ) ; |
---|
| 92 | |
---|
| 93 | virtual unsigned int getElemId |
---|
| 94 | ( |
---|
| 95 | const unsigned int uriId |
---|
| 96 | , const XMLCh* const baseName |
---|
| 97 | , const XMLCh* const qName |
---|
| 98 | , unsigned int scope |
---|
| 99 | ) const ; |
---|
| 100 | |
---|
| 101 | virtual const XMLElementDecl* getElemDecl |
---|
| 102 | ( |
---|
| 103 | const unsigned int uriId |
---|
| 104 | , const XMLCh* const baseName |
---|
| 105 | , const XMLCh* const qName |
---|
| 106 | , unsigned int scope |
---|
| 107 | ) const ; |
---|
| 108 | |
---|
| 109 | virtual XMLElementDecl* getElemDecl |
---|
| 110 | ( |
---|
| 111 | const unsigned int uriId |
---|
| 112 | , const XMLCh* const baseName |
---|
| 113 | , const XMLCh* const qName |
---|
| 114 | , unsigned int scope |
---|
| 115 | ); |
---|
| 116 | |
---|
| 117 | virtual const XMLElementDecl* getElemDecl |
---|
| 118 | ( |
---|
| 119 | const unsigned int elemId |
---|
| 120 | ) const; |
---|
| 121 | |
---|
| 122 | virtual XMLElementDecl* getElemDecl |
---|
| 123 | ( |
---|
| 124 | const unsigned int elemId |
---|
| 125 | ); |
---|
| 126 | |
---|
| 127 | virtual const XMLNotationDecl* getNotationDecl |
---|
| 128 | ( |
---|
| 129 | const XMLCh* const notName |
---|
| 130 | ) const; |
---|
| 131 | |
---|
| 132 | virtual XMLNotationDecl* getNotationDecl |
---|
| 133 | ( |
---|
| 134 | const XMLCh* const notName |
---|
| 135 | ); |
---|
| 136 | |
---|
| 137 | virtual bool getValidated() const; |
---|
| 138 | |
---|
| 139 | virtual XMLElementDecl* putElemDecl |
---|
| 140 | ( |
---|
| 141 | const unsigned int uriId |
---|
| 142 | , const XMLCh* const baseName |
---|
| 143 | , const XMLCh* const prefixName |
---|
| 144 | , const XMLCh* const qName |
---|
| 145 | , unsigned int scope |
---|
| 146 | , const bool notDeclared = false |
---|
| 147 | ); |
---|
| 148 | |
---|
| 149 | virtual unsigned int putElemDecl |
---|
| 150 | ( |
---|
| 151 | XMLElementDecl* const elemDecl |
---|
| 152 | , const bool notDeclared = false |
---|
| 153 | ) ; |
---|
| 154 | |
---|
| 155 | virtual unsigned int putNotationDecl |
---|
| 156 | ( |
---|
| 157 | XMLNotationDecl* const notationDecl |
---|
| 158 | ) const; |
---|
| 159 | |
---|
| 160 | virtual void setValidated(const bool newState); |
---|
| 161 | |
---|
| 162 | virtual void reset(); |
---|
| 163 | |
---|
| 164 | // ----------------------------------------------------------------------- |
---|
| 165 | // Getter methods |
---|
| 166 | // ----------------------------------------------------------------------- |
---|
| 167 | RefHash3KeysIdPoolEnumerator<SchemaElementDecl> getElemEnumerator() const; |
---|
| 168 | NameIdPoolEnumerator<XMLNotationDecl> getNotationEnumerator() const; |
---|
| 169 | RefHashTableOf<XMLAttDef>* getAttributeDeclRegistry() const; |
---|
| 170 | RefHashTableOf<ComplexTypeInfo>* getComplexTypeRegistry() const; |
---|
| 171 | RefHashTableOf<XercesGroupInfo>* getGroupInfoRegistry() const; |
---|
| 172 | RefHashTableOf<XercesAttGroupInfo>* getAttGroupInfoRegistry() const; |
---|
| 173 | DatatypeValidatorFactory* getDatatypeRegistry(); |
---|
| 174 | NamespaceScope* getNamespaceScope() const; |
---|
| 175 | RefHash2KeysTableOf<ElemVector>* getValidSubstitutionGroups() const; |
---|
| 176 | |
---|
| 177 | //deprecated |
---|
| 178 | RefHashTableOf<XMLRefInfo>* getIDRefList() const; |
---|
| 179 | |
---|
| 180 | ValidationContext* getValidationContext() const; |
---|
| 181 | |
---|
| 182 | // ----------------------------------------------------------------------- |
---|
| 183 | // Setter methods |
---|
| 184 | // ----------------------------------------------------------------------- |
---|
| 185 | void setTargetNamespace(const XMLCh* const targetNamespace); |
---|
| 186 | void setAttributeDeclRegistry(RefHashTableOf<XMLAttDef>* const attReg); |
---|
| 187 | void setComplexTypeRegistry(RefHashTableOf<ComplexTypeInfo>* const other); |
---|
| 188 | void setGroupInfoRegistry(RefHashTableOf<XercesGroupInfo>* const other); |
---|
| 189 | void setAttGroupInfoRegistry(RefHashTableOf<XercesAttGroupInfo>* const other); |
---|
| 190 | void setNamespaceScope(NamespaceScope* const nsScope); |
---|
| 191 | void setValidSubstitutionGroups(RefHash2KeysTableOf<ElemVector>* const); |
---|
| 192 | |
---|
| 193 | virtual void setGrammarDescription( XMLGrammarDescription*); |
---|
| 194 | virtual XMLGrammarDescription* getGrammarDescription() const; |
---|
| 195 | |
---|
| 196 | // ----------------------------------------------------------------------- |
---|
| 197 | // Helper methods |
---|
| 198 | // ----------------------------------------------------------------------- |
---|
| 199 | unsigned int putGroupElemDecl |
---|
| 200 | ( |
---|
| 201 | XMLElementDecl* const elemDecl |
---|
| 202 | ) const; |
---|
| 203 | |
---|
| 204 | // ----------------------------------------------------------------------- |
---|
| 205 | // Annotation management methods |
---|
| 206 | // ----------------------------------------------------------------------- |
---|
| 207 | /** |
---|
| 208 | * Add annotation to the list of annotations for a given key |
---|
| 209 | */ |
---|
| 210 | void putAnnotation(void* key, XSAnnotation* const annotation); |
---|
| 211 | |
---|
| 212 | /** |
---|
| 213 | * Add global annotation |
---|
| 214 | * |
---|
| 215 | * Note: XSAnnotation acts as a linked list |
---|
| 216 | */ |
---|
| 217 | void addAnnotation(XSAnnotation* const annotation); |
---|
| 218 | |
---|
| 219 | /** |
---|
| 220 | * Retrieve the annotation that is associated with the specified key |
---|
| 221 | * |
---|
| 222 | * @param key represents a schema component object (i.e. SchemaGrammar) |
---|
| 223 | * @return XSAnnotation associated with the key object |
---|
| 224 | */ |
---|
| 225 | XSAnnotation* getAnnotation(const void* const key); |
---|
| 226 | |
---|
| 227 | /** |
---|
| 228 | * Retrieve the annotation that is associated with the specified key |
---|
| 229 | * |
---|
| 230 | * @param key represents a schema component object (i.e. SchemaGrammar) |
---|
| 231 | * @return XSAnnotation associated with the key object |
---|
| 232 | */ |
---|
| 233 | const XSAnnotation* getAnnotation(const void* const key) const; |
---|
| 234 | |
---|
| 235 | /** |
---|
| 236 | * Get global annotation |
---|
| 237 | */ |
---|
| 238 | XSAnnotation* getAnnotation(); |
---|
| 239 | const XSAnnotation* getAnnotation() const; |
---|
| 240 | |
---|
| 241 | /** |
---|
| 242 | * Get annotation hash table, to enumerate through them |
---|
| 243 | */ |
---|
| 244 | RefHashTableOf<XSAnnotation>* getAnnotations(); |
---|
| 245 | const RefHashTableOf<XSAnnotation>* getAnnotations() const; |
---|
| 246 | |
---|
| 247 | /*** |
---|
| 248 | * Support for Serialization/De-serialization |
---|
| 249 | ***/ |
---|
| 250 | DECL_XSERIALIZABLE(SchemaGrammar) |
---|
| 251 | |
---|
| 252 | private: |
---|
| 253 | // ----------------------------------------------------------------------- |
---|
| 254 | // Unimplemented constructors and operators |
---|
| 255 | // ----------------------------------------------------------------------- |
---|
| 256 | SchemaGrammar(const SchemaGrammar&); |
---|
| 257 | SchemaGrammar& operator=(const SchemaGrammar&); |
---|
| 258 | |
---|
| 259 | // ----------------------------------------------------------------------- |
---|
| 260 | // Helper methods |
---|
| 261 | // ----------------------------------------------------------------------- |
---|
| 262 | void cleanUp(); |
---|
| 263 | |
---|
| 264 | // ----------------------------------------------------------------------- |
---|
| 265 | // Private data members |
---|
| 266 | // |
---|
| 267 | // fElemDeclPool |
---|
| 268 | // This is the element decl pool. It contains all of the elements |
---|
| 269 | // declared in the Schema (and their associated attributes.) |
---|
| 270 | // |
---|
| 271 | // fElemNonDeclPool |
---|
| 272 | // This is the element decl pool that is is populated as new elements |
---|
| 273 | // are seen in the XML document (not declared in the Schema), and they |
---|
| 274 | // are given default characteristics. |
---|
| 275 | // |
---|
| 276 | // fGroupElemDeclPool |
---|
| 277 | // This is the element decl pool for elements in a group that are |
---|
| 278 | // referenced in different scope. It contains all of the elements |
---|
| 279 | // declared in the Schema (and their associated attributes.) |
---|
| 280 | // |
---|
| 281 | // fNotationDeclPool |
---|
| 282 | // This is a pool of NotationDecl objects, which contains all of the |
---|
| 283 | // notations declared in the Schema. |
---|
| 284 | // |
---|
| 285 | // fTargetNamespace |
---|
| 286 | // Target name space for this grammar. |
---|
| 287 | // |
---|
| 288 | // fAttributeDeclRegistry |
---|
| 289 | // Global attribute declarations |
---|
| 290 | // |
---|
| 291 | // fComplexTypeRegistry |
---|
| 292 | // Stores complexType declaration info |
---|
| 293 | // |
---|
| 294 | // fGroupInfoRegistry |
---|
| 295 | // Stores global <group> declaration info |
---|
| 296 | // |
---|
| 297 | // fAttGroupInfoRegistry |
---|
| 298 | // Stores global <attributeGroup> declaration info |
---|
| 299 | // |
---|
| 300 | // fDatatypeRegistry |
---|
| 301 | // Datatype validator factory |
---|
| 302 | // |
---|
| 303 | // fNamespaceScope |
---|
| 304 | // Prefix to Namespace map |
---|
| 305 | // |
---|
| 306 | // fValidSubstitutionGroups |
---|
| 307 | // Valid list of elements that can substitute a given element |
---|
| 308 | // |
---|
| 309 | // fIDRefList |
---|
| 310 | // List of ids of schema declarations extracted during schema grammar |
---|
| 311 | // traversal |
---|
| 312 | // |
---|
| 313 | // fValidated |
---|
| 314 | // Indicates if the content of the Grammar has been pre-validated |
---|
| 315 | // or not (UPA checking, etc.). When using a cached grammar, no need |
---|
| 316 | // for pre content validation. |
---|
| 317 | // |
---|
| 318 | // fGramDesc: adopted |
---|
| 319 | // |
---|
| 320 | // ----------------------------------------------------------------------- |
---|
| 321 | XMLCh* fTargetNamespace; |
---|
| 322 | RefHash3KeysIdPool<SchemaElementDecl>* fElemDeclPool; |
---|
| 323 | RefHash3KeysIdPool<SchemaElementDecl>* fElemNonDeclPool; |
---|
| 324 | RefHash3KeysIdPool<SchemaElementDecl>* fGroupElemDeclPool; |
---|
| 325 | NameIdPool<XMLNotationDecl>* fNotationDeclPool; |
---|
| 326 | RefHashTableOf<XMLAttDef>* fAttributeDeclRegistry; |
---|
| 327 | RefHashTableOf<ComplexTypeInfo>* fComplexTypeRegistry; |
---|
| 328 | RefHashTableOf<XercesGroupInfo>* fGroupInfoRegistry; |
---|
| 329 | RefHashTableOf<XercesAttGroupInfo>* fAttGroupInfoRegistry; |
---|
| 330 | NamespaceScope* fNamespaceScope; |
---|
| 331 | RefHash2KeysTableOf<ElemVector>* fValidSubstitutionGroups; |
---|
| 332 | ValidationContext* fValidationContext; |
---|
| 333 | MemoryManager* fMemoryManager; |
---|
| 334 | XMLSchemaDescription* fGramDesc; |
---|
| 335 | RefHashTableOf<XSAnnotation>* fAnnotations; |
---|
| 336 | |
---|
| 337 | bool fValidated; |
---|
| 338 | DatatypeValidatorFactory fDatatypeRegistry; |
---|
| 339 | }; |
---|
| 340 | |
---|
| 341 | |
---|
| 342 | // --------------------------------------------------------------------------- |
---|
| 343 | // SchemaGrammar: Getter methods |
---|
| 344 | // --------------------------------------------------------------------------- |
---|
| 345 | inline RefHash3KeysIdPoolEnumerator<SchemaElementDecl> |
---|
| 346 | SchemaGrammar::getElemEnumerator() const |
---|
| 347 | { |
---|
| 348 | return RefHash3KeysIdPoolEnumerator<SchemaElementDecl>(fElemDeclPool, false, fMemoryManager); |
---|
| 349 | } |
---|
| 350 | |
---|
| 351 | inline NameIdPoolEnumerator<XMLNotationDecl> |
---|
| 352 | SchemaGrammar::getNotationEnumerator() const |
---|
| 353 | { |
---|
| 354 | return NameIdPoolEnumerator<XMLNotationDecl>(fNotationDeclPool, fMemoryManager); |
---|
| 355 | } |
---|
| 356 | |
---|
| 357 | inline RefHashTableOf<XMLAttDef>* SchemaGrammar::getAttributeDeclRegistry() const { |
---|
| 358 | |
---|
| 359 | return fAttributeDeclRegistry; |
---|
| 360 | } |
---|
| 361 | |
---|
| 362 | inline RefHashTableOf<ComplexTypeInfo>* |
---|
| 363 | SchemaGrammar::getComplexTypeRegistry() const { |
---|
| 364 | |
---|
| 365 | return fComplexTypeRegistry; |
---|
| 366 | } |
---|
| 367 | |
---|
| 368 | inline RefHashTableOf<XercesGroupInfo>* |
---|
| 369 | SchemaGrammar::getGroupInfoRegistry() const { |
---|
| 370 | |
---|
| 371 | return fGroupInfoRegistry; |
---|
| 372 | } |
---|
| 373 | |
---|
| 374 | inline RefHashTableOf<XercesAttGroupInfo>* |
---|
| 375 | SchemaGrammar::getAttGroupInfoRegistry() const { |
---|
| 376 | |
---|
| 377 | return fAttGroupInfoRegistry; |
---|
| 378 | } |
---|
| 379 | |
---|
| 380 | inline DatatypeValidatorFactory* SchemaGrammar::getDatatypeRegistry() { |
---|
| 381 | |
---|
| 382 | return &fDatatypeRegistry; |
---|
| 383 | } |
---|
| 384 | |
---|
| 385 | inline NamespaceScope* SchemaGrammar::getNamespaceScope() const { |
---|
| 386 | |
---|
| 387 | return fNamespaceScope; |
---|
| 388 | } |
---|
| 389 | |
---|
| 390 | inline RefHash2KeysTableOf<ElemVector>* |
---|
| 391 | SchemaGrammar::getValidSubstitutionGroups() const { |
---|
| 392 | |
---|
| 393 | return fValidSubstitutionGroups; |
---|
| 394 | } |
---|
| 395 | |
---|
| 396 | inline RefHashTableOf<XMLRefInfo>* SchemaGrammar::getIDRefList() const { |
---|
| 397 | |
---|
| 398 | return fValidationContext->getIdRefList(); |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | inline ValidationContext* SchemaGrammar::getValidationContext() const { |
---|
| 402 | |
---|
| 403 | return fValidationContext; |
---|
| 404 | } |
---|
| 405 | |
---|
| 406 | inline XMLGrammarDescription* SchemaGrammar::getGrammarDescription() const |
---|
| 407 | { |
---|
| 408 | return fGramDesc; |
---|
| 409 | } |
---|
| 410 | |
---|
| 411 | inline XSAnnotation* SchemaGrammar::getAnnotation(const void* const key) |
---|
| 412 | { |
---|
| 413 | return fAnnotations->get(key); |
---|
| 414 | } |
---|
| 415 | |
---|
| 416 | inline const XSAnnotation* SchemaGrammar::getAnnotation(const void* const key) const |
---|
| 417 | { |
---|
| 418 | return fAnnotations->get(key); |
---|
| 419 | } |
---|
| 420 | |
---|
| 421 | inline XSAnnotation* SchemaGrammar::getAnnotation() |
---|
| 422 | { |
---|
| 423 | return fAnnotations->get(this); |
---|
| 424 | } |
---|
| 425 | |
---|
| 426 | inline const XSAnnotation* SchemaGrammar::getAnnotation() const |
---|
| 427 | { |
---|
| 428 | return fAnnotations->get(this); |
---|
| 429 | } |
---|
| 430 | |
---|
| 431 | inline RefHashTableOf<XSAnnotation>* SchemaGrammar::getAnnotations() |
---|
| 432 | { |
---|
| 433 | return fAnnotations; |
---|
| 434 | } |
---|
| 435 | |
---|
| 436 | inline const RefHashTableOf<XSAnnotation>* SchemaGrammar::getAnnotations() const |
---|
| 437 | { |
---|
| 438 | return fAnnotations; |
---|
| 439 | } |
---|
| 440 | // ----------------------------------------------------------------------- |
---|
| 441 | // Setter methods |
---|
| 442 | // ----------------------------------------------------------------------- |
---|
| 443 | inline void SchemaGrammar::setTargetNamespace(const XMLCh* const targetNamespace) |
---|
| 444 | { |
---|
| 445 | if (fTargetNamespace) |
---|
| 446 | fMemoryManager->deallocate(fTargetNamespace);//delete [] fTargetNamespace; |
---|
| 447 | fTargetNamespace = XMLString::replicate(targetNamespace, fMemoryManager); |
---|
| 448 | } |
---|
| 449 | |
---|
| 450 | inline void |
---|
| 451 | SchemaGrammar::setAttributeDeclRegistry(RefHashTableOf<XMLAttDef>* const attReg) { |
---|
| 452 | |
---|
| 453 | fAttributeDeclRegistry = attReg; |
---|
| 454 | } |
---|
| 455 | |
---|
| 456 | inline void |
---|
| 457 | SchemaGrammar::setComplexTypeRegistry(RefHashTableOf<ComplexTypeInfo>* const other) { |
---|
| 458 | |
---|
| 459 | fComplexTypeRegistry = other; |
---|
| 460 | } |
---|
| 461 | |
---|
| 462 | inline void |
---|
| 463 | SchemaGrammar::setGroupInfoRegistry(RefHashTableOf<XercesGroupInfo>* const other) { |
---|
| 464 | |
---|
| 465 | fGroupInfoRegistry = other; |
---|
| 466 | } |
---|
| 467 | |
---|
| 468 | inline void |
---|
| 469 | SchemaGrammar::setAttGroupInfoRegistry(RefHashTableOf<XercesAttGroupInfo>* const other) { |
---|
| 470 | |
---|
| 471 | fAttGroupInfoRegistry = other; |
---|
| 472 | } |
---|
| 473 | |
---|
| 474 | inline void SchemaGrammar::setNamespaceScope(NamespaceScope* const nsScope) { |
---|
| 475 | |
---|
| 476 | fNamespaceScope = nsScope; |
---|
| 477 | } |
---|
| 478 | |
---|
| 479 | inline void |
---|
| 480 | SchemaGrammar::setValidSubstitutionGroups(RefHash2KeysTableOf<ElemVector>* const other) { |
---|
| 481 | |
---|
| 482 | fValidSubstitutionGroups = other; |
---|
| 483 | } |
---|
| 484 | |
---|
| 485 | |
---|
| 486 | // --------------------------------------------------------------------------- |
---|
| 487 | // SchemaGrammar: Virtual methods |
---|
| 488 | // --------------------------------------------------------------------------- |
---|
| 489 | inline Grammar::GrammarType SchemaGrammar::getGrammarType() const { |
---|
| 490 | return Grammar::SchemaGrammarType; |
---|
| 491 | } |
---|
| 492 | |
---|
| 493 | inline const XMLCh* SchemaGrammar::getTargetNamespace() const { |
---|
| 494 | return fTargetNamespace; |
---|
| 495 | } |
---|
| 496 | |
---|
| 497 | // Element Decl |
---|
| 498 | inline unsigned int SchemaGrammar::getElemId (const unsigned int uriId |
---|
| 499 | , const XMLCh* const baseName |
---|
| 500 | , const XMLCh* const |
---|
| 501 | , unsigned int scope ) const |
---|
| 502 | { |
---|
| 503 | // |
---|
| 504 | // In this case, we don't return zero to mean 'not found', so we have to |
---|
| 505 | // map it to the official not found value if we don't find it. |
---|
| 506 | // |
---|
| 507 | const SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope); |
---|
| 508 | if (!decl) { |
---|
| 509 | |
---|
| 510 | decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope); |
---|
| 511 | |
---|
| 512 | if (!decl) |
---|
| 513 | return XMLElementDecl::fgInvalidElemId; |
---|
| 514 | } |
---|
| 515 | return decl->getId(); |
---|
| 516 | } |
---|
| 517 | |
---|
| 518 | inline const XMLElementDecl* SchemaGrammar::getElemDecl( const unsigned int uriId |
---|
| 519 | , const XMLCh* const baseName |
---|
| 520 | , const XMLCh* const |
---|
| 521 | , unsigned int scope ) const |
---|
| 522 | { |
---|
| 523 | const SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope); |
---|
| 524 | |
---|
| 525 | if (!decl) { |
---|
| 526 | |
---|
| 527 | decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope); |
---|
| 528 | |
---|
| 529 | if (!decl && fElemNonDeclPool) |
---|
| 530 | decl = fElemNonDeclPool->getByKey(baseName, uriId, scope); |
---|
| 531 | } |
---|
| 532 | |
---|
| 533 | return decl; |
---|
| 534 | } |
---|
| 535 | |
---|
| 536 | inline XMLElementDecl* SchemaGrammar::getElemDecl (const unsigned int uriId |
---|
| 537 | , const XMLCh* const baseName |
---|
| 538 | , const XMLCh* const |
---|
| 539 | , unsigned int scope ) |
---|
| 540 | { |
---|
| 541 | SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope); |
---|
| 542 | |
---|
| 543 | if (!decl) { |
---|
| 544 | |
---|
| 545 | decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope); |
---|
| 546 | |
---|
| 547 | if (!decl && fElemNonDeclPool) |
---|
| 548 | decl = fElemNonDeclPool->getByKey(baseName, uriId, scope); |
---|
| 549 | } |
---|
| 550 | |
---|
| 551 | return decl; |
---|
| 552 | } |
---|
| 553 | |
---|
| 554 | inline const XMLElementDecl* SchemaGrammar::getElemDecl(const unsigned int elemId) const |
---|
| 555 | { |
---|
| 556 | // Look up this element decl by id |
---|
| 557 | const SchemaElementDecl* decl = fElemDeclPool->getById(elemId); |
---|
| 558 | |
---|
| 559 | if (!decl) |
---|
| 560 | decl = fGroupElemDeclPool->getById(elemId); |
---|
| 561 | |
---|
| 562 | return decl; |
---|
| 563 | } |
---|
| 564 | |
---|
| 565 | inline XMLElementDecl* SchemaGrammar::getElemDecl(const unsigned int elemId) |
---|
| 566 | { |
---|
| 567 | // Look up this element decl by id |
---|
| 568 | SchemaElementDecl* decl = fElemDeclPool->getById(elemId); |
---|
| 569 | |
---|
| 570 | if (!decl) |
---|
| 571 | decl = fGroupElemDeclPool->getById(elemId); |
---|
| 572 | |
---|
| 573 | return decl; |
---|
| 574 | } |
---|
| 575 | |
---|
| 576 | inline unsigned int |
---|
| 577 | SchemaGrammar::putElemDecl(XMLElementDecl* const elemDecl, |
---|
| 578 | const bool notDeclared) |
---|
| 579 | { |
---|
| 580 | if (notDeclared) |
---|
| 581 | { |
---|
| 582 | if(!fElemNonDeclPool) |
---|
| 583 | fElemNonDeclPool = new (fMemoryManager) RefHash3KeysIdPool<SchemaElementDecl>(29, true, 128, fMemoryManager); |
---|
| 584 | return fElemNonDeclPool->put(elemDecl->getBaseName(), elemDecl->getURI(), ((SchemaElementDecl* )elemDecl)->getEnclosingScope(), (SchemaElementDecl*) elemDecl); |
---|
| 585 | } |
---|
| 586 | |
---|
| 587 | return fElemDeclPool->put(elemDecl->getBaseName(), elemDecl->getURI(), ((SchemaElementDecl* )elemDecl)->getEnclosingScope(), (SchemaElementDecl*) elemDecl); |
---|
| 588 | } |
---|
| 589 | |
---|
| 590 | inline unsigned int SchemaGrammar::putGroupElemDecl (XMLElementDecl* const elemDecl) const |
---|
| 591 | { |
---|
| 592 | return fGroupElemDeclPool->put(elemDecl->getBaseName(), elemDecl->getURI(), ((SchemaElementDecl* )elemDecl)->getEnclosingScope(), (SchemaElementDecl*) elemDecl); |
---|
| 593 | } |
---|
| 594 | |
---|
| 595 | // Notation Decl |
---|
| 596 | inline const XMLNotationDecl* SchemaGrammar::getNotationDecl(const XMLCh* const notName) const |
---|
| 597 | { |
---|
| 598 | return fNotationDeclPool->getByKey(notName); |
---|
| 599 | } |
---|
| 600 | |
---|
| 601 | inline XMLNotationDecl* SchemaGrammar::getNotationDecl(const XMLCh* const notName) |
---|
| 602 | { |
---|
| 603 | return fNotationDeclPool->getByKey(notName); |
---|
| 604 | } |
---|
| 605 | |
---|
| 606 | inline unsigned int SchemaGrammar::putNotationDecl(XMLNotationDecl* const notationDecl) const |
---|
| 607 | { |
---|
| 608 | return fNotationDeclPool->put(notationDecl); |
---|
| 609 | } |
---|
| 610 | |
---|
| 611 | inline bool SchemaGrammar::getValidated() const |
---|
| 612 | { |
---|
| 613 | return fValidated; |
---|
| 614 | } |
---|
| 615 | |
---|
| 616 | inline void SchemaGrammar::setValidated(const bool newState) |
---|
| 617 | { |
---|
| 618 | fValidated = newState; |
---|
| 619 | } |
---|
| 620 | |
---|
| 621 | XERCES_CPP_NAMESPACE_END |
---|
| 622 | |
---|
| 623 | #endif |
---|