|
||||
File indexing completed on 2025-01-18 10:15:18
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_DTDELEMENTDECL_HPP) 0023 #define XERCESC_INCLUDE_GUARD_DTDELEMENTDECL_HPP 0024 0025 #include <xercesc/util/RefHashTableOf.hpp> 0026 #include <xercesc/util/QName.hpp> 0027 #include <xercesc/framework/XMLElementDecl.hpp> 0028 #include <xercesc/framework/XMLContentModel.hpp> 0029 #include <xercesc/validators/DTD/DTDAttDef.hpp> 0030 0031 XERCES_CPP_NAMESPACE_BEGIN 0032 0033 class ContentSpecNode; 0034 class DTDAttDefList; 0035 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 DTD. The big difference is that 0040 // they don't live in any URL in the DTD. The names are just stored as full 0041 // QNames, so they are not split out and element decls don't live within 0042 // URL namespaces or anything like that. 0043 // 0044 0045 class VALIDATORS_EXPORT DTDElementDecl : public XMLElementDecl 0046 { 0047 public : 0048 // ----------------------------------------------------------------------- 0049 // Class specific types 0050 // 0051 // ModelTypes 0052 // Indicates the type of content model that an element has. This 0053 // indicates how the content model is represented and validated. 0054 // ----------------------------------------------------------------------- 0055 enum ModelTypes 0056 { 0057 Empty 0058 , Any 0059 , Mixed_Simple 0060 , Children 0061 0062 , ModelTypes_Count 0063 }; 0064 0065 0066 // ----------------------------------------------------------------------- 0067 // Constructors and Destructor 0068 // ----------------------------------------------------------------------- 0069 DTDElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0070 DTDElementDecl 0071 ( 0072 const XMLCh* const elemRawName 0073 , const unsigned int uriId 0074 , const ModelTypes modelType 0075 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0076 ); 0077 DTDElementDecl 0078 ( 0079 QName* const elementName 0080 , const ModelTypes modelType = Any 0081 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0082 ); 0083 0084 ~DTDElementDecl(); 0085 0086 0087 // ----------------------------------------------------------------------- 0088 // The virtual element decl interface 0089 // ----------------------------------------------------------------------- 0090 virtual XMLAttDefList& getAttDefList() const; 0091 virtual CharDataOpts getCharDataOpts() const; 0092 virtual bool hasAttDefs() const; 0093 virtual const ContentSpecNode* getContentSpec() const; 0094 virtual ContentSpecNode* getContentSpec(); 0095 virtual void setContentSpec(ContentSpecNode* toAdopt); 0096 virtual XMLContentModel* getContentModel(); 0097 virtual void setContentModel(XMLContentModel* const newModelToAdopt); 0098 virtual const XMLCh* getFormattedContentModel () const; 0099 0100 // ----------------------------------------------------------------------- 0101 // Support keyed collections 0102 // 0103 // This method allows objects of this type be placed into one of the 0104 // standard keyed collections. This method will return the full name of 0105 // the element, which will vary depending upon the type of the grammar. 0106 // ----------------------------------------------------------------------- 0107 const XMLCh* getKey() const; 0108 0109 // ----------------------------------------------------------------------- 0110 // Getter methods 0111 // ----------------------------------------------------------------------- 0112 const DTDAttDef* getAttDef(const XMLCh* const attName) const; 0113 DTDAttDef* getAttDef(const XMLCh* const attName); 0114 ModelTypes getModelType() const; 0115 0116 // ----------------------------------------------------------------------- 0117 // Setter methods 0118 // ----------------------------------------------------------------------- 0119 void addAttDef(DTDAttDef* const toAdd); 0120 void setModelType(const DTDElementDecl::ModelTypes toSet); 0121 0122 /*** 0123 * Support for Serialization/De-serialization 0124 ***/ 0125 DECL_XSERIALIZABLE(DTDElementDecl) 0126 0127 virtual XMLElementDecl::objectType getObjectType() const; 0128 0129 private : 0130 // ----------------------------------------------------------------------- 0131 // Private helper methods 0132 // ----------------------------------------------------------------------- 0133 void faultInAttDefList() const; 0134 XMLContentModel* createChildModel() ; 0135 XMLContentModel* makeContentModel() ; 0136 XMLCh* formatContentModel () const ; 0137 0138 // ----------------------------------------------------------------------- 0139 // Unimplemented constructors and operators 0140 // ----------------------------------------------------------------------- 0141 DTDElementDecl(const DTDElementDecl &); 0142 DTDElementDecl& operator = (const DTDElementDecl&); 0143 0144 // ----------------------------------------------------------------------- 0145 // Private data members 0146 // 0147 // fAttDefs 0148 // The list of attributes that are defined for this element. Each 0149 // element is its own little 'namespace' for attributes, so each 0150 // element maintains its own list of owned attribute defs. It is 0151 // faulted in when an attribute is actually added. 0152 // 0153 // fAttList 0154 // We have to return a view of our att defs via the abstract view 0155 // that the scanner understands. It may or may not ever be asked 0156 // for so we fault it in as needed. 0157 // 0158 // fContentSpec 0159 // This is the content spec for the node. It contains the original 0160 // content spec that was read from the DTD, as a tree of nodes. This 0161 // one is always set up, and is used to build the fContentModel 0162 // version if we are validating. 0163 // 0164 // fModelType 0165 // The content model type of this element. This tells us what kind 0166 // of content model to create. 0167 // 0168 // fContentModel 0169 // The content model object for this element. It is stored here via 0170 // its abstract interface. 0171 // 0172 // fFormattedModel 0173 // This is a faulted in member. When the outside world asks for 0174 // our content model as a string, we format it and fault it into 0175 // this field (to avoid doing the formatted over and over.) 0176 // ----------------------------------------------------------------------- 0177 ModelTypes fModelType; 0178 0179 RefHashTableOf<DTDAttDef>* fAttDefs; 0180 DTDAttDefList* fAttList; 0181 ContentSpecNode* fContentSpec; 0182 XMLContentModel* fContentModel; 0183 XMLCh* fFormattedModel; 0184 }; 0185 0186 // --------------------------------------------------------------------------- 0187 // DTDElementDecl: XMLElementDecl virtual interface implementation 0188 // --------------------------------------------------------------------------- 0189 inline ContentSpecNode* DTDElementDecl::getContentSpec() 0190 { 0191 return fContentSpec; 0192 } 0193 0194 inline const ContentSpecNode* DTDElementDecl::getContentSpec() const 0195 { 0196 return fContentSpec; 0197 } 0198 0199 inline XMLContentModel* DTDElementDecl::getContentModel() 0200 { 0201 if (!fContentModel) 0202 fContentModel = makeContentModel(); 0203 return fContentModel; 0204 } 0205 0206 inline void 0207 DTDElementDecl::setContentModel(XMLContentModel* const newModelToAdopt) 0208 { 0209 delete fContentModel; 0210 fContentModel = newModelToAdopt; 0211 0212 // reset formattedModel 0213 if (fFormattedModel) 0214 { 0215 getMemoryManager()->deallocate(fFormattedModel); 0216 fFormattedModel = 0; 0217 } 0218 } 0219 0220 // --------------------------------------------------------------------------- 0221 // DTDElementDecl: Miscellaneous methods 0222 // --------------------------------------------------------------------------- 0223 inline const XMLCh* DTDElementDecl::getKey() const 0224 { 0225 return getFullName(); 0226 } 0227 0228 // --------------------------------------------------------------------------- 0229 // DTDElementDecl: Getter methods 0230 // --------------------------------------------------------------------------- 0231 inline DTDElementDecl::ModelTypes DTDElementDecl::getModelType() const 0232 { 0233 return fModelType; 0234 } 0235 0236 // --------------------------------------------------------------------------- 0237 // DTDElementDecl: Setter methods 0238 // --------------------------------------------------------------------------- 0239 inline void 0240 DTDElementDecl::setModelType(const DTDElementDecl::ModelTypes toSet) 0241 { 0242 fModelType = toSet; 0243 } 0244 0245 XERCES_CPP_NAMESPACE_END 0246 0247 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |