[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xerces-cvs
Subject:    cvs commit: xml-xerces/c/src/xercesc/validators/schema SchemaValidator.cpp SchemaValidator.hpp
From:       knoaman () apache ! org
Date:       2003-11-27 22:52:37
[Download RAW message or body]

knoaman     2003/11/27 14:52:37

  Modified:    c/src/xercesc/framework/psvi PSVIElement.cpp PSVIElement.hpp
               c/src/xercesc/internal IGXMLScanner.cpp IGXMLScanner.hpp
                        IGXMLScanner2.cpp SGXMLScanner.cpp SGXMLScanner.hpp
                        XMLScanner.hpp
               c/src/xercesc/validators/schema SchemaValidator.cpp
                        SchemaValidator.hpp
  Log:
  PSVIElement implementation
  
  Revision  Changes    Path
  1.4       +35 -23    xml-xerces/c/src/xercesc/framework/psvi/PSVIElement.cpp
  
  Index: PSVIElement.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/PSVIElement.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PSVIElement.cpp	21 Nov 2003 22:34:45 -0000	1.3
  +++ PSVIElement.cpp	27 Nov 2003 22:52:37 -0000	1.4
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.4  2003/11/27 22:52:37  knoaman
  + * PSVIElement implementation
  + *
    * Revision 1.3  2003/11/21 22:34:45  neilg
    * More schema component model implementation, thanks to David Cargill.
    * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
  @@ -76,7 +79,7 @@
   
   XERCES_CPP_NAMESPACE_BEGIN
   
  -PSVIElement::PSVIElement(MemoryManager* const manager ):  
  +PSVIElement::PSVIElement(MemoryManager* const manager):  
           PSVIItem(manager),
           fElementDecl(0),
           fNotationDecl(0),
  @@ -86,7 +89,7 @@
   
   XSTypeDefinition* PSVIElement::getTypeDefinition()
   {
  -    return fElementDecl->getTypeDefinition();
  +    return fType;
   }
   
       /**
  @@ -102,27 +105,34 @@
        */
   XSSimpleTypeDefinition* PSVIElement::getMemberTypeDefinition() 
   {
  -    XSTypeDefinition* typeDef = fElementDecl->getTypeDefinition();
  -    if (typeDef->getTypeCategory() == XSTypeDefinition::COMPLEX_TYPE)
  -    {
  -        if (((XSComplexTypeDefinition*)typeDef)->getContentType() == \
                XSComplexTypeDefinition::CONTENTTYPE_SIMPLE)
  -        {
  -            typeDef = ((XSComplexTypeDefinition*)typeDef)->getSimpleType();
  -            if (((XSSimpleTypeDefinition*)typeDef)->getVariety() == \
                XSSimpleTypeDefinition::VARIETY_UNION)
  -            {
  -
  -            }
  -        }        
  -    }
  -    else
  -    {
  -        // Simple Type...
  -        if (((XSSimpleTypeDefinition*)typeDef)->getVariety() == \
                XSSimpleTypeDefinition::VARIETY_UNION)
  -        {
  -
  -        }
  -    }
  -    return 0;
  +    return fMemberType;
  +}
  +
  +void PSVIElement::reset( const VALIDITY_STATE          validityState
  +                       , const ASSESSMENT_TYPE         assessmentType
  +                       , const XMLCh* const            validationContext
  +                       , bool                          isSpecified
  +                       , XSElementDeclaration* const   elemDecl
  +                       , XSTypeDefinition* const       typeDef
  +                       , XSSimpleTypeDefinition* const memberType
  +                       , XSModel* const                schemaInfo
  +                       , const XMLCh* const            defaultValue
  +                       , const XMLCh* const            normalizedValue
  +                       , const XMLCh* const            canonicalValue
  +                       , XSNotationDeclaration* const  notationDecl)
  +{
  +    fValidationContext = validationContext;
  +    fValidityState = validityState;
  +    fAssessmentType = assessmentType;
  +    fIsSpecified = isSpecified;
  +    fType = typeDef;
  +    fMemberType = memberType;
  +    fElementDecl = elemDecl;
  +    fNotationDecl = notationDecl;
  +    fSchemaInfo = schemaInfo;
  +    fDefaultValue = defaultValue;
  +    fNormalizedValue = normalizedValue;
  +    fCanonicalValue = canonicalValue;
   }
   
   XERCES_CPP_NAMESPACE_END
  
  
  
  1.5       +20 -0     xml-xerces/c/src/xercesc/framework/psvi/PSVIElement.hpp
  
  Index: PSVIElement.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/PSVIElement.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PSVIElement.hpp	21 Nov 2003 22:34:45 -0000	1.4
  +++ PSVIElement.hpp	27 Nov 2003 22:52:37 -0000	1.5
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.5  2003/11/27 22:52:37  knoaman
  + * PSVIElement implementation
  + *
    * Revision 1.4  2003/11/21 22:34:45  neilg
    * More schema component model implementation, thanks to David Cargill.
    * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
  @@ -166,6 +169,21 @@
       /** methods needed by implementation */
   
       //@{
  +    void reset
  +    (
  +        const VALIDITY_STATE            validityState
  +        , const ASSESSMENT_TYPE         assessmentType
  +        , const XMLCh* const            validationContext
  +        , bool                          isSpecified
  +        , XSElementDeclaration* const   elemDecl
  +        , XSTypeDefinition* const       typeDef
  +        , XSSimpleTypeDefinition* const memberType
  +        , XSModel* const                schemaInfo
  +        , const XMLCh* const            defaultValue
  +        , const XMLCh* const            normalizedValue = 0
  +        , const XMLCh* const            canonicalValue = 0
  +        , XSNotationDeclaration* const  notationDecl = 0
  +    );
   
       //@}
   
  
  
  
  1.36      +186 -50   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.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- IGXMLScanner.cpp	27 Nov 2003 06:10:31 -0000	1.35
  +++ IGXMLScanner.cpp	27 Nov 2003 22:52:37 -0000	1.36
  @@ -55,7 +55,7 @@
    */
   
   /*
  -  * $Id$
  + * $Id$
    */
   
   
  @@ -75,6 +75,7 @@
   #include <xercesc/framework/XMLGrammarPool.hpp>
   #include <xercesc/framework/XMLDTDDescription.hpp>
   #include <xercesc/framework/psvi/PSVIHandler.hpp>
  +#include <xercesc/framework/psvi/PSVIAttributeList.hpp>
   #include <xercesc/validators/common/GrammarResolver.hpp>
   #include <xercesc/validators/DTD/DocTypeHandler.hpp>
   #include <xercesc/validators/DTD/DTDScanner.hpp>
  @@ -116,6 +117,7 @@
       , fUndeclaredAttrRegistryNS(0)
       , fPSVIAttrList(0)
       , fModel(0)
  +    , fPSVIElement(0)
   {
       try
       {
  @@ -164,6 +166,7 @@
       , fUndeclaredAttrRegistryNS(0)
       , fPSVIAttrList(0)
       , fModel(0)
  +    , fPSVIElement(0)
   {
       try
       {	
  @@ -600,6 +603,7 @@
       delete fUndeclaredAttrRegistry;
       delete fUndeclaredAttrRegistryNS;
       delete fPSVIAttrList;
  +    delete fPSVIElement;
   }
   
   // ---------------------------------------------------------------------------
  @@ -980,6 +984,7 @@
           // It failed so we can't really do anything with it
           emitError(XMLErrs::ExpectedElementName);
           fReaderMgr.skipPastChar(chCloseAngle);
  +        //REVISIT: Do we restore PSVI information?
           return;
       }
   
  @@ -1033,7 +1038,6 @@
           }
       }
   
  -
       // Make sure we are back on the same reader as where we started
       if (topElem->fReaderNum != fReaderMgr.getCurrentReaderNum())
           emitError(XMLErrs::PartialTagMarkupError);
  @@ -1053,6 +1057,7 @@
   
       //  If validation is enabled, then lets pass him the list of children and
       //  this element and let him validate it.
  +    DatatypeValidator* psviMemberType = 0;
       if (fValidate)
       {
           int res = fValidator->checkContent
  @@ -1098,6 +1103,16 @@
   
   
           if (fGrammarType == Grammar::SchemaGrammarType) {
  +
  +            if (fPSVIHandler)
  +            {
  +                fPSVIElemContext.fIsSpecified = ((SchemaValidator*) \
fValidator)->getIsElemSpecified();  +                if (((SchemaValidator*) \
fValidator)->getErrorOccurred())  +                    \
fPSVIElemContext.fErrorOccurred = true;  +                else if \
(fPSVIElemContext.fCurrentDV->getType() == DatatypeValidator::Union)  +               \
psviMemberType = fValidationContext->getValidatingMemberType();  +            }
  +
               // call matchers and de-activate context
               int oldCount = fMatcherStack->getMatcherCount();
   
  @@ -1146,8 +1161,18 @@
               }
           }
       }
  -    if(!isRoot && fGrammarType == Grammar::SchemaGrammarType)
  -        ((SchemaElementDecl \
*)fElemStack.topElement()->fThisElement)->updateValidityFromElement(topElem->fThisElement, \
fGrammarType);  +
  +    if (fGrammarType == Grammar::SchemaGrammarType)
  +    {
  +        if(!isRoot)
  +            ((SchemaElementDecl \
*)fElemStack.topElement()->fThisElement)->updateValidityFromElement(topElem->fThisElement, \
fGrammarType);  +
  +        if (fPSVIHandler)
  +        {
  +            endElementPSVI(
  +                (SchemaElementDecl*)topElem->fThisElement, psviMemberType);
  +        }
  +    }
   
       // If we have a doc handler, tell it about the end tag
       if (fDocHandler)
  @@ -2107,7 +2132,7 @@
           ComplexTypeInfo *currType = \
((SchemaValidator*)fValidator)->getCurrentTypeInfo();  SchemaElementDecl::ModelTypes \
                modelType = (currType)
                   ? ((SchemaElementDecl::ModelTypes)currType->getContentType())
  -                : SchemaElementDecl::Simple;
  +                : ((SchemaElementDecl*) \
fElemStack.topElement()->fThisElement)->getModelType();  
           if ((modelType == SchemaElementDecl::Mixed_Simple)
             ||  (modelType == SchemaElementDecl::Mixed_Complex)
  @@ -2498,12 +2523,6 @@
               {
                   ((SchemaElementDecl \
                *)(elemDecl))->setValidationAttempted(PSVIDefs::FULL);
                   ((SchemaElementDecl \
                *)(elemDecl))->setValidity(PSVIDefs::INVALID);\
  -                if (getPSVIHandler())
  -                {
  -                    // REVISIT:                
  -                    // \
                PSVIElement->setValidationAttempted(PSVIItem::VALIDATION_FULL);
  -                    // PSVIElement->setValidity(PSVIItem::VALIDITY_INVALID);
  -                }
               }
           }
       }
  @@ -2513,12 +2532,6 @@
               if (fValidate) {
                   ((SchemaElementDecl \
                *)(elemDecl))->setValidationAttempted(PSVIDefs::FULL);
                   ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::VALID);
  -                if (getPSVIHandler())
  -                {
  -                    // REVISIT:
  -                    // \
                PSVIElement->setValidationAttempted(PSVIItem::VALIDATION_FULL);
  -                    // PSVIElement->setValidity(PSVIItem::VALIDITY_VALID);
  -                }
               }
           }
   
  @@ -2528,12 +2541,6 @@
                   if(fGrammarType == Grammar::SchemaGrammarType) {
                       ((SchemaElementDecl \
                *)(elemDecl))->setValidity(PSVIDefs::INVALID);
                       ((SchemaElementDecl \
                *)(elemDecl))->setValidationAttempted(PSVIDefs::FULL);
  -                    if (getPSVIHandler())
  -                    {
  -                        // REVISIT:
  -                        // \
                PSVIElement->setValidationAttempted(PSVIItem::VALIDATION_FULL);
  -                        // PSVIElement->setValidity(PSVIItem::VALIDATION_INVALID);
  -                    }
                   }
               }
               
  @@ -2559,11 +2566,6 @@
   
       if(errorBeforeElementFound && fGrammarType == Grammar::SchemaGrammarType) {
           ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
  -        if (getPSVIHandler())
  -        {
  -            // REVISIT:
  -            // PSVIElement->setValidity(PSVIItem::VALIDITY_INVALID);
  -        }
       }
   
   
  @@ -2574,13 +2576,71 @@
       fElemStack.setCurrentURI(uriId);
   
       if (isRoot)
  +    {
           fRootGrammar = fGrammar;
  +        fRootElemName = XMLString::replicate(qnameRawBuf);
  +    }
  +
  +    if (fGrammarType == Grammar::SchemaGrammarType && fPSVIHandler)
  +    {
  +        fPSVIElemContext.fPreviousError = 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;
  +        }
  +    }
   
       //  Validate the element
       if (fValidate)
  +    {
           fValidator->validateElement(elemDecl);
  +        if (fPSVIHandler && fValidator->handlesSchema())
  +        {
  +            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();  if (typeinfo) {
               currentScope = typeinfo->getScopeDefined();
  @@ -2604,20 +2664,10 @@
                               , prefixBuf.getRawBuffer()
                           );                        
                           ((SchemaElementDecl \
                *)(elemDecl))->setValidity(PSVIDefs::INVALID);                        \
                
  -                        if (getPSVIHandler())
  -                        {   
  -                            // \
                PSVIElement->setValidity(PSVIItem::VALIDITY_INVALID);                 \
                
  -                        }
                       }
                       else if(errorCondition) {                        
                           ((SchemaElementDecl \
                *)(elemDecl))->setValidationAttempted(PSVIDefs::NONE);
                           ((SchemaElementDecl \
                *)(elemDecl))->setValidity(PSVIDefs::UNKNOWN);
  -                        if (getPSVIHandler())
  -                        {
  -                            // REVISIT:
  -                            // \
                PSVIElement->setValidationAttempted(PSVIItem::VALIDATION_NONE);
  -                            // \
                PSVIElement->setValidity(PSVIItem::VALIDITY_NOTKNOWN);                \
                
  -                        }
                       }
                   }
               }
  @@ -2630,7 +2680,6 @@
           }
   
           fElemState[elemDepth] = 0;
  -
       }
   
       fElemStack.setCurrentGrammar(fGrammar);
  @@ -2741,6 +2790,7 @@
           // Pop the element stack back off since it'll never be used now
           fElemStack.popTop();
   
  +        DatatypeValidator* psviMemberType = 0;
           // If validating, then insure that its legal to have no content
           if (fValidate)
           {
  @@ -2753,19 +2803,22 @@
                       , elemDecl->getFullName()
                       , elemDecl->getFormattedContentModel()
                   );
  -                if(fGrammarType == Grammar::SchemaGrammarType)
  -                {
  -                    ((SchemaElementDecl \
                *)(elemDecl))->setValidity(PSVIDefs::INVALID);
  -                    if (getPSVIHandler())
  -                    {
  -                        // REVISIT:                
  -                        // PSVIElement->setValidity(PSVIItem::VALIDITY_INVALID);
  -                    }
  -                }
               }
   
               if (fGrammarType == Grammar::SchemaGrammarType) {
   
  +                if (((SchemaValidator*) fValidator)->getErrorOccurred())
  +                {
  +                    fPSVIElemContext.fErrorOccurred = true;
  +                    ((SchemaElementDecl \
*)(elemDecl))->setValidity(PSVIDefs::INVALID);  +                }
  +                else if (fPSVIHandler)
  +                {
  +                    fPSVIElemContext.fIsSpecified = ((SchemaValidator*) \
fValidator)->getIsElemSpecified();  +                    if \
(fPSVIElemContext.fCurrentDV->getType() == DatatypeValidator::Union)  +               \
psviMemberType = fValidationContext->getValidatingMemberType();  +                }
  +
                   // call matchers and de-activate context
                   int oldCount = fMatcherStack->getMatcherCount();
   
  @@ -2814,8 +2867,16 @@
               }
           }
   
  -        if(!isRoot && fGrammarType == Grammar::SchemaGrammarType)
  -           ((SchemaElementDecl \
*)fElemStack.topElement()->fThisElement)->updateValidityFromElement(elemDecl, \
fGrammarType);  +        if (fGrammarType == Grammar::SchemaGrammarType)
  +        {
  +            if(!isRoot)
  +                ((SchemaElementDecl \
*)fElemStack.topElement()->fThisElement)->updateValidityFromElement(elemDecl, \
fGrammarType);  +
  +            if (fPSVIHandler)
  +            {
  +                endElementPSVI((SchemaElementDecl*)elemDecl, psviMemberType);
  +            }
  +        }
   
           // If we have a doc handler, tell it about the end tag
           if (fDocHandler)
  @@ -3238,6 +3299,81 @@
               }
           }
       }
  +}
  +
  +void IGXMLScanner::endElementPSVI(SchemaElementDecl* const elemDecl,
  +                                  DatatypeValidator* const memberDV)
  +{
  +    PSVIElement::ASSESSMENT_TYPE validationAttempted;
  +    PSVIElement::VALIDITY_STATE validity = PSVIElement::VALIDITY_NOTKNOWN;
  +
  +    if (fPSVIElemContext.fElemDepth > fPSVIElemContext.fFullValidationDepth)
  +        validationAttempted = PSVIElement::VALIDATION_FULL;
  +    else if (fPSVIElemContext.fElemDepth > fPSVIElemContext.fNoneValidationDepth)
  +        validationAttempted = PSVIElement::VALIDATION_NONE;
  +    else
  +    {
  +        validationAttempted  = PSVIElement::VALIDATION_PARTIAL;
  +		fPSVIElemContext.fFullValidationDepth =
  +            fPSVIElemContext.fNoneValidationDepth = fPSVIElemContext.fElemDepth - \
1;  +    }
  +
  +    if (fValidate && elemDecl->isDeclared())
  +    {
  +        validity = (fPSVIElemContext.fErrorOccurred)
  +            ? PSVIElement::VALIDITY_INVALID : PSVIElement::VALIDITY_VALID;
  +    }
  +
  +    XSTypeDefinition* typeDef = (fPSVIElemContext.fCurrentDV)
  +        ? (XSTypeDefinition*) fModel->getXSObject(fPSVIElemContext.fCurrentDV)
  +        : (fPSVIElemContext.fCurrentTypeInfo)
  +            ? (XSTypeDefinition*) \
fModel->getXSObject(fPSVIElemContext.fCurrentTypeInfo)  +            : 0;
  +
  +    fPSVIElement->reset
  +    (
  +        validity
  +        , validationAttempted
  +        , fPSVIElemContext.fValidationRoot
  +        , fPSVIElemContext.fIsSpecified
  +        , (elemDecl->isDeclared()) 
  +            ? (XSElementDeclaration*) fModel->getXSObject(elemDecl) : 0
  +        , typeDef
  +        , (memberDV) ? (XSSimpleTypeDefinition*) fModel->getXSObject(memberDV) : 0
  +        , fModel
  +        , elemDecl->getDefaultValue()
  +    );
  +
  +    fPSVIHandler->handleElementPSVI
  +    (
  +        elemDecl->getBaseName()
  +        , fURIStringPool->getValueForId(elemDecl->getURI())
  +        , elemDecl->getElementName()->getPrefix()
  +        , fPSVIElement
  +    );
  +
  +    // 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;
  +}
  +
  +void IGXMLScanner::resetPSVIElemContext()
  +{
  +    fPSVIElemContext.fIsSpecified = false;
  +    fPSVIElemContext.fErrorOccurred = false;
  +    fPSVIElemContext.fElemDepth = -1;
  +    fPSVIElemContext.fFullValidationDepth = -1;
  +    fPSVIElemContext.fNoneValidationDepth = -1;
  +    fPSVIElemContext.fValidationRoot = 0;
  +    fPSVIElemContext.fCurrentDV = 0;
  +    fPSVIElemContext.fCurrentTypeInfo = 0;
   }
   
   XERCES_CPP_NAMESPACE_END
  
  
  
  1.15      +15 -3     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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- IGXMLScanner.hpp	27 Nov 2003 06:10:31 -0000	1.14
  +++ IGXMLScanner.hpp	27 Nov 2003 22:52:37 -0000	1.15
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.15  2003/11/27 22:52:37  knoaman
  + * PSVIElement implementation
  + *
    * Revision 1.14  2003/11/27 06:10:31  neilg
    * PSVIAttribute implementation
    *
  @@ -111,8 +114,6 @@
   #include <xercesc/util/RefHash3KeysIdPool.hpp>
   #include <xercesc/validators/common/Grammar.hpp>
   #include <xercesc/validators/schema/SchemaElementDecl.hpp>
  -#include <xercesc/framework/psvi/PSVIAttribute.hpp>
  -#include <xercesc/framework/psvi/PSVIAttributeList.hpp>
   
   XERCES_CPP_NAMESPACE_BEGIN
   
  @@ -128,6 +129,8 @@
   class SchemaAttDef;
   class XMLContentModel;
   class XSModel;
  +class PSVIAttributeList;
  +class PSVIElement;
   
   //  This is an integrated scanner class, which does DTD/XML Schema grammar
   //  processing.
  @@ -301,6 +304,13 @@
       Grammar* loadDTDGrammar(const InputSource& src, const bool toCache = false);
   
       // -----------------------------------------------------------------------
  +    //  PSVI handling methods
  +    // -----------------------------------------------------------------------
  +    void endElementPSVI(SchemaElementDecl* const elemDecl,
  +                        DatatypeValidator* const memberDV);
  +    void resetPSVIElemContext();
  +
  +    // -----------------------------------------------------------------------
       //  Data members
       //
       //  fRawAttrList
  @@ -374,6 +384,8 @@
       RefHash2KeysTableOf<unsigned int>*      fUndeclaredAttrRegistryNS;
       PSVIAttributeList *                     fPSVIAttrList;
       XSModel*                                fModel;
  +    PSVIElement*                            fPSVIElement;
  +    PSVIElemContext                         fPSVIElemContext;
   };
   
   inline const XMLCh* IGXMLScanner::getName() const
  
  
  
  1.45      +27 -8     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.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- IGXMLScanner2.cpp	27 Nov 2003 17:06:40 -0000	1.44
  +++ IGXMLScanner2.cpp	27 Nov 2003 22:52:37 -0000	1.45
  @@ -80,9 +80,8 @@
   #include <xercesc/framework/XMLGrammarPool.hpp>
   #include <xercesc/framework/XMLDTDDescription.hpp>
   #include <xercesc/framework/XMLSchemaDescription.hpp>
  -#include <xercesc/framework/psvi/PSVIAttribute.hpp>
  -#include <xercesc/framework/psvi/XSAttributeDeclaration.hpp>
  -#include <xercesc/framework/psvi/XSSimpleTypeDefinition.hpp>
  +#include <xercesc/framework/psvi/PSVIAttributeList.hpp>
  +#include <xercesc/framework/psvi/PSVIElement.hpp>
   #include <xercesc/validators/common/ContentLeafNameTypeVector.hpp>
   #include <xercesc/validators/DTD/DTDGrammar.hpp>
   #include <xercesc/validators/DTD/DTDValidator.hpp>
  @@ -271,9 +270,10 @@
                                   );
                                   if(fGrammarType == Grammar::SchemaGrammarType) {
                                       ((SchemaAttDef \
                *)(attDef))->setValidity(PSVIDefs::INVALID);
  -                                    if(getPSVIHandler() )
  +                                    if (getPSVIHandler())
                                       {
                                           attrValid = PSVIItem::VALIDITY_INVALID;
  +                                        fPSVIElemContext.fErrorOccurred = true;
                                       }                                
                                   }
                               }
  @@ -292,9 +292,10 @@
                                   );
                                   if(fGrammarType == Grammar::SchemaGrammarType) {
                                       ((SchemaAttDef \
                *)(attDef))->setValidity(PSVIDefs::INVALID);
  -                                    if(getPSVIHandler() )
  +                                    if (getPSVIHandler())
                                       {
                                           attrValid = PSVIItem::VALIDITY_INVALID;
  +                                        fPSVIElemContext.fErrorOccurred = true;
                                       }
                                   }
                               }
  @@ -333,6 +334,7 @@
                           , attDef->getFullName()
                           , elemDecl->getFullName()
                       );
  +                    fPSVIElemContext.fErrorOccurred = true;
                   }
               }
               else
  @@ -377,6 +379,7 @@
                               , namePtr
                               , elemDecl->getFullName()
                           );
  +                        fPSVIElemContext.fErrorOccurred = true;
                       }
                   }
               }
  @@ -394,7 +397,10 @@
                   if(!attDef && !attDefForWildCard)
                   {
                       if(!laxThisOne && !skipThisOne)
  +                    {
                           attrValid = PSVIItem::VALIDITY_INVALID;
  +                        fPSVIElemContext.fErrorOccurred = true;
  +                    }
                       else if(laxThisOne)
                       {
                           attrValid = PSVIItem::VALIDITY_NOTKNOWN;
  @@ -482,7 +488,10 @@
                       );
                       attrValidator = \
                ((SchemaValidator*)fValidator)->getMostRecentAttrValidator();
                       if(getPSVIHandler() && ((SchemaValidator \
*)fValidator)->getErrorOccurred())  +                    {
  +                        fPSVIElemContext.fErrorOccurred = true;
                           attrValid = PSVIItem::VALIDITY_INVALID;
  +                    }
                   }
                   else // no decl; default DOMTypeInfo to anySimpleType
                       attrValidator = \
DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_ANYSIMPLETYPE);
  @@ -555,8 +564,6 @@
                   {
                       ((SchemaElementDecl \
*)(elemDecl))->updateValidityFromAttribute((SchemaAttDef *)attDef);  }
  -
  -
               }
   
               // now fill in the PSVIAttributes entry for this attribute:
  @@ -744,6 +751,7 @@
                           if(fGrammarType == Grammar::SchemaGrammarType) 
                           {
                               ((SchemaAttDef \
*)(curDef))->setValidity(PSVIDefs::INVALID);  +                            \
fPSVIElemContext.fErrorOccurred = true;  }
                       }
                       else if ((defType == XMLAttDef::Default) ||
  @@ -757,6 +765,7 @@
                               if(fGrammarType == Grammar::SchemaGrammarType)
                               {
                                   ((SchemaAttDef \
*)(curDef))->setValidity(PSVIDefs::INVALID);  +                                \
fPSVIElemContext.fErrorOccurred = true;  }
                           }
                       }
  @@ -881,6 +890,7 @@
                                   fURIStringPool->getValueForId(attQName->getURI())
                               );
                               \
prohibitedAttr->updateValidity(PSVIItem::VALIDITY_INVALID);  +                        \
fPSVIElemContext.fErrorOccurred = true;  }
                       }
                   }
  @@ -1227,6 +1237,15 @@
       fErrorCount = 0;
       fHasNoDTD = true;
       fSeeXsi = false;
  +
  +    // Reset PSVI context
  +    if (fPSVIHandler)
  +    {
  +        if (!fPSVIElement)
  +            fPSVIElement = new (fMemoryManager) PSVIElement(fMemoryManager);
  +
  +        resetPSVIElemContext();
  +    }
   
       // Reset the validators
       fDTDValidator->reset();
  
  
  
  1.54      +196 -54   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.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- SGXMLScanner.cpp	27 Nov 2003 17:06:40 -0000	1.53
  +++ SGXMLScanner.cpp	27 Nov 2003 22:52:37 -0000	1.54
  @@ -74,9 +74,7 @@
   #include <xercesc/framework/XMLGrammarPool.hpp>
   #include <xercesc/framework/XMLSchemaDescription.hpp>
   #include <xercesc/framework/psvi/PSVIHandler.hpp>
  -#include <xercesc/framework/psvi/PSVIAttribute.hpp>
  -#include <xercesc/framework/psvi/XSAttributeDeclaration.hpp>
  -#include <xercesc/framework/psvi/XSSimpleTypeDefinition.hpp>
  +#include <xercesc/framework/psvi/PSVIAttributeList.hpp>
   #include <xercesc/internal/EndOfEntityException.hpp>
   #include <xercesc/validators/common/ContentLeafNameTypeVector.hpp>
   #include <xercesc/validators/schema/SchemaValidator.hpp>
  @@ -120,6 +118,7 @@
       , fUndeclaredAttrRegistryNS(0)
       , fPSVIAttrList(0)
       , fModel(0)
  +    , fPSVIElement(0)
   {
       try
       {
  @@ -171,6 +170,7 @@
       , fUndeclaredAttrRegistryNS(0)
       , fPSVIAttrList(0)
       , fModel(0)
  +    , fPSVIElement(0)
   {
       try
       {	
  @@ -968,6 +968,7 @@
   
       //  If validation is enabled, then lets pass him the list of children and
       //  this element and let him validate it.
  +    DatatypeValidator* psviMemberType = 0;
       if (fValidate)
       {
           int res = fValidator->checkContent
  @@ -1012,6 +1013,16 @@
               
           }
   
  +        // update PSVI info
  +        if (fPSVIHandler)
  +        {
  +            fPSVIElemContext.fIsSpecified = ((SchemaValidator*) \
fValidator)->getIsElemSpecified();  +            if (((SchemaValidator*) \
fValidator)->getErrorOccurred())  +                fPSVIElemContext.fErrorOccurred = \
true;  +            else if (fPSVIElemContext.fCurrentDV->getType() == \
DatatypeValidator::Union)  +                psviMemberType = \
fValidationContext->getValidatingMemberType();  +        }
  +
           // call matchers and de-activate context
           int oldCount = fMatcherStack->getMatcherCount();
   
  @@ -1062,6 +1073,14 @@
       if(!isRoot)
           ((SchemaElementDecl \
*)fElemStack.topElement()->fThisElement)->updateValidityFromElement(topElem->fThisElement, \
fGrammarType);  
  +    if (fPSVIHandler)
  +    {
  +        endElementPSVI
  +        (
  +            (SchemaElementDecl*)topElem->fThisElement, psviMemberType
  +        );
  +    }
  +
       // If we have a doc handler, tell it about the end tag
       if (fDocHandler)
       {
  @@ -1169,7 +1188,7 @@
           ComplexTypeInfo *currType = \
((SchemaValidator*)fValidator)->getCurrentTypeInfo();  SchemaElementDecl::ModelTypes \
                modelType = (currType)
                   ? ((SchemaElementDecl::ModelTypes)currType->getContentType())
  -                : SchemaElementDecl::Simple;
  +                : ((SchemaElementDecl*) \
fElemStack.topElement()->fThisElement)->getModelType();  
           if ((modelType == SchemaElementDecl::Mixed_Simple)
             ||  (modelType == SchemaElementDecl::Mixed_Complex)
  @@ -1461,11 +1480,6 @@
           }
           else if(fValidate) {
               ((SchemaElementDecl \
                *)(elemDecl))->setValidationAttempted(PSVIDefs::FULL);
  -            if (getPSVIHandler())
  -            {
  -                // REVISIT:
  -                // PSVIElement->setValidationAttempted(PSVIItem::VALIDATION_FULL); \
                
  -            }
           }
   
           // If validating then emit an error
  @@ -1481,11 +1495,6 @@
                   , elemDecl->getFullName()
               );
               ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
  -            if (getPSVIHandler())
  -            {
  -                // REVISIT:               
  -                // PSVIElement->setValidity(PSVIItem::VALIDITY_INVALID);
  -            }
           }
       }
       else
  @@ -1494,12 +1503,6 @@
               if (fValidate) {
                   ((SchemaElementDecl \
                *)(elemDecl))->setValidationAttempted(PSVIDefs::FULL);
                   ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::VALID);
  -                if (getPSVIHandler())
  -                {
  -                    // REVISIT:
  -                    // \
                PSVIElement->setValidationAttempted(PSVIItem::VALIDATION_FULL);
  -                    // PSVIElement->setValidity(PSVIItem::VALIDITY_VALID);
  -                }
               }
           }
   
  @@ -1508,12 +1511,6 @@
               if(elemDecl->getCreateReason() == XMLElementDecl::NoReason) {
                   ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
                   ((SchemaElementDecl \
                *)(elemDecl))->setValidationAttempted(PSVIDefs::FULL);
  -                if (getPSVIHandler())
  -                {
  -                    // REVISIT:
  -                    // \
                PSVIElement->setValidationAttempted(PSVIItem::VALIDATION_FULL);
  -                    // PSVIElement->setValidity(PSVIItem::VALIDITY_INVALID);
  -                }
               }
               if (laxThisOne) {
                   fValidate = false;
  @@ -1537,11 +1534,6 @@
   
       if(errorBeforeElementFound) {
           ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
  -        if (getPSVIHandler())
  -        {
  -            // REVISIT:        
  -            // PSVIElement->setValidity(PSVIItem::VALIDITY_INVALID);
  -        }
       }
   
       //  Now we can update the element stack to set the current element
  @@ -1551,12 +1543,68 @@
       fElemStack.setCurrentURI(uriId);
   
       if (isRoot)
  +    {
           fRootGrammar = fGrammar;
  +        fRootElemName = XMLString::replicate(qnameRawBuf);
  +    }
  +
  +    if (fPSVIHandler)
  +    {
  +        fPSVIElemContext.fPreviousError = 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;
  +        }
  +    }
   
       //  Validate the element
       if (fValidate)
  +    {
           fValidator->validateElement(elemDecl);
  +        if (fPSVIHandler)
  +        {
  +            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();  if (typeinfo) {
  @@ -1581,22 +1629,10 @@
                           , prefixBuf.getRawBuffer()
                       );
                       ((SchemaElementDecl \
                *)(elemDecl))->setValidity(PSVIDefs::INVALID);
  -                    if (getPSVIHandler())
  -                    {
  -                        // REVISIT:                
  -                        // PSVIElement->setValidity(PSVIItem::VALIDITY_INVALID);
  -                    }
  -
                   }
                   else if(errorCondition) {
                       ((SchemaElementDecl \
                *)(elemDecl))->setValidationAttempted(PSVIDefs::NONE);
                       ((SchemaElementDecl \
                *)(elemDecl))->setValidity(PSVIDefs::UNKNOWN);
  -                    if (getPSVIHandler())
  -                    {
  -                        // REVISIT:
  -                        // \
                PSVIElement->setValidationAttempted(PSVIItem::VALIDATION_FULL);
  -                        // PSVIElement->setValidity(PSVIItem::VALIDITY_NOTKNOWN);
  -                    }
                   }
   
               }
  @@ -1623,11 +1659,6 @@
               if (fValidatorFromUser && \
                !fValidator->checkRootElement(elemDecl->getId())) {
                   fValidator->emitError(XMLValid::RootElemNotLikeDocType);
                   ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
  -                if (getPSVIHandler())
  -                {
  -                    // REVISIT:                
  -                    // PSVIElement->setValidity(PSVIItem::VALIDITY_INVALID);
  -                }
               }
           }
       }
  @@ -1713,6 +1744,7 @@
           fElemStack.popTop();
   
           // If validating, then insure that its legal to have no content
  +        DatatypeValidator* psviMemberType = 0;
           if (fValidate)
           {
               const int res = fValidator->checkContent(elemDecl, 0, 0);
  @@ -1727,11 +1759,14 @@
                       , elemDecl->getFormattedContentModel()
                   );
                   ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
  -                if (getPSVIHandler())
  -                {
  -                    // REVISIT:               
  -                    // PSVIElement->setValidity(PSVIItem::VALIDITY_INVALID);
  -                }
  +            }
  +
  +            if (fPSVIHandler)
  +            {
  +                if (((SchemaValidator*) fValidator)->getErrorOccurred())
  +                    fPSVIElemContext.fErrorOccurred = true;
  +                else if (fPSVIElemContext.fCurrentDV->getType() == \
DatatypeValidator::Union)  +                        psviMemberType = \
fValidationContext->getValidatingMemberType();  }
   
               // call matchers and de-activate context
  @@ -1783,6 +1818,14 @@
           if(!isRoot)
              ((SchemaElementDecl \
*)fElemStack.topElement()->fThisElement)->updateValidityFromElement(elemDecl, \
fGrammarType);  
  +        if (fPSVIHandler)
  +        {
  +            endElementPSVI
  +            (
  +                (SchemaElementDecl*)elemDecl, psviMemberType
  +            );
  +        }
  +
           // If we have a doc handler, tell it about the end tag
           if (fDocHandler)
           {
  @@ -2069,6 +2112,7 @@
       delete fAttDefRegistry;
       delete fUndeclaredAttrRegistryNS;
       delete fPSVIAttrList;
  +    delete fPSVIElement;
   }
   
   void SGXMLScanner::resizeElemState() {
  @@ -2253,6 +2297,7 @@
                                   if (getPSVIHandler())
                                   {
                                       attrValid = PSVIItem::VALIDITY_INVALID;
  +                                    fPSVIElemContext.fErrorOccurred = true;
                                   }
                               }
                           }
  @@ -2271,6 +2316,7 @@
                                   if (getPSVIHandler())
                                   {
                                       attrValid = PSVIItem::VALIDITY_INVALID;
  +                                    fPSVIElemContext.fErrorOccurred = true;
                                   }
                               }
                           }
  @@ -2305,6 +2351,7 @@
                           , attDef->getFullName()
                           , elemDecl->getFullName()
                       );
  +                    fPSVIElemContext.fErrorOccurred = true;
                   }
               }
               else
  @@ -2326,6 +2373,7 @@
                           , namePtr
                           , elemDecl->getFullName()
                       );
  +                    fPSVIElemContext.fErrorOccurred = true;
                   }
               }
               if(!skipThisOne && fGrammarType == Grammar::SchemaGrammarType && \
attDef) {  @@ -2344,7 +2392,10 @@
                   if(!attDef && !attDefForWildCard)
                   {
                       if(!laxThisOne && !skipThisOne)
  +                    {
                           attrValid = PSVIItem::VALIDITY_INVALID;
  +                        fPSVIElemContext.fErrorOccurred = true;
  +                    }
                       else if(laxThisOne)
                       {
                           attrValid = PSVIItem::VALIDITY_NOTKNOWN;
  @@ -2431,7 +2482,10 @@
                       );
                       attrValidator = ((SchemaValidator \
                *)fValidator)->getMostRecentAttrValidator();
                       if(getPSVIHandler() && ((SchemaValidator \
*)fValidator)->getErrorOccurred())  +                    {
                           attrValid = PSVIItem::VALIDITY_INVALID;
  +                        fPSVIElemContext.fErrorOccurred = true;
  +                    }
                   }
                   else // no decl; default DOMTypeInfo to anySimpleType
                       attrValidator = \
DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_ANYSIMPLETYPE);
  @@ -2483,7 +2537,10 @@
                           );
                           attrValidator = ((SchemaValidator \
                *)fValidator)->getMostRecentAttrValidator();
                           if(getPSVIHandler() && ((SchemaValidator \
*)fValidator)->getErrorOccurred())  +                        {
                               attrValid = PSVIItem::VALIDITY_INVALID;
  +                            fPSVIElemContext.fErrorOccurred = true;
  +                        }
                       }
                       else
                           attrValidator = \
DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_ANYSIMPLETYPE);
  @@ -2661,6 +2718,7 @@
                               , curDef->getFullName()
                           );
                           ((SchemaAttDef \
*)(curDef))->setValidity(PSVIDefs::INVALID);  +                        \
fPSVIElemContext.fErrorOccurred = true;  }
                       else if ((defType == XMLAttDef::Default) ||
                                (defType == XMLAttDef::Fixed)  )
  @@ -3110,6 +3168,15 @@
       fDoNamespaces = true;
       fDoSchema = true;
   
  +    // Reset PSVI context
  +    if (fPSVIHandler)
  +    {
  +        if (!fPSVIElement)
  +            fPSVIElement = new (fMemoryManager) PSVIElement(fMemoryManager);
  +
  +        resetPSVIElemContext();
  +    }
  +
       // Reset the validators
       fSchemaValidator->reset();
       fSchemaValidator->setErrorReporter(fErrorReporter);
  @@ -4657,6 +4724,81 @@
           return currType->getAttDefList();
       else
           return elemDecl->getAttDefList();
  +}
  +
  +void SGXMLScanner::endElementPSVI(SchemaElementDecl* const elemDecl,
  +                                  DatatypeValidator* const memberDV)
  +{
  +    PSVIElement::ASSESSMENT_TYPE validationAttempted;
  +    PSVIElement::VALIDITY_STATE validity = PSVIElement::VALIDITY_NOTKNOWN;
  +
  +    if (fPSVIElemContext.fElemDepth > fPSVIElemContext.fFullValidationDepth)
  +        validationAttempted = PSVIElement::VALIDATION_FULL;
  +    else if (fPSVIElemContext.fElemDepth > fPSVIElemContext.fNoneValidationDepth)
  +        validationAttempted = PSVIElement::VALIDATION_NONE;
  +    else
  +    {
  +        validationAttempted  = PSVIElement::VALIDATION_PARTIAL;
  +		fPSVIElemContext.fFullValidationDepth =
  +            fPSVIElemContext.fNoneValidationDepth = fPSVIElemContext.fElemDepth - \
1;  +    }
  +
  +    if (fValidate && elemDecl->isDeclared())
  +    {
  +        validity = (fPSVIElemContext.fErrorOccurred)
  +            ? PSVIElement::VALIDITY_INVALID : PSVIElement::VALIDITY_VALID;
  +    }
  +
  +    XSTypeDefinition* typeDef = (fPSVIElemContext.fCurrentDV)
  +        ? (XSTypeDefinition*) fModel->getXSObject(fPSVIElemContext.fCurrentDV)
  +        : (fPSVIElemContext.fCurrentTypeInfo)
  +            ? (XSTypeDefinition*) \
fModel->getXSObject(fPSVIElemContext.fCurrentTypeInfo)  +            : 0;
  +
  +    fPSVIElement->reset
  +    (
  +        validity
  +        , validationAttempted
  +        , fPSVIElemContext.fValidationRoot
  +        , fPSVIElemContext.fIsSpecified
  +        , (elemDecl->isDeclared()) 
  +            ? (XSElementDeclaration*) fModel->getXSObject(elemDecl) : 0
  +        , typeDef
  +        , (memberDV) ? (XSSimpleTypeDefinition*) fModel->getXSObject(memberDV) : 0
  +        , fModel
  +        , elemDecl->getDefaultValue()
  +    );
  +
  +    fPSVIHandler->handleElementPSVI
  +    (
  +        elemDecl->getBaseName()
  +        , fURIStringPool->getValueForId(elemDecl->getURI())
  +        , elemDecl->getElementName()->getPrefix()
  +        , fPSVIElement
  +    );
  +
  +    // 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;
  +}
  +
  +void SGXMLScanner::resetPSVIElemContext()
  +{
  +    fPSVIElemContext.fIsSpecified = false;
  +    fPSVIElemContext.fErrorOccurred = false;
  +    fPSVIElemContext.fElemDepth = -1;
  +    fPSVIElemContext.fFullValidationDepth = -1;
  +    fPSVIElemContext.fNoneValidationDepth = -1;
  +    fPSVIElemContext.fValidationRoot = 0;
  +    fPSVIElemContext.fCurrentDV = 0;
  +    fPSVIElemContext.fCurrentTypeInfo = 0;
   }
   
   XERCES_CPP_NAMESPACE_END
  
  
  
  1.14      +16 -3     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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SGXMLScanner.hpp	27 Nov 2003 06:10:31 -0000	1.13
  +++ SGXMLScanner.hpp	27 Nov 2003 22:52:37 -0000	1.14
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.14  2003/11/27 22:52:37  knoaman
  + * PSVIElement implementation
  + *
    * Revision 1.13  2003/11/27 06:10:31  neilg
    * PSVIAttribute implementation
    *
  @@ -108,8 +111,7 @@
   #include <xercesc/util/RefHash3KeysIdPool.hpp>
   #include <xercesc/validators/common/Grammar.hpp>
   #include <xercesc/validators/schema/SchemaElementDecl.hpp>
  -#include <xercesc/framework/psvi/PSVIAttribute.hpp>
  -#include <xercesc/framework/psvi/PSVIAttributeList.hpp>
  +
   
   XERCES_CPP_NAMESPACE_BEGIN
   
  @@ -123,6 +125,8 @@
   class SchemaAttDef;
   class XMLContentModel;
   class XSModel;
  +class PSVIAttributeList;
  +class PSVIElement;
   
   //  This is a scanner class, which process XML Schema grammar.
   class XMLPARSER_EXPORT SGXMLScanner : public XMLScanner
  @@ -292,6 +296,13 @@
       Grammar* loadXMLSchemaGrammar(const InputSource& src, const bool toCache = \
false);  
       // -----------------------------------------------------------------------
  +    //  PSVI handling methods
  +    // -----------------------------------------------------------------------
  +    void endElementPSVI(SchemaElementDecl* const elemDecl,
  +                        DatatypeValidator* const memberDV);
  +    void resetPSVIElemContext();
  +
  +    // -----------------------------------------------------------------------
       //  Data members
       //
       //  fRawAttrList
  @@ -355,6 +366,8 @@
       RefHash2KeysTableOf<unsigned int>*      fUndeclaredAttrRegistryNS;
       PSVIAttributeList *                     fPSVIAttrList;
       XSModel*                                fModel;
  +    PSVIElement*                            fPSVIElement;
  +    PSVIElemContext                         fPSVIElemContext;
   };
   
   inline const XMLCh* SGXMLScanner::getName() const
  
  
  
  1.29      +20 -1     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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- XMLScanner.hpp	24 Nov 2003 05:09:38 -0000	1.28
  +++ XMLScanner.hpp	27 Nov 2003 22:52:37 -0000	1.29
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.29  2003/11/27 22:52:37  knoaman
  + * PSVIElement implementation
  + *
    * Revision 1.28  2003/11/24 05:09:38  neilg
    * implement new, statless, method for detecting duplicate attributes
    *
  @@ -319,6 +322,22 @@
   class XMLValidator;
   class MemoryManager;
   class PSVIHandler;
  +
  +
  +struct PSVIElemContext
  +{
  +    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
   //  work of parsing. It handles reading in input and spitting out events
  
  
  
  1.46      +171 -165  xml-xerces/c/src/xercesc/validators/schema/SchemaValidator.cpp
  
  Index: SchemaValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaValidator.cpp,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- SchemaValidator.cpp	27 Nov 2003 06:10:31 -0000	1.45
  +++ SchemaValidator.cpp	27 Nov 2003 22:52:37 -0000	1.46
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.46  2003/11/27 22:52:37  knoaman
  + * PSVIElement implementation
  + *
    * Revision 1.45  2003/11/27 06:10:31  neilg
    * PSVIAttribute implementation
    *
  @@ -280,7 +283,6 @@
   //  Includes
   // ---------------------------------------------------------------------------
   #include <xercesc/util/Janitor.hpp>
  -#include <xercesc/util/KVStringPair.hpp>
   #include <xercesc/framework/XMLDocumentHandler.hpp>
   #include <xercesc/framework/XMLSchemaDescription.hpp>
   #include <xercesc/internal/XMLReader.hpp>
  @@ -321,6 +323,8 @@
       , fNil(false)
       , fTypeStack(0)
       , fMostRecentAttrValidator(0)
  +    , fErrorOccurred(false)
  +    , fElemIsSpecified(false)
   {
       fTypeStack = new (fMemoryManager) ValueStackOf<ComplexTypeInfo*>(8, \
fMemoryManager);  }
  @@ -341,7 +345,8 @@
                                    , QName** const         children
                                    , const unsigned int    childCount)
   {
  -    bool valid = true;
  +    fErrorOccurred = false;
  +    fElemIsSpecified = false;
   
       //
       //  Look up the element id in our element decl pool. This will get us
  @@ -354,7 +359,6 @@
       //  Get the content spec type of this element. This will tell us what
       //  to do to validate it.
       //
  -
       // the top of the type stack always knows best...
       ComplexTypeInfo* currType = fTypeStack->pop();
       ((SchemaElementDecl*) elemDecl)->setXsiComplexTypeInfo(currType);
  @@ -370,6 +374,7 @@
           //  we return 0 as the index of the first bad child.
           //
           if (childCount) {
  +            fErrorOccurred = true;
               return 0;
           }
       }
  @@ -386,9 +391,8 @@
               if (childCount > 0 || \
                !XMLString::equals(fDatatypeBuffer.getRawBuffer(), \
                XMLUni::fgZeroLenString)) {
                   emitError(XMLValid::NilAttrNotEmpty, elemDecl->getFullName());
                   ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
  -                valid = false;
  +                fErrorOccurred = true;
               }
  -
           }
           else {
               // Get the element's content model or fault it in
  @@ -407,6 +411,7 @@
   
               if(result != -1) {
                   ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
  +                fErrorOccurred = true;
               }
   
               return result;
  @@ -416,123 +421,122 @@
       {
           // Normally for SchemaElementDecl::Any, We pass no judgement on it and \
                anything goes
           // but if there is a fXsiTypeValidator, we need to use it for validation
  -
  -
           if (modelType == SchemaElementDecl::Simple && childCount > 0) {
               emitError(XMLValid::SimpleTypeHasChild, elemDecl->getFullName());
  -            valid = false;
  -        } else {
  -            try {
  -                if (!fCurrentDatatypeValidator) {
  -                    if (modelType == SchemaElementDecl::Simple) {
  -                        emitError(XMLValid::NoDatatypeValidatorForSimpleType, \
                elemDecl->getFullName());
  -                        valid = false;
  -                    }
  -                } else {
  -                    XMLCh* value = fDatatypeBuffer.getRawBuffer();
  -                    XMLCh* elemDefaultValue = ((SchemaElementDecl*) \
elemDecl)->getDefaultValue();  +            fErrorOccurred = true;
  +        }
  +        else if (fCurrentDatatypeValidator)
  +        {
  +            XMLCh* value = fDatatypeBuffer.getRawBuffer();
  +            XMLCh* elemDefaultValue = ((SchemaElementDecl*) \
elemDecl)->getDefaultValue();  
  -                    DatatypeValidator::ValidatorType eleDefDVType = \
fCurrentDatatypeValidator->getType();  +            if (fNil)
  +            {
  +                if ((!XMLString::equals(value, XMLUni::fgZeroLenString))
  +                    || elemDefaultValue)
  +                {
  +                    emitError(XMLValid::NilAttrNotEmpty, elemDecl->getFullName());
  +                    fErrorOccurred = true;
  +                }
  +            }
  +            else
  +            {
  +                DatatypeValidator::ValidatorType eleDefDVType = \
fCurrentDatatypeValidator->getType();  +                if (eleDefDVType == \
DatatypeValidator::NOTATION)  +                {
  +                    // if notation, need to bind URI to notation first
  +                    if (!fNotationBuf)
  +                        fNotationBuf = new (fMemoryManager) XMLBuffer(1023, \
fMemoryManager);  +
  +                    //  Make sure that this value maps to one of the
  +                    //  notation values in the enumList parameter. We don't have \
to  +                    //  look it up in the notation pool (if a notation) because \
we  +                    //  will look up the enumerated values themselves. If they \
are in  +                    //  the notation pool (after the Grammar is parsed), \
then obviously  +                    //  this value will be legal since it matches \
one of them.  +                    int colonPos = -1;
  +                    unsigned int uriId = getScanner()->resolveQName(value, \
*fNotationBuf, ElemStack::Mode_Element, colonPos);  +                    \
fNotationBuf->set(getScanner()->getURIText(uriId));  +                    \
fNotationBuf->append(chColon);  +                    \
fNotationBuf->append(&value[colonPos + 1]);  +                    value = \
fNotationBuf->getRawBuffer();  +                }
   
  -                    if (eleDefDVType == DatatypeValidator::NOTATION)
  +                if (elemDefaultValue)
  +                {
  +                    if (XMLString::equals(value, XMLUni::fgZeroLenString))
                       {
  -                        // if notation, need to bind URI to notation first
  -                        if (!fNotationBuf)
  -                            fNotationBuf = new (fMemoryManager) XMLBuffer(1023, \
                fMemoryManager);
  -
  -                        //  Make sure that this value maps to one of the
  -                        //  notation values in the enumList parameter. We don't \
                have to
  -                        //  look it up in the notation pool (if a notation) \
                because we
  -                        //  will look up the enumerated values themselves. If they \
                are in
  -                        //  the notation pool (after the Grammar is parsed), then \
                obviously
  -                        //  this value will be legal since it matches one of them.
  -                        int colonPos = -1;
  -                        unsigned int uriId = getScanner()->resolveQName(value, \
                *fNotationBuf, ElemStack::Mode_Element, colonPos);
  -                        fNotationBuf->set(getScanner()->getURIText(uriId));
  -                        fNotationBuf->append(chColon);
  -                        fNotationBuf->append(&value[colonPos + 1]);
  -                        value = fNotationBuf->getRawBuffer();
  +                        fElemIsSpecified = true;
  +                        // if this element didn't specified any value
  +                        // use default value
  +                        if (getScanner()->getDocHandler())
  +                            \
getScanner()->getDocHandler()->docCharacters(elemDefaultValue, \
XMLString::stringLen(elemDefaultValue), false);  +
  +                        // Normally for default value, it has been validated \
already during TraverseSchema  +                        // But if there was a \
xsi:type and this validator is fXsiTypeValidator,  +                        // need \
to validate again  +                        // we determine this if the current \
content dataype validator  +                        // is neither the one in the \
element nor the one in the current  +                        // complex type (if any)
  +                        if ((fCurrentDatatypeValidator != \
((SchemaElementDecl*)elemDecl)->getDatatypeValidator())  +                            \
&& (!fTypeStack->peek() || (fCurrentDatatypeValidator != \
fTypeStack->peek()->getDatatypeValidator())))  +                            value = \
elemDefaultValue;  +                        else
  +                            value = 0;
                       }
  -
  -                    if (elemDefaultValue) {
  -                        // a default value was specified
  -
  -                        // if nillable, it's an error to have default value
  -                        if (fNil) {
  -                            emitError(XMLValid::NilAttrNotEmpty, \
                elemDecl->getFullName());
  -                            valid = false;
  -                        }
  -                        if (XMLString::equals(value, XMLUni::fgZeroLenString)) {
  -                            // if this element didn't specified any value
  -                            // use default value
  -                            if (getScanner()->getDocHandler())
  -                                \
getScanner()->getDocHandler()->docCharacters(elemDefaultValue, \
                XMLString::stringLen(elemDefaultValue), false);
  -
  -                            // Normally for default value, it has been validated \
                already during TraverseSchema
  -                            // But if there was a xsi:type and this validator is \
                fXsiTypeValidator,
  -                            // need to validate again
  -                            // we determine this if the current content dataype \
                validator
  -                            // is neither the one in the element nor the one in \
                the current
  -                            // complex type (if any)
  -                            if ((fCurrentDatatypeValidator != \
                ((SchemaElementDecl*)elemDecl)->getDatatypeValidator())
  -                                    && (!fTypeStack->peek() || \
                (fCurrentDatatypeValidator != \
                fTypeStack->peek()->getDatatypeValidator())))
  -                                \
                fCurrentDatatypeValidator->validate(elemDefaultValue
  -                                                                  , \
                getScanner()->getValidationContext());
  -
  -                        }
  -                        else {
  -                            // this element has specified some value
  -                            // if the flag is FIXED, then this value must be same \
                as default value
  -                            if ((((SchemaElementDecl*)elemDecl)->getMiscFlags() & \
                SchemaSymbols::XSD_FIXED) != 0) {
  -                                if (fCurrentDatatypeValidator->compare(value, \
                elemDefaultValue) != 0 ) {
  -                                    emitError(XMLValid::FixedDifferentFromActual, \
                elemDecl->getFullName());
  -                                    valid = false;
  -                                }
  -                            }
  -
  -                            // if nillable, it's an error to have value
  -                            if (fNil) {
  -                                emitError(XMLValid::NilAttrNotEmpty, \
                elemDecl->getFullName());
  -                                valid = false;
  +                    else
  +                    {
  +                        // this element has specified some value
  +                        // if the flag is FIXED, then this value must be same as \
default value  +                        if \
((((SchemaElementDecl*)elemDecl)->getMiscFlags() & SchemaSymbols::XSD_FIXED) != 0)  + \
{  +                            if (fCurrentDatatypeValidator->compare(value, \
elemDefaultValue) != 0 )  +                            {
  +                                emitError(XMLValid::FixedDifferentFromActual, \
elemDecl->getFullName());  +                                fErrorOccurred = true;
                               }
  -                            else
  -                                fCurrentDatatypeValidator->validate(value
  -                                                                  , \
getScanner()->getValidationContext());  }
                       }
  -                    else {
  -                        // no default value, then check nillable
  -                        if (XMLString::equals(value, XMLUni::fgZeroLenString)) {
  -                            if ((((SchemaElementDecl*)elemDecl)->getMiscFlags() & \
                SchemaSymbols::XSD_NILLABLE) == 0)
  -                                fCurrentDatatypeValidator->validate(value
  -                                                                  , \
                getScanner()->getValidationContext());
  -                        }
  -                        else if (fNil) {
  -                            emitError(XMLValid::NilAttrNotEmpty, \
                elemDecl->getFullName());
  -                            valid = false;
  -                        }
  -                        else
  -                            fCurrentDatatypeValidator->validate(value
  -                                                              , \
getScanner()->getValidationContext());  +                }
  +                else
  +                {
  +                    // no default value, then check nillable
  +                    if (XMLString::equals(value, XMLUni::fgZeroLenString)
  +                        && (((SchemaElementDecl*)elemDecl)->getMiscFlags() & \
SchemaSymbols::XSD_NILLABLE) != 0)  +                            value = 0;
  +                }
  +
  +                if ((!fErrorOccurred) && value)
  +                {
  +                    try
  +                    {
  +                        fCurrentDatatypeValidator->validate(value, \
getScanner()->getValidationContext());  +                    }
  +                    catch (XMLException& idve)
  +                    {
  +                        emitError (XMLValid::DatatypeError, idve.getType(), \
idve.getMessage());  +                        fErrorOccurred = true;
  +                    }
  +                    catch(const OutOfMemoryException&)
  +                    {
  +                        throw;
  +                    }
  +                    catch (...)
  +                    {
  +                        ((SchemaElementDecl \
*)(elemDecl))->setValidity(PSVIDefs::INVALID);  +                        \
emitError(XMLValid::GenericError);  +                        throw;
                       }
                   }
               }
  -            catch (XMLException& idve) {
  -                emitError (XMLValid::DatatypeError, idve.getType(), \
                idve.getMessage());
  -                valid = false;
  -            }
  -            catch(const OutOfMemoryException&)
  -            {
  -                throw;
  -            }
  -            catch (...) {
  -                ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
  -                emitError(XMLValid::GenericError);
  -                throw;
  -            }
  +        }
  +        else if (modelType == SchemaElementDecl::Simple)
  +        {
  +            emitError(XMLValid::NoDatatypeValidatorForSimpleType, \
elemDecl->getFullName());  +            fErrorOccurred = true;
           }
       }
  -     else
  +    else
       {
           ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMType);
       }
  @@ -541,7 +545,7 @@
       fNil = false;
       fTrailing=false;
   
  -    if(!valid) {
  +    if(fErrorOccurred) {
           ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
       }
          
  @@ -593,8 +597,8 @@
                                          , bool                  preValidation
                                          , const XMLElementDecl* elemDecl)
   {
  -
       fErrorOccurred = false;
  +
       //turn on IdRefList checking
       getScanner()->getValidationContext()->toCheckIdRefList(true);
   
  @@ -770,7 +774,7 @@
               ? elemTypeInfo->getDatatypeValidator()
               : ((SchemaElementDecl*)elemDef)->getDatatypeValidator();
   
  -    bool valid = true;
  +    fErrorOccurred = false;
   
       if (fXsiType) {
           // handle "xsi:type" right here
  @@ -795,7 +799,7 @@
   
                       if (!xsiTypeDV) {
                           emitError(XMLValid::BadXsiType, fXsiType->getRawName());
  -                        valid = false;
  +                        fErrorOccurred = true;
                       }
                       else {
                           \
((SchemaElementDecl*)elemDef)->setXsiSimpleTypeInfo(xsiTypeDV);  @@ -804,18 +808,18 \
                @@
                                   && \
!fCurrentDatatypeValidator->isSubstitutableBy(xsiTypeDV))) {  // the type is not \
                derived from ancestor
                               emitError(XMLValid::NonDerivedXsiType, \
                fXsiType->getRawName(), elemDef->getFullName());
  -                            valid = false;
  +                            fErrorOccurred = true;
                           }
                           else {
                               // the type is derived from ancestor
                               if (((SchemaElementDecl*)elemDef)->getBlockSet() == \
                SchemaSymbols::XSD_RESTRICTION) {
                                   emitError(XMLValid::NoSubforBlock, \
                fXsiType->getRawName(), elemDef->getFullName());
  -                                valid = false;
  +                                fErrorOccurred = true;
                               }
                               if (elemDef->hasAttDefs()) {
                                   // if we have an attribute but xsi:type's type is \
                simple, we have a problem...
                                   emitError(XMLValid::NonDerivedXsiType, \
                fXsiType->getRawName(), elemDef->getFullName());
  -                                valid = false;
  +                                fErrorOccurred = true;
                               }
                           }
                           fCurrentDatatypeValidator = xsiTypeDV;
  @@ -824,20 +828,19 @@
                   else {
                       // Grammar not found
                       emitError(XMLValid::GrammarNotFound, uriStr);
  -                    valid = false;
  +                    fErrorOccurred = true;
                   }
               }
               else if (sGrammar->getGrammarType() != Grammar::SchemaGrammarType) {
                   emitError(XMLValid::GrammarNotFound, uriStr);
  -                valid = false;
  +                fErrorOccurred = true;
               }
               else {
                   // retrieve complexType registry and DatatypeValidator registry
                   RefHashTableOf<ComplexTypeInfo>* complexTypeRegistry = \
                sGrammar->getComplexTypeRegistry();
  -
                   if (!complexTypeRegistry) {
                       emitError(XMLValid::BadXsiType, fXsiType->getRawName());
  -                    valid = false;
  +                    fErrorOccurred = true;
                   }
                   else {
   
  @@ -850,84 +853,88 @@
   
                       if (typeInfo) {
                           // typeInfo is found
  -                        bool error = false;
  -
                           if (typeInfo->getAbstract()) {
                               emitError(XMLValid::NoAbstractInXsiType, \
                aBuffer.getRawBuffer());
  -                            error = true;
  +                            fErrorOccurred = true;
                           }
  +                        else
  +                        {
  +                            if (elemTypeInfo)
  +                            {
  +                                ComplexTypeInfo* tempType = typeInfo;
  +                                while (tempType) {
  +                                    if (tempType == elemTypeInfo)
  +                                        break;
  +                                    tempType = tempType->getBaseComplexTypeInfo();
  +                                }
   
  -                        ComplexTypeInfo* tempType = typeInfo;
  -                        if (elemTypeInfo) {
  -                            while (tempType) {
  -                                if (tempType == elemTypeInfo)
  -                                    break;
  -                                tempType = tempType->getBaseComplexTypeInfo();
  -                            }
  -                            if (!tempType) {
  -                                emitError(XMLValid::NonDerivedXsiType, \
                fXsiType->getRawName(), elemDef->getFullName());
  -                                error = true;
  -                            }
  -                            else {
  -                                int derivationMethod = typeInfo->getDerivedBy();
  -                                if ((((SchemaElementDecl*)elemDef)->getBlockSet() \
                & derivationMethod) != 0) {
  -                                    emitError(XMLValid::NoSubforBlock, \
                fXsiType->getRawName(), elemDef->getFullName());
  -                                    error = true;
  +                                if (!tempType) {
  +                                    emitError(XMLValid::NonDerivedXsiType, \
fXsiType->getRawName(), elemDef->getFullName());  +                                   \
fErrorOccurred = true;  +                                }
  +                                else {
  +                                    int derivationMethod = \
typeInfo->getDerivedBy();  +                                    if \
((((SchemaElementDecl*)elemDef)->getBlockSet() & derivationMethod) != 0) {  +         \
emitError(XMLValid::NoSubforBlock, fXsiType->getRawName(), elemDef->getFullName());  \
+                                        fErrorOccurred = true;  +                    \
}  }
                               }
  -                        }
  -                        else {
  -                            // if the original type is a simple type, check \
                derivation ok.
  -                            if (fCurrentDatatypeValidator && \
                !fCurrentDatatypeValidator->isSubstitutableBy(typeInfo->getDatatypeValidator())) \
                {
  -                                // the type is not derived from ancestor
  -                                emitError(XMLValid::NonDerivedXsiType, \
                fXsiType->getRawName(), elemDef->getFullName());
  -                                error = true;
  +                            else
  +                            {
  +                                // if the original type is a simple type, check \
derivation ok.  +                                if (fCurrentDatatypeValidator && \
!fCurrentDatatypeValidator->isSubstitutableBy(typeInfo->getDatatypeValidator())) {  + \
// the type is not derived from ancestor  +                                    \
emitError(XMLValid::NonDerivedXsiType, fXsiType->getRawName(), \
elemDef->getFullName());  +                                    fErrorOccurred = true;
  +                                }
                               }
  -                        }
   
  -                        if (!error) {
  -                            \
                ((SchemaElementDecl*)elemDef)->setXsiComplexTypeInfo(typeInfo);
  -                            fTypeStack->pop();
  -                            fTypeStack->push(typeInfo);
  -                            fCurrentDatatypeValidator = \
typeInfo->getDatatypeValidator();  +                            if (!fErrorOccurred)
  +                            {
  +                                \
((SchemaElementDecl*)elemDef)->setXsiComplexTypeInfo(typeInfo);  +                    \
fTypeStack->pop();  +                                fTypeStack->push(typeInfo);
  +                                fCurrentDatatypeValidator = \
typeInfo->getDatatypeValidator();  +                            }
                           }
  -                        valid = !error;
                       }
  -                    else {
  +                    else
  +                    {
                           // typeInfo not found
                           xsiTypeDV = fGrammarResolver->getDatatypeValidator(uriStr, \
localPart);  
                           if (!xsiTypeDV) {
                               emitError(XMLValid::BadXsiType, \
                fXsiType->getRawName());
  -                            valid = false;
  +                            fErrorOccurred = true;
                           }
                           else {
                               \
                ((SchemaElementDecl*)elemDef)->setXsiSimpleTypeInfo(xsiTypeDV);
                               if (fCurrentDatatypeValidator && \
                !fCurrentDatatypeValidator->isSubstitutableBy(xsiTypeDV)) {
                                   // the type is not derived from ancestor
                                   emitError(XMLValid::NonDerivedXsiType, \
                fXsiType->getRawName(), elemDef->getFullName());
  -                                valid = false;
  +                                fErrorOccurred = true;
                               }
                               else {
                                   // the type is derived from ancestor
                                   if (((SchemaElementDecl*)elemDef)->getBlockSet() \
                == SchemaSymbols::XSD_RESTRICTION) {
                                       emitError(XMLValid::NoSubforBlock, \
                fXsiType->getRawName(), elemDef->getFullName());
  -                                    valid = false;
  -                                    
  +                                    fErrorOccurred = true;
                                   }
                                   if (elemDef->hasAttDefs()) {
                                       // if we have an attribute but xsi:type's type \
                is simple, we have a problem...
                                       emitError(XMLValid::NonDerivedXsiType, \
                fXsiType->getRawName(), elemDef->getFullName());
  -                                    valid = false;
  +                                    fErrorOccurred = true;
                                   }
                               }
  -                            fCurrentDatatypeValidator = xsiTypeDV;
   
  +                            fCurrentDatatypeValidator = xsiTypeDV;
                           }
                       }
                   }
               }
           }
  +
           delete fXsiType;
           fXsiType = 0;
       }
  @@ -938,7 +945,7 @@
           //
           if (elemTypeInfo && elemTypeInfo->getAbstract()) {
               emitError(XMLValid::NoUseAbstractType, elemDef->getFullName());
  -            valid = false;
  +            fErrorOccurred = true;
           }
       }
   
  @@ -948,7 +955,7 @@
       int miscFlags = ((SchemaElementDecl*)elemDef)->getMiscFlags();
       if ((miscFlags & SchemaSymbols::XSD_ABSTRACT) != 0) {
           emitError(XMLValid::NoDirectUseAbstractElement, elemDef->getFullName());
  -        valid = false;
  +        fErrorOccurred = true;
       }
   
       //
  @@ -957,16 +964,15 @@
       if (fNil && (miscFlags & SchemaSymbols::XSD_NILLABLE) == 0 ) {
           fNil = false;
           emitError(XMLValid::NillNotAllowed, elemDef->getFullName());
  -        valid = false;
  +        fErrorOccurred = true;
       }
   
       fDatatypeBuffer.reset();
       fTrailing = false;
       fSeenId = false;
   
  -    if(!valid) {
  +    if(fErrorOccurred)
           ((SchemaElementDecl *)(elemDef))->setValidity(PSVIDefs::INVALID);    
  -    }
   }
   
   void SchemaValidator::preContentValidation(bool reuseGrammar,
  
  
  
  1.22      +15 -3     xml-xerces/c/src/xercesc/validators/schema/SchemaValidator.hpp
  
  Index: SchemaValidator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaValidator.hpp,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- SchemaValidator.hpp	27 Nov 2003 06:10:31 -0000	1.21
  +++ SchemaValidator.hpp	27 Nov 2003 22:52:37 -0000	1.22
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.22  2003/11/27 22:52:37  knoaman
  + * PSVIElement implementation
  + *
    * Revision 1.21  2003/11/27 06:10:31  neilg
    * PSVIAttribute implementation
    *
  @@ -267,7 +270,8 @@
       ComplexTypeInfo* getCurrentTypeInfo() const;
       DatatypeValidator *getCurrentDatatypeValidator() const;
       DatatypeValidator *getMostRecentAttrValidator() const;
  -    bool getErrorOccurred();
  +    bool getErrorOccurred() const;
  +    bool getIsElemSpecified() const;
   
   private:
       // -----------------------------------------------------------------------
  @@ -399,8 +403,10 @@
       //
       //  fTypeStack
       //      Stack of complex type declarations.
  +    //
       //  fMostRecentAttrValidator
       //      DatatypeValidator that validated attribute most recently processed
  +    //
       //  fErrorOccurred
       //      whether an error occurred in the most recent operation
       // -----------------------------------------------------------------------
  @@ -418,6 +424,7 @@
       ValueStackOf<ComplexTypeInfo*>* fTypeStack;
       DatatypeValidator *             fMostRecentAttrValidator;
       bool                            fErrorOccurred;
  +    bool                            fElemIsSpecified;
   };
   
   
  @@ -517,9 +524,14 @@
       return false;
   }
   
  -inline bool SchemaValidator::getErrorOccurred()
  +inline bool SchemaValidator::getErrorOccurred() const
   {
       return fErrorOccurred;
  +}
  +
  +inline bool SchemaValidator::getIsElemSpecified() const
  +{
  +    return fElemIsSpecified;
   }
   
   XERCES_CPP_NAMESPACE_END
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic