complextypeinfo.cpp
来自「IBM的解析xml的工具Xerces的源代码」· C++ 代码 · 共 1,129 行 · 第 1/3 页
CPP
1,129 行
/* * Copyright 2001,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *//* * $Log: ComplexTypeInfo.cpp,v $ * Revision 1.30 2004/09/23 00:37:24 cargilld * Remove unused variable and data member. * * Revision 1.29 2004/09/16 13:32:04 amassari * Updated error message for UPA to also state the complex type that is failing the test * * Revision 1.28 2004/09/08 13:56:56 peiyongz * Apache License Version 2.0 * * Revision 1.27 2004/07/22 15:00:54 knoaman * Eliminate the need to create a temporary content model when performing UPA checking * * Revision 1.26 2004/01/29 11:52:31 cargilld * Code cleanup changes to get rid of various compiler diagnostic messages. * * Revision 1.25 2004/01/13 16:17:09 knoaman * Fo sanity, use class name to qualify method * * Revision 1.24 2004/01/09 22:41:58 knoaman * Use a global static mutex for locking when creating local static mutexes instead of compareAndSwap * * Revision 1.23 2003/12/24 17:42:03 knoaman * Misc. PSVI updates * * Revision 1.22 2003/12/17 00:18:40 cargilld * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. * * Revision 1.21 2003/12/16 17:18:50 peiyongz * don't expand ContextSpecNode when deserilized * * Revision 1.20 2003/11/20 18:05:16 knoaman * PSVI: Use a copy of the content spec node when creating the content model. * * Revision 1.19 2003/11/13 23:20:47 peiyongz * initSize * * Revision 1.18 2003/11/10 21:54:51 neilg * implementation for new stateless means of traversing attribute definition lists * * Revision 1.17 2003/11/07 17:08:12 knoaman * For PSVI support, distinguish wildcard elements with namespace lists. * * Revision 1.16 2003/10/29 16:22:58 peiyongz * allow proper recreation of ContentModel from deserialization * * Revision 1.15 2003/10/21 10:23:53 amassari * When creating a new list of attributes, use the assigned memory manager * * Revision 1.14 2003/10/17 21:17:12 peiyongz * using XTemplateSerializer * * Revision 1.13 2003/10/14 15:22:28 peiyongz * Implementation of Serialization/Deserialization * * Revision 1.12 2003/10/10 16:25:40 peiyongz * Implementation of Serialization/Deserialization * * Revision 1.11 2003/10/08 21:33:48 peiyongz * Synchronize ContentSpec/ContentModel/FormattedModel * * Revision 1.10 2003/09/26 18:31:05 peiyongz * Synchronize ContentSpecNode and formattedModel * * Revision 1.9 2003/05/18 14:02:07 knoaman * Memory manager implementation: pass per instance manager. * * Revision 1.8 2003/05/16 21:43:21 knoaman * Memory manager implementation: Modify constructors to pass in the memory manager. * * Revision 1.7 2003/05/15 18:57:27 knoaman * Partial implementation of the configurable memory manager. * * Revision 1.6 2003/01/29 19:57:30 gareth * API to retrive local and uri part of the type name * * Revision 1.5 2002/12/19 14:04:05 gareth * get/set methods to see if the represented type is anonymous. Patch by Peter Volchek. * * Revision 1.4 2002/11/04 14:49:41 tng * C++ Namespace Support. * * Revision 1.3 2002/03/21 15:34:40 knoaman * Add support for reporting line/column numbers of schema errors. * * Revision 1.2 2002/02/06 22:29:24 knoaman * Remove unnecessary data/methods. * * Revision 1.1.1.1 2002/02/01 22:22:45 peiyongz * sane_include * * Revision 1.27 2002/01/15 19:09:16 knoaman * Fix for bug 5807. * * Revision 1.26 2002/01/02 15:20:22 tng * Schema Fix: should not store a temp value as the key in the element pool and the attribute pool. * * Revision 1.25 2001/12/17 21:38:59 tng * Fix dangling pointer. * * Revision 1.24 2001/11/21 14:30:13 knoaman * Fix for UPA checking. * * Revision 1.23 2001/11/15 17:10:19 knoaman * Particle derivation checking support. * * Revision 1.22 2001/11/07 21:50:28 tng * Fix comment log that lead to error. * * Revision 1.21 2001/11/07 21:12:15 tng * Performance: Create QName in ContentSpecNode only if it is a leaf/Any/PCDataNode. * * Revision 1.20 2001/10/12 18:08:57 tng * make sure the second node exists before calling getType * * Revision 1.19 2001/10/04 15:08:56 knoaman * Add support for circular import. * * Revision 1.18 2001/09/05 20:49:11 knoaman * Fix for complexTypes with mixed content model. * * Revision 1.17 2001/08/29 21:27:07 knoaman * no message * * Revision 1.16 2001/08/28 20:43:52 knoaman * Fix for content spec node adoption. * * Revision 1.15 2001/08/27 23:04:02 knoaman * Handle deletion of spec node tree created during UPA checking. * * Revision 1.14 2001/08/27 20:48:45 knoaman * Make the UPA rename before the content model expansion. * * Revision 1.13 2001/08/27 20:14:42 knoaman * Validate attributes in <all>, <redefine>, <group> and <attributeGroup> declarations. * Misc. fixes. * * Revision 1.12 2001/08/24 12:48:48 tng * Schema: AllContentModel * * Revision 1.11 2001/08/23 11:54:26 tng * Add newline at the end and various typo fixes. * * Revision 1.10 2001/08/21 18:14:55 knoaman * Defer creation of spec node. * * Revision 1.9 2001/08/21 16:06:11 tng * Schema: Unique Particle Attribution Constraint Checking. * * Revision 1.8 2001/08/09 15:23:16 knoaman * add support for <anyAttribute> declaration. * * Revision 1.7 2001/07/24 18:33:46 knoaman * Added support for <group> + extra constraint checking for complexType * * Revision 1.6 2001/06/05 13:59:53 knoaman * Fixes to include and import. * * Revision 1.5 2001/05/11 13:27:32 tng * Copyright update. * * Revision 1.4 2001/05/10 17:49:40 tng * Schema: SchemaValidator fixes * * Revision 1.3 2001/05/10 16:33:12 knoaman * Traverse Schema Part III + error messages. * * Revision 1.2 2001/05/03 20:34:41 tng * Schema: SchemaValidator update * * Revision 1.1 2001/04/19 17:43:14 knoaman * More schema implementation classes. * */// ---------------------------------------------------------------------------// Includes// ---------------------------------------------------------------------------#include <xercesc/framework/XMLBuffer.hpp>#include <xercesc/validators/schema/ComplexTypeInfo.hpp>#include <xercesc/validators/schema/SchemaAttDefList.hpp>#include <xercesc/validators/common/AllContentModel.hpp>#include <xercesc/validators/common/ContentSpecNode.hpp>#include <xercesc/validators/common/DFAContentModel.hpp>#include <xercesc/validators/common/MixedContentModel.hpp>#include <xercesc/validators/common/SimpleContentModel.hpp>#include <xercesc/validators/schema/XSDLocator.hpp>#include <xercesc/internal/XTemplateSerializer.hpp>#include <xercesc/util/XMLRegisterCleanup.hpp>XERCES_CPP_NAMESPACE_BEGIN// ---------------------------------------------------------------------------// Local static data// ---------------------------------------------------------------------------static bool sAnyTypeMutexRegistered = false;static XMLMutex* sAnyTypeMutex = 0;static XMLRegisterCleanup anyTypeCleanup;// ---------------------------------------------------------------------------// ComplexTypeInfo: Static member data// ---------------------------------------------------------------------------ComplexTypeInfo* ComplexTypeInfo::fAnyType = 0;// ---------------------------------------------------------------------------// ComplexTypeInfo: Static meber methods// ---------------------------------------------------------------------------void ComplexTypeInfo::reinitAnyType() { delete fAnyType; fAnyType = 0; // delete local static data delete sAnyTypeMutex; sAnyTypeMutex = 0; sAnyTypeMutexRegistered = false;}ComplexTypeInfo* ComplexTypeInfo::getAnyType(unsigned int emptyNSId){ if (!sAnyTypeMutexRegistered) { if (!sAnyTypeMutex) { XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex); if (!sAnyTypeMutex) sAnyTypeMutex = new XMLMutex; } // Use a faux scope to synchronize while we do this { XMLMutexLock lock(sAnyTypeMutex); // If we got here first, then register it and set the registered flag if (!sAnyTypeMutexRegistered) { // create type name XMLCh typeName[128]; unsigned int nsLen = XMLString::stringLen( SchemaSymbols::fgURI_SCHEMAFORSCHEMA); XMLString::copyString( typeName, SchemaSymbols::fgURI_SCHEMAFORSCHEMA); typeName[nsLen] = chComma; XMLString::copyString( typeName + nsLen + 1, SchemaSymbols::fgATTVAL_ANYTYPE); // Create and initialize 'anyType' fAnyType = new ComplexTypeInfo(); ContentSpecNode* term = new ContentSpecNode ( new QName ( XMLUni::fgZeroLenString , XMLUni::fgZeroLenString , emptyNSId ) , false ); term->setType(ContentSpecNode::Any_Lax); term->setMinOccurs(0); term->setMaxOccurs(SchemaSymbols::XSD_UNBOUNDED); ContentSpecNode* particle = new ContentSpecNode ( ContentSpecNode::ModelGroupSequence , term , 0 ); SchemaAttDef* attWildCard = new SchemaAttDef ( XMLUni::fgZeroLenString , XMLUni::fgZeroLenString , emptyNSId , XMLAttDef::Any_Any , XMLAttDef::ProcessContents_Lax ); fAnyType->setTypeName(typeName); fAnyType->setBaseComplexTypeInfo(fAnyType); fAnyType->setDerivedBy(SchemaSymbols::XSD_RESTRICTION); fAnyType->setContentType(SchemaElementDecl::Mixed_Complex); fAnyType->setContentSpec(particle); fAnyType->setAttWildCard(attWildCard); // register cleanup method anyTypeCleanup.registerCleanup(ComplexTypeInfo::reinitAnyType); sAnyTypeMutexRegistered = true; } } } return fAnyType;}// ---------------------------------------------------------------------------// ComplexTypeInfo: Constructors and Destructor// ---------------------------------------------------------------------------ComplexTypeInfo::ComplexTypeInfo(MemoryManager* const manager) : fAnonymous(false) , fAbstract(false) , fAdoptContentSpec(true) , fAttWithTypeId(false) , fPreprocessed(false) , fDerivedBy(0) , fBlockSet(0) , fFinalSet(0) , fScopeDefined(Grammar::TOP_LEVEL_SCOPE) , fElementId(XMLElementDecl::fgInvalidElemId) , fContentType(SchemaElementDecl::Empty) , fTypeName(0) , fTypeLocalName(0) , fTypeUri(0) , fBaseDatatypeValidator(0) , fDatatypeValidator(0) , fBaseComplexTypeInfo(0) , fContentSpec(0) , fAttWildCard(0) , fAttList(0) , fElements(0) , fAttDefs(0) , fContentModel(0) , fFormattedModel(0) , fContentSpecOrgURI(0) , fUniqueURI(0) , fContentSpecOrgURISize(16) , fLocator(0) , fMemoryManager(manager){}ComplexTypeInfo::~ComplexTypeInfo(){ fMemoryManager->deallocate(fTypeName); //delete [] fTypeName; fMemoryManager->deallocate(fTypeLocalName); //delete [] fTypeLocalName; fMemoryManager->deallocate(fTypeUri); //delete [] fTypeUri; if (fAdoptContentSpec) { delete fContentSpec; } delete fAttWildCard; delete fAttDefs; delete fAttList; delete fElements; delete fLocator; delete fContentModel; fMemoryManager->deallocate(fFormattedModel); //delete [] fFormattedModel; fMemoryManager->deallocate(fContentSpecOrgURI); //delete [] fContentSpecOrgURI;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?