neilg 2003/11/21 14:38:50 Modified: c/src/xercesc/internal XMLGrammarPoolImpl.cpp XMLGrammarPoolImpl.hpp c/src/xercesc/validators/common GrammarResolver.cpp GrammarResolver.hpp c/src/xercesc/dom/deprecated DOMParser.cpp c/src/xercesc/parsers AbstractDOMParser.cpp SAX2XMLReaderImpl.cpp SAXParser.cpp c/src/xercesc/util XercesVersion.hpp Log: Enable grammar pools and grammar resolvers to manufacture XSModels. This also cleans up handling in the parser classes by eliminating the need to tell the grammar pool that schema compoments need to be produced. Thanks to David Cargill. Revision Changes Path 1.14 +121 -81 xml-xerces/c/src/xercesc/internal/XMLGrammarPoolImpl.cpp Index: XMLGrammarPoolImpl.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLGrammarPoolImpl.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- XMLGrammarPoolImpl.cpp 14 Nov 2003 22:34:20 -0000 1.13 +++ XMLGrammarPoolImpl.cpp 21 Nov 2003 22:38:50 -0000 1.14 @@ -56,6 +56,13 @@ /* * $Log$ + * Revision 1.14 2003/11/21 22:38:50 neilg + * Enable grammar pools and grammar resolvers to manufacture + * XSModels. This also cleans up handling in the + * parser classes by eliminating the need to tell + * the grammar pool that schema compoments need to be produced. + * Thanks to David Cargill. + * * Revision 1.13 2003/11/14 22:34:20 neilg * removed methods made unnecessary by new XSModel implementation design; thanks to David Cargill * @@ -117,6 +124,33 @@ XERCES_CPP_NAMESPACE_BEGIN +// private function used to update fXSModel +void XMLGrammarPoolImpl::createXSModel() +{ + RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarRegistry); + if (fXSModel) + { + // Need to guarantee that we return a different address... + if (grammarEnum.hasMoreElements()) + { + XSModel* xsModel = new (getMemoryManager()) XSModel(this, getMemoryManager()); + delete fXSModel; + fXSModel = xsModel; + } + else + { + // its empty... + delete fXSModel; + fXSModel = 0; + } + } + else if (grammarEnum.hasMoreElements()) + { + fXSModel = new (getMemoryManager()) XSModel(this, getMemoryManager()); + } + fXSModelIsValid = true; +} + // --------------------------------------------------------------------------- // XMLGrammarPoolImpl: constructor and destructor // --------------------------------------------------------------------------- @@ -126,6 +160,8 @@ delete fStringPool; if(fSynchronizedStringPool) delete fSynchronizedStringPool; + if(fXSModel) + delete fXSModel; } XMLGrammarPoolImpl::XMLGrammarPoolImpl(MemoryManager* const memMgr) @@ -133,9 +169,9 @@ ,fGrammarRegistry(0) ,fStringPool(0) ,fSynchronizedStringPool(0) -,fPSVIvectorElemDecls(0) ,fLocked(false) -,fDoPSVI(false) +,fXSModelIsValid(false) +,fXSModel(0) { fGrammarRegistry = new (memMgr) RefHashTableOf<Grammar>(29, true, memMgr); fStringPool = new (memMgr) XMLStringPool(109, memMgr); @@ -146,9 +182,7 @@ // ----------------------------------------------------------------------- bool XMLGrammarPoolImpl::cacheGrammar(Grammar* const gramToCache ) { - if(fLocked) - return false; - if (!gramToCache ) + if(fLocked || !gramToCache) return false; const XMLCh* grammarKey = gramToCache->getGrammarDescription()->getGrammarKey(); @@ -160,6 +194,8 @@ fGrammarRegistry->put((void*) grammarKey, gramToCache); + fXSModelIsValid = false; + return true; } @@ -172,12 +208,16 @@ * This implementation simply use GrammarKey */ return fGrammarRegistry->get(gramDesc->getGrammarKey()); - } Grammar* XMLGrammarPoolImpl::orphanGrammar(const XMLCh* const nameSpaceKey) { - return fGrammarRegistry->orphanKey(nameSpaceKey); + if (!fLocked) + { + fXSModelIsValid = false; + return fGrammarRegistry->orphanKey(nameSpaceKey); + } + return 0; } RefHashTableOfEnumerator<Grammar> @@ -187,46 +227,62 @@ } -void XMLGrammarPoolImpl::clear() +bool XMLGrammarPoolImpl::clear() { - fGrammarRegistry->removeAll(); + if (!fLocked) + { + fGrammarRegistry->removeAll(); + + fXSModelIsValid = false; + if (fXSModel) + { + delete fXSModel; + fXSModel = 0; + } + return true; + } + return false; } void XMLGrammarPoolImpl::lockPool() { - fLocked = true; - MemoryManager *memMgr = getMemoryManager(); - if(!fSynchronizedStringPool) + if (!fLocked) { - fSynchronizedStringPool = new (memMgr) XMLSynchronizedStringPool(fStringPool, 109, memMgr); - } - if (fDoPSVI) - { - fXSModel = new XSModel(this, memMgr); + fLocked = true; + MemoryManager *memMgr = getMemoryManager(); + if(!fSynchronizedStringPool) + { + fSynchronizedStringPool = new (memMgr) XMLSynchronizedStringPool(fStringPool, 109, memMgr); + } + if (!fXSModelIsValid) + { + createXSModel(); + } } } void XMLGrammarPoolImpl::unlockPool() { - fLocked = false; - if(fSynchronizedStringPool) - fSynchronizedStringPool->flushAll(); - if (fDoPSVI) + if (fLocked) { - delete fXSModel; - fXSModel = 0; + fLocked = false; + if(fSynchronizedStringPool) + { + fSynchronizedStringPool->flushAll(); + // if user calls Lock again, need to have null fSynchronizedStringPool + delete fSynchronizedStringPool; + fSynchronizedStringPool = 0; + } + fXSModelIsValid = false; + if (fXSModel) + { + delete fXSModel; + fXSModel = 0; + } } } // ----------------------------------------------------------------------- -// Implementation of PSVI -// ----------------------------------------------------------------------- -void XMLGrammarPoolImpl::setPSVI(const bool doPSVI) -{ - fDoPSVI = doPSVI; -} - -// ----------------------------------------------------------------------- // Implementation of Factory Interface // ----------------------------------------------------------------------- DTDGrammar* XMLGrammarPoolImpl::createDTDGrammar() @@ -251,8 +307,14 @@ XSModel *XMLGrammarPoolImpl::getXSModel() { - // REVISIT: implement along with XSModel implementation - return 0; + if (fLocked) + return fXSModel; + + if (fXSModelIsValid) + return fXSModel; + + createXSModel(); + return fXSModel; } XMLStringPool *XMLGrammarPoolImpl::getURIStringPool() @@ -270,68 +332,45 @@ * don't serialize * * XMLSynchronizedStringPool* fSynchronizedStringPool; - * bool fLocked; */ /*** - * .not locked * .non-empty gramamrRegistry ***/ void XMLGrammarPoolImpl::serializeGrammars(BinOutputStream* const binOut) { - if (fLocked) - { - ThrowXML(XSerializationException, XMLExcepts::XSer_GrammarPool_Locked); - } - - fLocked = true; RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarRegistry); if (!(grammarEnum.hasMoreElements())) - { - fLocked = false; + { ThrowXML(XSerializationException, XMLExcepts::XSer_GrammarPool_Empty); } + + XSerializeEngine serEng(binOut, getMemoryManager()); - try - { - XSerializeEngine serEng(binOut, getMemoryManager()); + //version information + serEng<<gXercesMajVersion; + serEng<<gXercesMinVersion; + serEng<<gXercesRevision; + serEng<<(unsigned int)XERCES_GRAMMAR_SERIALIZATION_LEVEL; - //version information - serEng<<gXercesMajVersion; - serEng<<gXercesMinVersion; - serEng<<gXercesRevision; + //lock status + serEng<<fLocked; - //StringPool, don't use << - fStringPool->serialize(serEng); + //StringPool, don't use << + fStringPool->serialize(serEng); - /*** - * Serialize RefHashTableOf<Grammar>* fGrammarRegistry; - ***/ - XTemplateSerializer::storeObject(fGrammarRegistry, serEng); - - } - catch(...) - { - fLocked = false; - throw; - } - - fLocked = false; + /*** + * Serialize RefHashTableOf<Grammar>* fGrammarRegistry; + ***/ + XTemplateSerializer::storeObject(fGrammarRegistry, serEng); } /*** - * .not locked * .empty stringPool * .empty gramamrRegistry ***/ void XMLGrammarPoolImpl::deserializeGrammars(BinInputStream* const binIn) { - if (fLocked) - { - ThrowXML(XSerializationException, XMLExcepts::XSer_GrammarPool_Locked); - } - - fLocked = true; unsigned int stringCount = fStringPool->getStringCount(); if (stringCount) { @@ -346,7 +385,6 @@ } else { - fLocked = false; ThrowXML(XSerializationException, XMLExcepts::XSer_StringPool_NotEmpty); } } @@ -354,30 +392,32 @@ RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarRegistry); if (grammarEnum.hasMoreElements()) { - fLocked = false; ThrowXML(XSerializationException, XMLExcepts::XSer_GrammarPool_NotEmpty); } + MemoryManager *memMgr = getMemoryManager(); try { - XSerializeEngine serEng(binIn, getMemoryManager()); + XSerializeEngine serEng(binIn, memMgr); //version information unsigned int MajVer; unsigned int MinVer; unsigned int Revision; + unsigned int SerializationLevel; serEng>>MajVer; serEng>>MinVer; serEng>>Revision; + serEng>>SerializationLevel; //we may change the logic once we have more //versions if ((MajVer != gXercesMajVersion) || (MinVer != gXercesMinVersion) || - (Revision != gXercesRevision) ) + (Revision != gXercesRevision) || + (SerializationLevel != (unsigned int) XERCES_GRAMMAR_SERIALIZATION_LEVEL)) { - fLocked = false; XMLCh MajVerChar[4]; XMLCh MinVerChar[4]; XMLCh RevisionChar[4]; @@ -391,6 +431,8 @@ , MinVerChar , RevisionChar); } + //lock status + serEng>>fLocked; //StringPool, don't use >> fStringPool->serialize(serEng); @@ -403,12 +445,14 @@ } catch(...) { + fLocked = false; // need to unset it so we can clean it out.. clear(); //clear all deserialized grammars - fLocked = false; throw; } - - fLocked = false; + if (fLocked) + { + createXSModel(); + } } 1.13 +20 -20 xml-xerces/c/src/xercesc/internal/XMLGrammarPoolImpl.hpp Index: XMLGrammarPoolImpl.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLGrammarPoolImpl.hpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- XMLGrammarPoolImpl.hpp 14 Nov 2003 22:34:20 -0000 1.12 +++ XMLGrammarPoolImpl.hpp 21 Nov 2003 22:38:50 -0000 1.13 @@ -56,6 +56,13 @@ /* * $Log$ + * Revision 1.13 2003/11/21 22:38:50 neilg + * Enable grammar pools and grammar resolvers to manufacture + * XSModels. This also cleans up handling in the + * parser classes by eliminating the need to tell + * the grammar pool that schema compoments need to be produced. + * Thanks to David Cargill. + * * Revision 1.12 2003/11/14 22:34:20 neilg * removed methods made unnecessary by new XSModel implementation design; thanks to David Cargill * @@ -156,7 +163,7 @@ * * grammar removed from the grammar pool and owned by the caller * - * @param nameSpaceKey: Key sed to search for grammar in the grammar pool + * @param nameSpaceKey: Key used to search for grammar in the grammar pool * */ virtual Grammar* orphanGrammar(const XMLCh* const nameSpaceKey); @@ -173,16 +180,15 @@ * clear * * all grammars are removed from the grammar pool and deleted. - * + * @return true if the grammar pool was cleared. false if it did not. */ - virtual void clear(); + virtual bool clear(); /** * lockPool * * When this method is called by the application, the * grammar pool should stop adding new grammars to the cache. - * */ virtual void lockPool(); @@ -192,17 +198,10 @@ * After this method has been called, the grammar pool implementation * should return to its default behaviour when cacheGrammars(...) is called. * + * For PSVI support any previous XSModel that was produced will be deleted. */ virtual void unlockPool(); - /** - * setPSVI - * - * A flag to indicate that PSVI will be performed on the schema grammars as - * a PSVIHandler has been set. - */ - virtual void setPSVI(const bool doPSVI); - //@} // ----------------------------------------------------------------------- @@ -245,8 +244,13 @@ * be a thread-safe operation. It should return null if and only if * the pool is empty. * - * In this implementation, a new XSModel will be - * computed each this time the pool is called if the pool is not locked (and the + * Calling getXSModel() on an unlocked grammar pool may result in the + * creation of a new XSModel with the old XSModel being deleted. The + * function will return a different address for the XSModel if it has + * changed. + * + * In this implementation, when the pool is not locked a new XSModel will be + * computed each this time the pool is called if the pool has changed (and the * previous one will be destroyed at that time). When the lockPool() * method is called, an XSModel will be generated and returned whenever this method is called * while the pool is in the locked state. This will be destroyed if the unlockPool() @@ -290,7 +294,8 @@ * * Versioning * - * Only binary data serialized with the current XercesC Version is supported. + * Only binary data serialized with the current XercesC Version and + * SerializationLevel is supported. * * Clean up * @@ -320,6 +325,8 @@ friend class XTemplateComparator; private: + + virtual void createXSModel(); // ----------------------------------------------------------------------- /** name Unimplemented copy constructor and operator= */ // ----------------------------------------------------------------------- @@ -340,17 +347,14 @@ // that can be updated in a thread-safe manner. // fLocked // whether the pool has been locked - // fDoPSVI - // whether PSVI will be performed // // ----------------------------------------------------------------------- RefHashTableOf<Grammar>* fGrammarRegistry; XMLStringPool* fStringPool; XMLSynchronizedStringPool* fSynchronizedStringPool; - ValueVectorOf<SchemaElementDecl*>* fPSVIvectorElemDecls; XSModel* fXSModel; bool fLocked; - bool fDoPSVI; + bool fXSModelIsValid; }; XERCES_CPP_NAMESPACE_END 1.21 +150 -23 xml-xerces/c/src/xercesc/validators/common/GrammarResolver.cpp Index: GrammarResolver.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/GrammarResolver.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- GrammarResolver.cpp 6 Nov 2003 21:53:52 -0000 1.20 +++ GrammarResolver.cpp 21 Nov 2003 22:38:50 -0000 1.21 @@ -57,6 +57,13 @@ /* * $Log$ + * Revision 1.21 2003/11/21 22:38:50 neilg + * Enable grammar pools and grammar resolvers to manufacture + * XSModels. This also cleans up handling in the + * parser classes by eliminating the need to tell + * the grammar pool that schema compoments need to be produced. + * Thanks to David Cargill. + * * Revision 1.20 2003/11/06 21:53:52 neilg * update grammar pool interface so that cacheGrammar(Grammar) can tell the caller whether the grammar was accepted. Also fix some documentation errors. * @@ -140,7 +147,6 @@ #include <xercesc/validators/schema/SchemaGrammar.hpp> #include <xercesc/validators/schema/XMLSchemaDescriptionImpl.hpp> #include <xercesc/validators/DTD/XMLDTDDescriptionImpl.hpp> - #include <xercesc/internal/XMLGrammarPoolImpl.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -159,8 +165,9 @@ ,fDataTypeReg(0) ,fMemoryManager(manager) ,fGrammarPool(gramPool) +,fXSModel(0) +,fGrammarPoolXSModel(0) { - fGrammarBucket = new (manager) RefHashTableOf<Grammar>(29, true, manager); /*** @@ -180,6 +187,8 @@ } fStringPool = fGrammarPool->getURIStringPool(); + // REVISIT: size + fGrammarsToAddToXSModel = new (manager) ValueVectorOf<SchemaGrammar*> (29, manager); } GrammarResolver::~GrammarResolver() @@ -195,6 +204,11 @@ */ if (!fGrammarPoolFromExternalApplication) delete fGrammarPool; + + if (fXSModel) + delete fXSModel; + // don't delete fGrammarPoolXSModel! we don't own it! + delete fGrammarsToAddToXSModel; } // --------------------------------------------------------------------------- @@ -319,7 +333,24 @@ bool GrammarResolver::containsNameSpace( const XMLCh* const nameSpaceKey ) { - return fGrammarBucket->containsKey( nameSpaceKey ); + if (!nameSpaceKey) + return false; + if (fGrammarBucket->containsKey(nameSpaceKey)) + return true; + if (fUseCachedGrammar) + { + if (fGrammarFromPool->containsKey(nameSpaceKey)) + return true; + + // Lastly, need to check in fGrammarPool + XMLSchemaDescription* gramDesc = fGrammarPool->createSchemaDescription(nameSpaceKey); + Janitor<XMLGrammarDescription> janName(gramDesc); + Grammar* grammar = fGrammarPool->retrieveGrammar(gramDesc); + if (grammar) + return true; + } + + return false; } void GrammarResolver::putGrammar(Grammar* const grammarToAdopt) @@ -330,37 +361,38 @@ /*** * the grammar will be either in the grammarpool, or in the grammarbucket */ - if (fCacheGrammar) - { - if(!fGrammarPool->cacheGrammar(grammarToAdopt)) - { - // grammar pool doesn't want it; we're stuck with looking after it - fGrammarBucket->put( (void*) grammarToAdopt->getGrammarDescription()->getGrammarKey(), grammarToAdopt ); - } - } - else + if (!fCacheGrammar || !fGrammarPool->cacheGrammar(grammarToAdopt)) { + // either we aren't caching or the grammar pool doesn't want it + // so we need to look after it fGrammarBucket->put( (void*) grammarToAdopt->getGrammarDescription()->getGrammarKey(), grammarToAdopt ); + if (grammarToAdopt->getGrammarType() == Grammar::SchemaGrammarType) + { + fGrammarsToAddToXSModel->addElement((SchemaGrammar*) grammarToAdopt); + } } - } // --------------------------------------------------------------------------- // GrammarResolver: methods // --------------------------------------------------------------------------- void GrammarResolver::reset() { - fGrammarBucket->removeAll(); + fGrammarBucket->removeAll(); + fGrammarsToAddToXSModel->removeAllElements(); + delete fXSModel; + fXSModel = 0; } void GrammarResolver::resetCachedGrammar() { + //REVISIT: if the pool is locked this will fail... should throw an exception? fGrammarPool->clear(); - + // Even though fXSModel and fGrammarPoolXSModel will be invalid don't touch + // them here as getXSModel will handle this. } void GrammarResolver::cacheGrammars() { - RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarBucket); ValueVectorOf<XMLCh*> keys(8, fMemoryManager); unsigned int keyCount = 0; @@ -373,6 +405,10 @@ keyCount++; } + // PSVI: assume everything will be added, if caching fails add grammar back + // into vector + fGrammarsToAddToXSModel->removeAllElements(); + // Cache for (unsigned int i = 0; i < keyCount; i++) { @@ -384,9 +420,14 @@ Grammar* grammar = fGrammarBucket->get(grammarKey); if(fGrammarPool->cacheGrammar(grammar)) { - // only orphan grammar is grammar pool accepts + // only orphan grammar if grammar pool accepts caching of it fGrammarBucket->orphanKey(grammarKey); } + else if (grammar->getGrammarType() == Grammar::SchemaGrammarType) + { + // add it back to list of grammars not in grammar pool + fGrammarsToAddToXSModel->addElement((SchemaGrammar*) grammar); + } } } @@ -396,9 +437,8 @@ // --------------------------------------------------------------------------- void GrammarResolver::cacheGrammarFromParse(const bool aValue) { - - fCacheGrammar = aValue; - fGrammarBucket->removeAll(); + reset(); + fCacheGrammar = aValue; fGrammarBucket->setAdoptElements(!fCacheGrammar); } @@ -406,14 +446,105 @@ { if (fCacheGrammar) { - fGrammarFromPool->removeKey(nameSpaceKey); - return fGrammarPool->orphanGrammar(nameSpaceKey); + Grammar* grammar = fGrammarPool->orphanGrammar(nameSpaceKey); + if (grammar) + { + fGrammarFromPool->removeKey(nameSpaceKey); + return grammar; + } + // It failed to remove it from the grammar pool either because it + // didn't exist or because it is locked. + return 0; } else { return fGrammarBucket->orphanKey(nameSpaceKey); } +} +XSModel *GrammarResolver::getXSModel() +{ + XSModel* xsModel; + if (fCacheGrammar) + { + // We know if the grammarpool changed thru caching, orphaning and erasing + // but NOT by other mechanisms such as lockPool() or unlockPool() so it + // is safest to always get it. The grammarPool XSModel will only be + // regenerated if something changed and in that case it will have a new + // address. + xsModel = fGrammarPool->getXSModel(); + if (xsModel != fGrammarPoolXSModel) + { + // we know the grammarpool XSModel has changed or this is the + // first call to getXSModel + if (!fGrammarPoolXSModel && (fGrammarsToAddToXSModel->size() == 0) && + !fXSModel) + { + fGrammarPoolXSModel = xsModel; + return fGrammarPoolXSModel; + } + else + { + // We had previously augmented the grammar pool XSModel + // with our our grammars or we would like to upate it now + // so we have to regenerate the XSModel + fGrammarsToAddToXSModel->removeAllElements(); + RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarBucket); + while (grammarEnum.hasMoreElements()) + { + Grammar& grammar = (Grammar&) grammarEnum.nextElement(); + if (grammar.getGrammarType() == Grammar::SchemaGrammarType) + fGrammarsToAddToXSModel->addElement((SchemaGrammar*)&grammar); + } + if (fXSModel) + { + xsModel = new (fMemoryManager) XSModel(fGrammarPoolXSModel, this, fMemoryManager); + delete fXSModel; + fXSModel = xsModel; + } + else + { + fXSModel = new (fMemoryManager) XSModel(fGrammarPoolXSModel, this, fMemoryManager); + } + fGrammarsToAddToXSModel->removeAllElements(); + return fXSModel; + } + } + else { + // we know that the grammar pool XSModel is the same as before + if (fGrammarsToAddToXSModel->size()) + { + // we need to update our fXSModel with the new grammars + if (fXSModel) + { + xsModel = new (fMemoryManager) XSModel(fXSModel, this, fMemoryManager); + fXSModel = xsModel; + } + else + { + fXSModel = new (fMemoryManager) XSModel(fGrammarPoolXSModel, this, fMemoryManager); + } + fGrammarsToAddToXSModel->removeAllElements(); + return fXSModel; + } + // Nothing has changed! + if (fXSModel) + { + return fXSModel; + } + else + { + return fGrammarPoolXSModel; + } + } + } + // Not Caching... + if (fGrammarsToAddToXSModel->size()) + { + xsModel = new (fMemoryManager) XSModel(fXSModel, this, fMemoryManager); + fXSModel = xsModel; + } + return fXSModel; } XERCES_CPP_NAMESPACE_END 1.17 +26 -10 xml-xerces/c/src/xercesc/validators/common/GrammarResolver.hpp Index: GrammarResolver.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/GrammarResolver.hpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- GrammarResolver.hpp 16 Sep 2003 18:30:54 -0000 1.16 +++ GrammarResolver.hpp 21 Nov 2003 22:38:50 -0000 1.17 @@ -219,6 +219,14 @@ void reset(); void resetCachedGrammar(); + /** + * Returns an XSModel, either from the GrammarPool or by creating one + */ + XSModel* getXSModel(); + + + ValueVectorOf<SchemaGrammar*>* getGrammarsToAddToXSModel(); + //@} private: @@ -241,15 +249,18 @@ // fMemoryManager Pluggable memory manager for dynamic memory // allocation/deallocation // ----------------------------------------------------------------------- - bool fCacheGrammar; - bool fUseCachedGrammar; - bool fGrammarPoolFromExternalApplication; - XMLStringPool* fStringPool; - RefHashTableOf<Grammar>* fGrammarBucket; - RefHashTableOf<Grammar>* fGrammarFromPool; - DatatypeValidatorFactory* fDataTypeReg; - MemoryManager* fMemoryManager; - XMLGrammarPool* fGrammarPool; + bool fCacheGrammar; + bool fUseCachedGrammar; + bool fGrammarPoolFromExternalApplication; + XMLStringPool* fStringPool; + RefHashTableOf<Grammar>* fGrammarBucket; + RefHashTableOf<Grammar>* fGrammarFromPool; + DatatypeValidatorFactory* fDataTypeReg; + MemoryManager* fMemoryManager; + XMLGrammarPool* fGrammarPool; + XSModel* fXSModel; + XSModel* fGrammarPoolXSModel; + ValueVectorOf<SchemaGrammar*>* fGrammarsToAddToXSModel; }; inline XMLStringPool* GrammarResolver::getStringPool() { @@ -271,6 +282,11 @@ inline MemoryManager* const GrammarResolver::getGrammarPoolMemoryManager() const { return fGrammarPool->getMemoryManager(); +} + +inline ValueVectorOf<SchemaGrammar*>* GrammarResolver::getGrammarsToAddToXSModel() +{ + return fGrammarsToAddToXSModel; } XERCES_CPP_NAMESPACE_END 1.30 +3 -5 xml-xerces/c/src/xercesc/dom/deprecated/DOMParser.cpp Index: DOMParser.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/deprecated/DOMParser.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- DOMParser.cpp 10 Nov 2003 21:56:52 -0000 1.29 +++ DOMParser.cpp 21 Nov 2003 22:38:50 -0000 1.30 @@ -324,12 +324,10 @@ { fPSVIHandler = handler; if (fPSVIHandler) { - fScanner->setPSVIHandler(fPSVIHandler); - fGrammarResolver->getGrammarPool()->setPSVI(true); + fScanner->setPSVIHandler(fPSVIHandler); } else { - fScanner->setPSVIHandler(0); - fGrammarResolver->getGrammarPool()->setPSVI(false); + fScanner->setPSVIHandler(0); } } 1.55 +3 -5 xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.cpp Index: AbstractDOMParser.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.cpp,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- AbstractDOMParser.cpp 10 Nov 2003 21:56:52 -0000 1.54 +++ AbstractDOMParser.cpp 21 Nov 2003 22:38:50 -0000 1.55 @@ -340,12 +340,10 @@ { fPSVIHandler = handler; if (fPSVIHandler) { - fScanner->setPSVIHandler(fPSVIHandler); - fGrammarResolver->getGrammarPool()->setPSVI(true); + fScanner->setPSVIHandler(fPSVIHandler); } else { - fScanner->setPSVIHandler(0); - fGrammarResolver->getGrammarPool()->setPSVI(false); + fScanner->setPSVIHandler(0); } } 1.31 +5 -4 xml-xerces/c/src/xercesc/parsers/SAX2XMLReaderImpl.cpp Index: SAX2XMLReaderImpl.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/SAX2XMLReaderImpl.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- SAX2XMLReaderImpl.cpp 6 Nov 2003 15:30:07 -0000 1.30 +++ SAX2XMLReaderImpl.cpp 21 Nov 2003 22:38:50 -0000 1.31 @@ -56,6 +56,13 @@ /* * $Log$ + * Revision 1.31 2003/11/21 22:38:50 neilg + * Enable grammar pools and grammar resolvers to manufacture + * XSModels. This also cleans up handling in the + * parser classes by eliminating the need to tell + * the grammar pool that schema compoments need to be produced. + * Thanks to David Cargill. + * * Revision 1.30 2003/11/06 15:30:07 neilg * first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse. * @@ -587,12 +594,10 @@ { fPSVIHandler = handler; if (fPSVIHandler) { - fScanner->setPSVIHandler(fPSVIHandler); - fGrammarResolver->getGrammarPool()->setPSVI(true); + fScanner->setPSVIHandler(fPSVIHandler); } else { - fScanner->setPSVIHandler(0); - fGrammarResolver->getGrammarPool()->setPSVI(false); + fScanner->setPSVIHandler(0); } } 1.29 +5 -4 xml-xerces/c/src/xercesc/parsers/SAXParser.cpp Index: SAXParser.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/SAXParser.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- SAXParser.cpp 6 Nov 2003 15:30:07 -0000 1.28 +++ SAXParser.cpp 21 Nov 2003 22:38:50 -0000 1.29 @@ -56,6 +56,13 @@ /* * $Log$ + * Revision 1.29 2003/11/21 22:38:50 neilg + * Enable grammar pools and grammar resolvers to manufacture + * XSModels. This also cleans up handling in the + * parser classes by eliminating the need to tell + * the grammar pool that schema compoments need to be produced. + * Thanks to David Cargill. + * * Revision 1.28 2003/11/06 15:30:07 neilg * first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse. * @@ -812,12 +819,10 @@ { fPSVIHandler = handler; if (fPSVIHandler) { - fScanner->setPSVIHandler(fPSVIHandler); - fGrammarResolver->getGrammarPool()->setPSVI(true); + fScanner->setPSVIHandler(fPSVIHandler); } else { - fScanner->setPSVIHandler(0); - fGrammarResolver->getGrammarPool()->setPSVI(false); + fScanner->setPSVIHandler(0); } } 1.8 +6 -0 xml-xerces/c/src/xercesc/util/XercesVersion.hpp Index: XercesVersion.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XercesVersion.hpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- XercesVersion.hpp 19 Nov 2003 23:06:52 -0000 1.7 +++ XercesVersion.hpp 21 Nov 2003 22:38:50 -0000 1.8 @@ -80,6 +80,11 @@ * other constants and preprocessor macros are automatically generated from * these three definitions. * + * The macro XERCES_GRAMMAR_SERIALIZATION_LEVEL has been added so that during + * development if users are using the latest code they can use the grammar + * serialization/desialization features. Whenever a change is made to the + * serialization code this macro should be incremented. + * * Xerces User Documentation: * * The following sections in the user documentation have examples based upon @@ -160,6 +165,7 @@ #define XERCES_VERSION_MINOR 4 #define XERCES_VERSION_REVISION 0 +#define XERCES_GRAMMAR_SERIALIZATION_LEVEL 0 /** DO NOT MODIFY BELOW THIS LINE */
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]