knoaman 2004/09/27 14:04:38 Modified: c/src/xercesc/internal SGXMLScanner.cpp SGXMLScanner.hpp Log: Update SGXMLScanner to allow access of data and methods to XSAXMLScanner Revision Changes Path 1.96 +11 -6 xml-xerces/c/src/xercesc/internal/SGXMLScanner.cpp Index: SGXMLScanner.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/SGXMLScanner.cpp,v retrieving revision 1.95 retrieving revision 1.96 diff -u -r1.95 -r1.96 --- SGXMLScanner.cpp 26 Sep 2004 18:23:50 -0000 1.95 +++ SGXMLScanner.cpp 27 Sep 2004 21:04:38 -0000 1.96 @@ -2001,9 +2001,6 @@ // value string pairs (prior to any processing.) fRawAttrList = new (fMemoryManager) RefVectorOf<KVStringPair>(32, true, fMemoryManager); - // Create dummy schema grammar - fSchemaGrammar = new (fGrammarPoolMemoryManager) SchemaGrammar(fGrammarPoolMemoryManager); - // Create the Validator and init them fSchemaValidator = new (fMemoryManager) SchemaValidator(0, fMemoryManager); initValidator(fSchemaValidator); @@ -2043,8 +2040,11 @@ delete fAttDefRegistry; delete fUndeclaredAttrRegistryNS; delete fPSVIAttrList; - delete fPSVIElement; - delete fErrorStack; + if (fPSVIElement) + delete fPSVIElement; + + if (fErrorStack) + delete fErrorStack; } void SGXMLScanner::resizeElemState() { @@ -3030,6 +3030,11 @@ // fModel may need updating, as fGrammarResolver could have cleaned it if(fModel && getPSVIHandler()) fModel = fGrammarResolver->getXSModel(); + + // Create dummy schema grammar + if (!fSchemaGrammar) { + fSchemaGrammar = new (fGrammarPoolMemoryManager) SchemaGrammar(fGrammarPoolMemoryManager); + } fGrammar = fSchemaGrammar; fGrammarType = Grammar::DTDGrammarType; 1.21 +102 -85 xml-xerces/c/src/xercesc/internal/SGXMLScanner.hpp Index: SGXMLScanner.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/SGXMLScanner.hpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- SGXMLScanner.hpp 8 Sep 2004 13:56:13 -0000 1.20 +++ SGXMLScanner.hpp 27 Sep 2004 21:04:38 -0000 1.21 @@ -16,6 +16,9 @@ /* * $Log$ + * Revision 1.21 2004/09/27 21:04:38 knoaman + * Update SGXMLScanner to allow access of data and methods to XSAXMLScanner + * * Revision 1.20 2004/09/08 13:56:13 peiyongz * Apache License Version 2.0 * @@ -156,6 +159,105 @@ , const bool toCache = false ); +protected: + // ----------------------------------------------------------------------- + // XMLScanner virtual methods + // ----------------------------------------------------------------------- + virtual void scanReset(const InputSource& src); + + // ----------------------------------------------------------------------- + // SGXMLScanner virtual methods + // ----------------------------------------------------------------------- + virtual bool scanStartTag(bool& gotData); + virtual void scanEndTag(bool& gotData); + + // ----------------------------------------------------------------------- + // Helper methods + // ----------------------------------------------------------------------- + unsigned int buildAttList + ( + const RefVectorOf<KVStringPair>& providedAttrs + , const unsigned int attCount + , XMLElementDecl* elemDecl + , RefVectorOf<XMLAttr>& toFill + ); + bool laxElementValidation(QName* element, ContentLeafNameTypeVector* cv, + const XMLContentModel* const cm, + const unsigned int parentElemDepth); + unsigned int rawAttrScan + ( + const XMLCh* const elemName + , RefVectorOf<KVStringPair>& toFill + , bool& isEmpty + ); + void updateNSMap + ( + const XMLCh* const attrName + , const XMLCh* const attrValue + ); + unsigned int resolvePrefix + ( + const XMLCh* const prefix + , const ElemStack::MapModes mode + ); + void resizeElemState(); + + + // ----------------------------------------------------------------------- + // Data members + // + // fRawAttrList + // During the initial scan of the attributes we can only do a raw + // scan for key/value pairs. So this vector is used to store them + // until they can be processed (and put into fAttrList.) + // + // fSchemaValidator + // The Schema validator instance. + // + // fSeeXsi + // This flag indicates a schema has been seen. + // + // fElemState + // fElemStateSize + // Stores an element next state from DFA content model - used for + // wildcard validation + // + // fElemNonDeclPool + // registry for elements without decls in the grammar + // fElemCount + // count of the number of start tags seen so far (starts at 1). + // Used for duplicate attribute detection/processing of required/defaulted attributes + // fAttDefRegistry + // mapping from XMLAttDef instances to the count of the last + // start tag where they were utilized. + // fUndeclaredAttrRegistryNS + // mapping of namespaceId/localName pairs to the count of the last + // start tag in which they occurred. + // fPSVIAttrList + // PSVI attribute list implementation that needs to be + // filled when a PSVIHandler is registered + // + // ----------------------------------------------------------------------- + bool fSeeXsi; + Grammar::GrammarType fGrammarType; + unsigned int fElemStateSize; + unsigned int* fElemState; + XMLBuffer fContent; + ValueHashTableOf<XMLCh>* fEntityTable; + RefVectorOf<KVStringPair>* fRawAttrList; + SchemaGrammar* fSchemaGrammar; + SchemaValidator* fSchemaValidator; + IdentityConstraintHandler* fICHandler; + RefHash3KeysIdPool<SchemaElementDecl>* fElemNonDeclPool; + unsigned int fElemCount; + RefHashTableOf<unsigned int>* fAttDefRegistry; + RefHash2KeysTableOf<unsigned int>* fUndeclaredAttrRegistryNS; + PSVIAttributeList * fPSVIAttrList; + XSModel* fModel; + PSVIElement* fPSVIElement; + ValueStackOf<bool>* fErrorStack; + PSVIElemContext fPSVIElemContext; + private : // ----------------------------------------------------------------------- // Unimplemented constructors and operators @@ -177,7 +279,6 @@ , bool& escaped ); virtual void scanDocTypeDecl(); - virtual void scanReset(const InputSource& src); virtual void sendCharData(XMLBuffer& toSend); virtual InputSource* resolveSystemId(const XMLCh* const sysId); @@ -187,13 +288,6 @@ void commonInit(); void cleanUp(); - unsigned int buildAttList - ( - const RefVectorOf<KVStringPair>& providedAttrs - , const unsigned int attCount - , XMLElementDecl* elemDecl - , RefVectorOf<XMLAttr>& toFill - ); bool normalizeAttValue ( const XMLAttDef* const attDef @@ -210,31 +304,17 @@ unsigned int resolvePrefix ( const XMLCh* const prefix - , const ElemStack::MapModes mode - ); - unsigned int resolvePrefix - ( - const XMLCh* const prefix , XMLBuffer& uriBufToFill , const ElemStack::MapModes mode ); - void updateNSMap - ( - const XMLCh* const attrName - , const XMLCh* const attrValue - ); void scanRawAttrListforNameSpaces(int attCount); void parseSchemaLocation(const XMLCh* const schemaLocationStr); void resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* const uri); bool switchGrammar(const XMLCh* const newGrammarNameSpace); - bool laxElementValidation(QName* element, ContentLeafNameTypeVector* cv, - const XMLContentModel* const cm, - const unsigned int parentElemDepth); bool anyAttributeValidation(SchemaAttDef* attWildCard, unsigned int uriId, bool& skipThisOne, bool& laxThisOne); - void resizeElemState(); // ----------------------------------------------------------------------- // Private scanning methods @@ -244,20 +324,12 @@ const XMLCh* const attrName , XMLBuffer& toFill ); - unsigned int rawAttrScan - ( - const XMLCh* const elemName - , RefVectorOf<KVStringPair>& toFill - , bool& isEmpty - ); bool scanAttValue ( const XMLAttDef* const attDef , XMLBuffer& toFill ); bool scanContent(); - void scanEndTag(bool& gotData); - bool scanStartTag(bool& gotData); // ----------------------------------------------------------------------- // IdentityConstraints Activation methods @@ -275,61 +347,6 @@ void endElementPSVI(SchemaElementDecl* const elemDecl, DatatypeValidator* const memberDV); void resetPSVIElemContext(); - - // ----------------------------------------------------------------------- - // Data members - // - // fRawAttrList - // During the initial scan of the attributes we can only do a raw - // scan for key/value pairs. So this vector is used to store them - // until they can be processed (and put into fAttrList.) - // - // fSchemaValidator - // The Schema validator instance. - // - // fSeeXsi - // This flag indicates a schema has been seen. - // - // fElemState - // fElemStateSize - // Stores an element next state from DFA content model - used for - // wildcard validation - // - // fElemNonDeclPool - // registry for elements without decls in the grammar - // fElemCount - // count of the number of start tags seen so far (starts at 1). - // Used for duplicate attribute detection/processing of required/defaulted attributes - // fAttDefRegistry - // mapping from XMLAttDef instances to the count of the last - // start tag where they were utilized. - // fUndeclaredAttrRegistryNS - // mapping of namespaceId/localName pairs to the count of the last - // start tag in which they occurred. - // fPSVIAttrList - // PSVI attribute list implementation that needs to be - // filled when a PSVIHandler is registered - // - // ----------------------------------------------------------------------- - bool fSeeXsi; - Grammar::GrammarType fGrammarType; - unsigned int fElemStateSize; - unsigned int* fElemState; - XMLBuffer fContent; - ValueHashTableOf<XMLCh>* fEntityTable; - RefVectorOf<KVStringPair>* fRawAttrList; - SchemaGrammar* fSchemaGrammar; - SchemaValidator* fSchemaValidator; - IdentityConstraintHandler* fICHandler; - RefHash3KeysIdPool<SchemaElementDecl>* fElemNonDeclPool; - unsigned int fElemCount; - RefHashTableOf<unsigned int>* fAttDefRegistry; - RefHash2KeysTableOf<unsigned int>* fUndeclaredAttrRegistryNS; - PSVIAttributeList * fPSVIAttrList; - XSModel* fModel; - PSVIElement* fPSVIElement; - ValueStackOf<bool>* fErrorStack; - PSVIElemContext fPSVIElemContext; }; inline const XMLCh* SGXMLScanner::getName() const
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]