knoaman 2003/11/28 11:54:32 Modified: c/src/xercesc/internal XMLScanner.hpp SGXMLScanner.hpp SGXMLScanner.cpp IGXMLScanner2.cpp IGXMLScanner.hpp IGXMLScanner.cpp Log: PSVIElement update Revision Changes Path 1.30 +3 -4 xml-xerces/c/src/xercesc/internal/XMLScanner.hpp Index: XMLScanner.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner.hpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- XMLScanner.hpp 27 Nov 2003 22:52:37 -0000 1.29 +++ XMLScanner.hpp 28 Nov 2003 19:54:31 -0000 1.30 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.30 2003/11/28 19:54:31 knoaman + * PSVIElement update + * * Revision 1.29 2003/11/27 22:52:37 knoaman * PSVIElement implementation * @@ -328,15 +331,11 @@ { bool fIsSpecified; bool fErrorOccurred; - bool fPreviousError; int fElemDepth; int fFullValidationDepth; int fNoneValidationDepth; - const XMLCh* fValidationRoot; DatatypeValidator* fCurrentDV; - DatatypeValidator* fPreviousDV; ComplexTypeInfo* fCurrentTypeInfo; - ComplexTypeInfo* fPreviousTypeInfo; }; // This is the mondo scanner class, which does the vast majority of the 1.15 +4 -0 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.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- SGXMLScanner.hpp 27 Nov 2003 22:52:37 -0000 1.14 +++ SGXMLScanner.hpp 28 Nov 2003 19:54:31 -0000 1.15 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.15 2003/11/28 19:54:31 knoaman + * PSVIElement update + * * Revision 1.14 2003/11/27 22:52:37 knoaman * PSVIElement implementation * @@ -367,6 +370,7 @@ PSVIAttributeList * fPSVIAttrList; XSModel* fModel; PSVIElement* fPSVIElement; + ValueStackOf<bool>* fErrorStack; PSVIElemContext fPSVIElemContext; }; 1.57 +65 -44 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.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- SGXMLScanner.cpp 28 Nov 2003 15:54:30 -0000 1.56 +++ SGXMLScanner.cpp 28 Nov 2003 19:54:31 -0000 1.57 @@ -119,6 +119,7 @@ , fPSVIAttrList(0) , fModel(0) , fPSVIElement(0) + , fErrorStack(0) { try { @@ -171,6 +172,7 @@ , fPSVIAttrList(0) , fModel(0) , fPSVIElement(0) + , fErrorStack(0) { try { @@ -966,6 +968,20 @@ ); } + if (fPSVIHandler) + { + if (fValidate && topElem->fThisElement->isDeclared()) + { + fPSVIElemContext.fCurrentDV = ((SchemaValidator*) fValidator)->getCurrentDatatypeValidator(); + fPSVIElemContext.fCurrentTypeInfo = ((SchemaValidator*) fValidator)->getCurrentTypeInfo(); + } + else + { + fPSVIElemContext.fCurrentDV = 0; + fPSVIElemContext.fCurrentTypeInfo = 0; + } + } + // If validation is enabled, then lets pass him the list of children and // this element and let him validate it. DatatypeValidator* psviMemberType = 0; @@ -1183,12 +1199,26 @@ XMLContentModel* cm = 0; int currentScope = Grammar::TOP_LEVEL_SCOPE; bool laxThisOne = false; - if (!isRoot) { - // schema validator will have correct type - ComplexTypeInfo *currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo(); - SchemaElementDecl::ModelTypes modelType = (currType) - ? ((SchemaElementDecl::ModelTypes)currType->getContentType()) - : ((SchemaElementDecl*) fElemStack.topElement()->fThisElement)->getModelType(); + if (!isRoot) + { + // schema validator will have correct type if validating + SchemaElementDecl* tempElement = (SchemaElementDecl*) + fElemStack.topElement()->fThisElement; + SchemaElementDecl::ModelTypes modelType = tempElement->getModelType(); + ComplexTypeInfo *currType = 0; + + if (fValidate) + { + currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo(); + if (currType) + modelType = (SchemaElementDecl::ModelTypes)currType->getContentType(); + else // something must have gone wrong + modelType = SchemaElementDecl::Any; + } + else + { + currType = tempElement->getComplexTypeInfo(); + } if ((modelType == SchemaElementDecl::Mixed_Simple) || (modelType == SchemaElementDecl::Mixed_Complex) @@ -1550,31 +1580,18 @@ if (fPSVIHandler) { - fPSVIElemContext.fPreviousError = fPSVIElemContext.fErrorOccurred; + fErrorStack->push(fPSVIElemContext.fErrorOccurred); fPSVIElemContext.fErrorOccurred = false; fPSVIElemContext.fElemDepth++; - fPSVIElemContext.fValidationRoot = fRootElemName; - - // store current type info so we can restore it later - fPSVIElemContext.fPreviousDV = fPSVIElemContext.fCurrentDV; - fPSVIElemContext.fPreviousTypeInfo = fPSVIElemContext.fCurrentTypeInfo; if (elemDecl->isDeclared()) { fPSVIElemContext.fNoneValidationDepth = fPSVIElemContext.fElemDepth; - - // update current type info - fPSVIElemContext.fCurrentDV = ((SchemaElementDecl*) elemDecl)->getDatatypeValidator(); - fPSVIElemContext.fCurrentTypeInfo = ((SchemaElementDecl*) elemDecl)->getComplexTypeInfo(); } else { fPSVIElemContext.fFullValidationDepth = fPSVIElemContext.fElemDepth; - // update current type info - fPSVIElemContext.fCurrentDV = 0; - fPSVIElemContext.fCurrentTypeInfo = 0; - if (isRoot && fValidate) fPSVIElemContext.fErrorOccurred = true; } @@ -1588,25 +1605,13 @@ { if (((SchemaValidator*) fValidator)->getErrorOccurred()) fPSVIElemContext.fErrorOccurred = true; - - // store current type info so we can restore it later - fPSVIElemContext.fPreviousDV = fPSVIElemContext.fCurrentDV; - fPSVIElemContext.fPreviousTypeInfo = fPSVIElemContext.fCurrentTypeInfo; - - if (elemDecl->isDeclared()) - { - fPSVIElemContext.fCurrentDV = ((SchemaValidator*) fValidator)->getCurrentDatatypeValidator(); - fPSVIElemContext.fCurrentTypeInfo = ((SchemaValidator*) fValidator)->getCurrentTypeInfo(); - } - else - { - fPSVIElemContext.fCurrentDV = 0; - fPSVIElemContext.fCurrentTypeInfo = 0; - } } } - ComplexTypeInfo* typeinfo = ((SchemaValidator*)fValidator)->getCurrentTypeInfo(); + ComplexTypeInfo* typeinfo = (fValidate) + ? ((SchemaValidator*)fValidator)->getCurrentTypeInfo() + : ((SchemaElementDecl*) elemDecl)->getComplexTypeInfo(); + if (typeinfo) { currentScope = typeinfo->getScopeDefined(); @@ -1742,6 +1747,21 @@ // Pop the element stack back off since it'll never be used now fElemStack.popTop(); + // reset current type info + if (fPSVIHandler && fGrammarType == Grammar::SchemaGrammarType) + { + if (fValidate && elemDecl->isDeclared()) + { + fPSVIElemContext.fCurrentDV = ((SchemaValidator*) fValidator)->getCurrentDatatypeValidator(); + fPSVIElemContext.fCurrentTypeInfo = ((SchemaValidator*) fValidator)->getCurrentTypeInfo(); + } + else + { + fPSVIElemContext.fCurrentDV = 0; + fPSVIElemContext.fCurrentTypeInfo = 0; + } + } + // If validating, then insure that its legal to have no content DatatypeValidator* psviMemberType = 0; if (fValidate) @@ -2112,6 +2132,7 @@ delete fUndeclaredAttrRegistryNS; delete fPSVIAttrList; delete fPSVIElement; + delete fErrorStack; } void SGXMLScanner::resizeElemState() { @@ -3173,6 +3194,9 @@ if (!fPSVIElement) fPSVIElement = new (fMemoryManager) PSVIElement(fMemoryManager); + if (!fErrorStack) + fErrorStack = new (fMemoryManager) ValueStackOf<bool>(8, fMemoryManager); + resetPSVIElemContext(); } @@ -4758,7 +4782,7 @@ ( validity , validationAttempted - , fPSVIElemContext.fValidationRoot + , fRootElemName , fPSVIElemContext.fIsSpecified , (elemDecl->isDeclared()) ? (XSElementDeclaration*) fModel->getXSObject(elemDecl) : 0 @@ -4766,6 +4790,8 @@ , (memberDV) ? (XSSimpleTypeDefinition*) fModel->getXSObject(memberDV) : 0 , fModel , elemDecl->getDefaultValue() + , 0 + , (fPSVIElemContext.fCurrentDV) ? fPSVIElemContext.fCurrentDV->getCanonicalRepresentation() : 0 ); fPSVIHandler->handleElementPSVI @@ -4778,13 +4804,9 @@ // decrease element depth fPSVIElemContext.fElemDepth--; - // restore type info - fPSVIElemContext.fCurrentDV = fPSVIElemContext.fPreviousDV; - fPSVIElemContext.fCurrentTypeInfo = fPSVIElemContext.fPreviousTypeInfo; - // reset error occurred fPSVIElemContext.fErrorOccurred = - fPSVIElemContext.fErrorOccurred && fPSVIElemContext.fPreviousError; + fPSVIElemContext.fErrorOccurred && fErrorStack->pop(); } void SGXMLScanner::resetPSVIElemContext() @@ -4794,7 +4816,6 @@ fPSVIElemContext.fElemDepth = -1; fPSVIElemContext.fFullValidationDepth = -1; fPSVIElemContext.fNoneValidationDepth = -1; - fPSVIElemContext.fValidationRoot = 0; fPSVIElemContext.fCurrentDV = 0; fPSVIElemContext.fCurrentTypeInfo = 0; } 1.48 +4 -1 xml-xerces/c/src/xercesc/internal/IGXMLScanner2.cpp Index: IGXMLScanner2.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/IGXMLScanner2.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- IGXMLScanner2.cpp 28 Nov 2003 18:33:15 -0000 1.47 +++ IGXMLScanner2.cpp 28 Nov 2003 19:54:31 -0000 1.48 @@ -1248,6 +1248,9 @@ if (!fPSVIElement) fPSVIElement = new (fMemoryManager) PSVIElement(fMemoryManager); + if (!fErrorStack) + fErrorStack = new (fMemoryManager) ValueStackOf<bool>(8, fMemoryManager); + resetPSVIElemContext(); } 1.17 +7 -1 xml-xerces/c/src/xercesc/internal/IGXMLScanner.hpp Index: IGXMLScanner.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/IGXMLScanner.hpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- IGXMLScanner.hpp 28 Nov 2003 05:13:29 -0000 1.16 +++ IGXMLScanner.hpp 28 Nov 2003 19:54:31 -0000 1.17 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.17 2003/11/28 19:54:31 knoaman + * PSVIElement update + * * Revision 1.16 2003/11/28 05:13:29 neilg * Fix state-ful duplicate attribute detection when the integrated * scanner is in use and namespaces are off. Also, implement @@ -391,6 +394,7 @@ PSVIAttributeList * fPSVIAttrList; XSModel* fModel; PSVIElement* fPSVIElement; + ValueStackOf<bool>* fErrorStack; PSVIElemContext fPSVIElemContext; }; 1.39 +62 -44 xml-xerces/c/src/xercesc/internal/IGXMLScanner.cpp Index: IGXMLScanner.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/IGXMLScanner.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- IGXMLScanner.cpp 28 Nov 2003 15:48:15 -0000 1.38 +++ IGXMLScanner.cpp 28 Nov 2003 19:54:31 -0000 1.39 @@ -118,6 +118,7 @@ , fPSVIAttrList(0) , fModel(0) , fPSVIElement(0) + , fErrorStack(0) { try { @@ -167,6 +168,7 @@ , fPSVIAttrList(0) , fModel(0) , fPSVIElement(0) + , fErrorStack(0) { try { @@ -604,6 +606,7 @@ delete fUndeclaredAttrRegistryNS; delete fPSVIAttrList; delete fPSVIElement; + delete fErrorStack; } // --------------------------------------------------------------------------- @@ -1055,6 +1058,20 @@ ); } + if (fPSVIHandler && fGrammarType == Grammar::SchemaGrammarType) + { + if (fValidate && topElem->fThisElement->isDeclared()) + { + fPSVIElemContext.fCurrentDV = ((SchemaValidator*) fValidator)->getCurrentDatatypeValidator(); + fPSVIElemContext.fCurrentTypeInfo = ((SchemaValidator*) fValidator)->getCurrentTypeInfo(); + } + else + { + fPSVIElemContext.fCurrentDV = 0; + fPSVIElemContext.fCurrentTypeInfo = 0; + } + } + // If validation is enabled, then lets pass him the list of children and // this element and let him validate it. DatatypeValidator* psviMemberType = 0; @@ -2125,12 +2142,26 @@ int currentScope = Grammar::TOP_LEVEL_SCOPE; bool laxThisOne = false; - if (!isRoot && fGrammarType == Grammar::SchemaGrammarType) { - // schema validator will have correct type - ComplexTypeInfo *currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo(); - SchemaElementDecl::ModelTypes modelType = (currType) - ? ((SchemaElementDecl::ModelTypes)currType->getContentType()) - : ((SchemaElementDecl*) fElemStack.topElement()->fThisElement)->getModelType(); + if (!isRoot && fGrammarType == Grammar::SchemaGrammarType) + { + // schema validator will have correct type if validating + SchemaElementDecl* tempElement = (SchemaElementDecl*) + fElemStack.topElement()->fThisElement; + SchemaElementDecl::ModelTypes modelType = tempElement->getModelType(); + ComplexTypeInfo *currType = 0; + + if (fValidate) + { + currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo(); + if (currType) + modelType = (SchemaElementDecl::ModelTypes)currType->getContentType(); + else // something must have gone wrong + modelType = SchemaElementDecl::Any; + } + else + { + currType = tempElement->getComplexTypeInfo(); + } if ((modelType == SchemaElementDecl::Mixed_Simple) || (modelType == SchemaElementDecl::Mixed_Complex) @@ -2582,31 +2613,18 @@ if (fGrammarType == Grammar::SchemaGrammarType && fPSVIHandler) { - fPSVIElemContext.fPreviousError = fPSVIElemContext.fErrorOccurred; + fErrorStack->push(fPSVIElemContext.fErrorOccurred); fPSVIElemContext.fErrorOccurred = false; fPSVIElemContext.fElemDepth++; - fPSVIElemContext.fValidationRoot = fRootElemName; - - // store current type info so we can restore it later - fPSVIElemContext.fPreviousDV = fPSVIElemContext.fCurrentDV; - fPSVIElemContext.fPreviousTypeInfo = fPSVIElemContext.fCurrentTypeInfo; if (elemDecl->isDeclared()) { fPSVIElemContext.fNoneValidationDepth = fPSVIElemContext.fElemDepth; - - // update current type info - fPSVIElemContext.fCurrentDV = ((SchemaElementDecl*) elemDecl)->getDatatypeValidator(); - fPSVIElemContext.fCurrentTypeInfo = ((SchemaElementDecl*) elemDecl)->getComplexTypeInfo(); } else { fPSVIElemContext.fFullValidationDepth = fPSVIElemContext.fElemDepth; - // update current type info - fPSVIElemContext.fCurrentDV = 0; - fPSVIElemContext.fCurrentTypeInfo = 0; - if (isRoot && fValidate) fPSVIElemContext.fErrorOccurred = true; } @@ -2620,27 +2638,15 @@ { if (((SchemaValidator*) fValidator)->getErrorOccurred()) fPSVIElemContext.fErrorOccurred = true; - - // store current type info so we can restore it later - fPSVIElemContext.fPreviousDV = fPSVIElemContext.fCurrentDV; - fPSVIElemContext.fPreviousTypeInfo = fPSVIElemContext.fCurrentTypeInfo; - - if (elemDecl->isDeclared()) - { - fPSVIElemContext.fCurrentDV = ((SchemaValidator*) fValidator)->getCurrentDatatypeValidator(); - fPSVIElemContext.fCurrentTypeInfo = ((SchemaValidator*) fValidator)->getCurrentTypeInfo(); - } - else - { - fPSVIElemContext.fCurrentDV = 0; - fPSVIElemContext.fCurrentTypeInfo = 0; - } } } if (fGrammarType == Grammar::SchemaGrammarType) { - ComplexTypeInfo* typeinfo = ((SchemaValidator*)fValidator)->getCurrentTypeInfo(); + ComplexTypeInfo* typeinfo = (fValidate) + ? ((SchemaValidator*)fValidator)->getCurrentTypeInfo() + : ((SchemaElementDecl*) elemDecl)->getComplexTypeInfo(); + if (typeinfo) { currentScope = typeinfo->getScopeDefined(); @@ -2788,6 +2794,21 @@ // Pop the element stack back off since it'll never be used now fElemStack.popTop(); + // reset current type info + if (fPSVIHandler && fGrammarType == Grammar::SchemaGrammarType) + { + if (fValidate && elemDecl->isDeclared()) + { + fPSVIElemContext.fCurrentDV = ((SchemaValidator*) fValidator)->getCurrentDatatypeValidator(); + fPSVIElemContext.fCurrentTypeInfo = ((SchemaValidator*) fValidator)->getCurrentTypeInfo(); + } + else + { + fPSVIElemContext.fCurrentDV = 0; + fPSVIElemContext.fCurrentTypeInfo = 0; + } + } + DatatypeValidator* psviMemberType = 0; // If validating, then insure that its legal to have no content if (fValidate) @@ -3332,7 +3353,7 @@ ( validity , validationAttempted - , fPSVIElemContext.fValidationRoot + , fRootElemName , fPSVIElemContext.fIsSpecified , (elemDecl->isDeclared()) ? (XSElementDeclaration*) fModel->getXSObject(elemDecl) : 0 @@ -3340,6 +3361,8 @@ , (memberDV) ? (XSSimpleTypeDefinition*) fModel->getXSObject(memberDV) : 0 , fModel , elemDecl->getDefaultValue() + , 0 + , (fPSVIElemContext.fCurrentDV) ? fPSVIElemContext.fCurrentDV->getCanonicalRepresentation() : 0 ); fPSVIHandler->handleElementPSVI @@ -3352,13 +3375,9 @@ // decrease element depth fPSVIElemContext.fElemDepth--; - // restore type info - fPSVIElemContext.fCurrentDV = fPSVIElemContext.fPreviousDV; - fPSVIElemContext.fCurrentTypeInfo = fPSVIElemContext.fPreviousTypeInfo; - // reset error occurred fPSVIElemContext.fErrorOccurred = - fPSVIElemContext.fErrorOccurred && fPSVIElemContext.fPreviousError; + fPSVIElemContext.fErrorOccurred && fErrorStack->pop(); } void IGXMLScanner::resetPSVIElemContext() @@ -3368,7 +3387,6 @@ fPSVIElemContext.fElemDepth = -1; fPSVIElemContext.fFullValidationDepth = -1; fPSVIElemContext.fNoneValidationDepth = -1; - fPSVIElemContext.fValidationRoot = 0; fPSVIElemContext.fCurrentDV = 0; fPSVIElemContext.fCurrentTypeInfo = 0; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]