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: XMLContentModel.hpp 677705 2008-07-17 20:15:32Z amassari $ 20 */ 21 22 #if !defined(XERCESC_INCLUDE_GUARD_XMLCONTENTMODEL_HPP) 23 #define XERCESC_INCLUDE_GUARD_XMLCONTENTMODEL_HPP 24 25 #include <xercesc/util/XMemory.hpp> 26 #include <xercesc/util/QName.hpp> 27 28 XERCES_CPP_NAMESPACE_BEGIN 29 30 class ContentLeafNameTypeVector; 31 class GrammarResolver; 32 class XMLStringPool; 33 class XMLValidator; 34 class SchemaGrammar; 35 class SubstitutionGroupComparator; 36 37 /** 38 * This class defines the abstract interface for all content models. All 39 * elements have a content model against which (if validating) its content 40 * is checked. Each type of validator (DTD, Schema, etc...) can have 41 * different types of content models, and even with each type of validator 42 * there can be specialized content models. So this simple class provides 43 * the abstract API via which all the types of contents models are dealt 44 * with generically. Its pretty simple. 45 */ 46 class XMLPARSER_EXPORT XMLContentModel : public XMemory 47 { 48 public: 49 // --------------------------------------------------------------------------- 50 // Public static data 51 // 52 // gInvalidTrans 53 // This value represents an invalid transition in each line of the 54 // transition table. 55 // 56 // gEOCFakeId 57 // gEpsilonFakeId 58 // We have to put in a couple of special CMLeaf nodes to represent 59 // special values, using fake element ids that we know won't conflict 60 // with real element ids. 61 // 62 // 63 // --------------------------------------------------------------------------- 64 static const unsigned int gInvalidTrans; 65 static const unsigned int gEOCFakeId; 66 static const unsigned int gEpsilonFakeId; 67 68 // ----------------------------------------------------------------------- 69 // Constructors are hidden, only the virtual Destructor is exposed 70 // ----------------------------------------------------------------------- 71 /** @name Destructor */ 72 //@{ ~XMLContentModel()73 virtual ~XMLContentModel() 74 { 75 } 76 //@} 77 78 79 // ----------------------------------------------------------------------- 80 // The virtual content model interface provided by derived classes 81 // ----------------------------------------------------------------------- 82 virtual bool validateContent 83 ( 84 QName** const children 85 , XMLSize_t childCount 86 , unsigned int emptyNamespaceId 87 , XMLSize_t* indexFailingChild 88 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 89 ) const = 0; 90 91 virtual bool validateContentSpecial 92 ( 93 QName** const children 94 , XMLSize_t childCount 95 , unsigned int emptyNamespaceId 96 , GrammarResolver* const pGrammarResolver 97 , XMLStringPool* const pStringPool 98 , XMLSize_t* indexFailingChild 99 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 100 ) const =0; 101 102 virtual void checkUniqueParticleAttribution 103 ( 104 SchemaGrammar* const pGrammar 105 , GrammarResolver* const pGrammarResolver 106 , XMLStringPool* const pStringPool 107 , XMLValidator* const pValidator 108 , unsigned int* const pContentSpecOrgURI 109 , const XMLCh* pComplexTypeName = 0 110 ) =0; 111 112 virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() 113 const = 0; 114 115 virtual unsigned int getNextState(unsigned int currentState, 116 XMLSize_t elementIndex) const = 0; 117 118 virtual bool handleRepetitions( const QName* const curElem, 119 unsigned int curState, 120 unsigned int currentLoop, 121 unsigned int& nextState, 122 unsigned int& nextLoop, 123 XMLSize_t elementIndex, 124 SubstitutionGroupComparator * comparator) const = 0; 125 126 protected : 127 // ----------------------------------------------------------------------- 128 // Hidden Constructors 129 // ----------------------------------------------------------------------- XMLContentModel()130 XMLContentModel() 131 { 132 } 133 134 135 private : 136 // ----------------------------------------------------------------------- 137 // Unimplemented constructors and operators 138 // ----------------------------------------------------------------------- 139 XMLContentModel(const XMLContentModel&); 140 XMLContentModel& operator=(const XMLContentModel&); 141 }; 142 143 XERCES_CPP_NAMESPACE_END 144 145 #endif 146