neilg       2003/12/14 13:09:26

  Modified:    c/src/xercesc/internal DGXMLScanner.cpp IGXMLScanner.cpp
                        IGXMLScanner2.cpp SGXMLScanner.cpp
  Log:
  implement XMLDocumentHandler::elementTypeInfo callback
  
  Revision  Changes    Path
  1.34      +4 -0      xml-xerces/c/src/xercesc/internal/DGXMLScanner.cpp
  
  Index: DGXMLScanner.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/DGXMLScanner.cpp,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- DGXMLScanner.cpp  10 Dec 2003 05:14:42 -0000      1.33
  +++ DGXMLScanner.cpp  14 Dec 2003 21:09:26 -0000      1.34
  @@ -758,6 +758,8 @@
                   ? topElem->fThisElement->getElementName()->getPrefix()
                   : XMLUni::fgZeroLenString
           );
  +        // pass back type name information
  +        fDocHandler->elementTypeInfo(XMLUni::fgZeroLenString, 
XMLUni::fgZeroLenString); 
       }
   
       // If this was the root, then done with content
  @@ -1591,6 +1593,8 @@
                   , (fDoNamespaces) ? elemDecl->getElementName()->getPrefix()
                                     : XMLUni::fgZeroLenString
               );
  +            // pass back type name information
  +            fDocHandler->elementTypeInfo(XMLUni::fgZeroLenString, 
XMLUni::fgZeroLenString); 
           }
   
           // Pop the element stack back off since it'll never be used now
  
  
  
  1.46      +125 -22   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.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- IGXMLScanner.cpp  10 Dec 2003 05:14:42 -0000      1.45
  +++ IGXMLScanner.cpp  14 Dec 2003 21:09:26 -0000      1.46
  @@ -1020,6 +1020,8 @@
       XMLElementDecl* tempElement = topElem->fThisElement;
       if (fDoNamespaces && fGrammarType == Grammar::SchemaGrammarType) {
   
  +        // reset error occurred
  +        fPSVIElemContext.fErrorOccurred = fErrorStack->pop();
           const XMLCh* rawNameBuf = fQNameBuf.getRawBuffer();
           if ((topUri != uriId) || (!XMLString::equals(tempElement->getBaseName(), 
&rawNameBuf[prefixColonPos + 1])))
           {
  @@ -1058,16 +1060,19 @@
           );
       }
   
  -    if (fPSVIHandler && fGrammarType == Grammar::SchemaGrammarType)
  +    if (fGrammarType == Grammar::SchemaGrammarType)
       {
           if (fValidate && topElem->fThisElement->isDeclared())
           {
               fPSVIElemContext.fCurrentDV = ((SchemaValidator*) 
fValidator)->getCurrentDatatypeValidator();
               fPSVIElemContext.fCurrentTypeInfo = ((SchemaValidator*) 
fValidator)->getCurrentTypeInfo();
  -            fPSVIElemContext.fNormalizedValue = ((SchemaValidator*) 
fValidator)->getNormalizedValue();
  +            if(fPSVIHandler)
  +            {
  +                fPSVIElemContext.fNormalizedValue = ((SchemaValidator*) 
fValidator)->getNormalizedValue();
   
  -            if (XMLString::equals(fPSVIElemContext.fNormalizedValue, 
XMLUni::fgZeroLenString))
  -                fPSVIElemContext.fNormalizedValue = 0;
  +                if (XMLString::equals(fPSVIElemContext.fNormalizedValue, 
XMLUni::fgZeroLenString))
  +                    fPSVIElemContext.fNormalizedValue = 0;
  +            }
           }
           else
           {
  @@ -1125,14 +1130,14 @@
   
   
           if (fGrammarType == Grammar::SchemaGrammarType) {
  +            if (((SchemaValidator*) fValidator)->getErrorOccurred())
  +                fPSVIElemContext.fErrorOccurred = true;
  +            else if (fPSVIElemContext.fCurrentDV && 
fPSVIElemContext.fCurrentDV->getType() == DatatypeValidator::Union)
  +                psviMemberType = fValidationContext->getValidatingMemberType();
   
               if (fPSVIHandler)
               {
                   fPSVIElemContext.fIsSpecified = ((SchemaValidator*) 
fValidator)->getIsElemSpecified();
  -                if (((SchemaValidator*) fValidator)->getErrorOccurred())
  -                    fPSVIElemContext.fErrorOccurred = true;
  -                else if (fPSVIElemContext.fCurrentDV && 
fPSVIElemContext.fCurrentDV->getType() == DatatypeValidator::Union)
  -                        psviMemberType = 
fValidationContext->getValidatingMemberType();
               }
   
               // call matchers and de-activate context
  @@ -1209,14 +1214,60 @@
               , isRoot
               , fPrefixBuf.getRawBuffer()
           );
  +        // pass information about type info:
  +        if(fGrammarType == Grammar::SchemaGrammarType)
  +        {
  +            const XMLCh *typeName = SchemaSymbols::fgATTVAL_ANYTYPE;
  +            const XMLCh *typeURI = SchemaSymbols::fgURI_SCHEMAFORSCHEMA; 
  +            if(!fPSVIElemContext.fErrorOccurred)
  +            {
  +                if(fPSVIElemContext.fCurrentTypeInfo != 0)
  +                {
  +                    if(fPSVIElemContext.fCurrentTypeInfo->getAnonymous())
  +                        typeName = XMLUni::fgZeroLenString;
  +                    else 
  +                        typeName = 
fPSVIElemContext.fCurrentTypeInfo->getTypeLocalName();
  +                    typeURI = fPSVIElemContext.fCurrentTypeInfo->getTypeUri();
  +                } 
  +                else
  +                {
  +                    DatatypeValidator *actualDV = 
(psviMemberType)?psviMemberType:fPSVIElemContext.fCurrentDV;
  +                    if(actualDV)
  +                    {
  +                        if(actualDV->getAnonymous())
  +                            typeName = XMLUni::fgZeroLenString;
  +                        else
  +                            typeName = actualDV->getTypeLocalName();
  +                        typeURI = actualDV->getTypeUri();
  +                    }
  +                }
  +            }
  +            else 
  +            {
  +                // idiosyncratically, if there's an
  +                // error but this element was simpleType-validated,
  +                // the tests demand anySimpleType be returned
  +                if(fPSVIElemContext.fCurrentDV)
  +                    typeName = SchemaSymbols::fgDT_ANYSIMPLETYPE;
  +            }
  +            fDocHandler->elementTypeInfo(typeName, typeURI);
  +        }
  +        else 
  +        {
  +            fDocHandler->elementTypeInfo(XMLUni::fgZeroLenString, 
XMLUni::fgZeroLenString); 
  +        }
       }
   
       // reset xsi:type ComplexTypeInfo
       if (fGrammarType == Grammar::SchemaGrammarType) {        
           ((SchemaElementDecl*)topElem->fThisElement)->reset();
           if (!isRoot)
  +        {
               ((SchemaElementDecl*)(fElemStack.topElement()->fThisElement))->
                   
setXsiComplexTypeInfo(((SchemaValidator*)fValidator)->getCurrentTypeInfo());
  +            // update error information
  +            fErrorStack->push(fErrorStack->pop() || 
fPSVIElemContext.fErrorOccurred);
  +        }
       }
   
       // If this was the root, then done with content
  @@ -2544,6 +2595,9 @@
           }
       }
   
  +    // this info needed for DOMTypeInfo
  +    fPSVIElemContext.fErrorOccurred = false;
  +
       //  We do something different here according to whether we found the
       //  element or not.
       if (wasAdded)
  @@ -2570,6 +2624,7 @@
               {
                   ((SchemaElementDecl 
*)(elemDecl))->setValidationAttempted(PSVIDefs::FULL);
                   ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);\
  +                fPSVIElemContext.fErrorOccurred = true;
               }
           }
       }
  @@ -2588,6 +2643,7 @@
                   if(fGrammarType == Grammar::SchemaGrammarType) {
                       ((SchemaElementDecl 
*)(elemDecl))->setValidity(PSVIDefs::INVALID);
                       ((SchemaElementDecl 
*)(elemDecl))->setValidationAttempted(PSVIDefs::FULL);
  +                    fPSVIElemContext.fErrorOccurred = true;
                   }
               }
               
  @@ -2631,10 +2687,8 @@
   
       if (fGrammarType == Grammar::SchemaGrammarType && fPSVIHandler)
       {
  -        fErrorStack->push(fPSVIElemContext.fErrorOccurred);
  -        fPSVIElemContext.fErrorOccurred = false;
  -        fPSVIElemContext.fElemDepth++;
   
  +        fPSVIElemContext.fElemDepth++;
           if (elemDecl->isDeclared())
           {
               fPSVIElemContext.fNoneValidationDepth = fPSVIElemContext.fElemDepth;
  @@ -2643,8 +2697,12 @@
           {
               fPSVIElemContext.fFullValidationDepth = fPSVIElemContext.fElemDepth;
   
  +            /******
  +             * While we report an error for historical reasons, this should
  +             * actually result in lax assessment - NG.
               if (isRoot && fValidate)
                   fPSVIElemContext.fErrorOccurred = true;
  +            *****/
           }
       }
   
  @@ -2652,7 +2710,7 @@
       if (fValidate)
       {
           fValidator->validateElement(elemDecl);
  -        if (fPSVIHandler && fValidator->handlesSchema())
  +        if (fValidator->handlesSchema())
           {
               if (((SchemaValidator*) fValidator)->getErrorOccurred())
                   fPSVIElemContext.fErrorOccurred = true;
  @@ -2813,16 +2871,20 @@
           fElemStack.popTop();
   
           // reset current type info
  -        if (fPSVIHandler && fGrammarType == Grammar::SchemaGrammarType)
  +        DatatypeValidator* psviMemberType = 0;
  +        if (fGrammarType == Grammar::SchemaGrammarType)
           {
               if (fValidate && elemDecl->isDeclared())
               {
                   fPSVIElemContext.fCurrentDV = ((SchemaValidator*) 
fValidator)->getCurrentDatatypeValidator();
                   fPSVIElemContext.fCurrentTypeInfo = ((SchemaValidator*) 
fValidator)->getCurrentTypeInfo();
  -                fPSVIElemContext.fNormalizedValue = ((SchemaValidator*) 
fValidator)->getNormalizedValue();
  +                if(fPSVIHandler)
  +                {
  +                    fPSVIElemContext.fNormalizedValue = ((SchemaValidator*) 
fValidator)->getNormalizedValue();
   
  -                if (XMLString::equals(fPSVIElemContext.fNormalizedValue, 
XMLUni::fgZeroLenString))
  -                    fPSVIElemContext.fNormalizedValue = 0;
  +                    if (XMLString::equals(fPSVIElemContext.fNormalizedValue, 
XMLUni::fgZeroLenString))
  +                        fPSVIElemContext.fNormalizedValue = 0;
  +                }
               }
               else
               {
  @@ -2832,7 +2894,6 @@
               }
           }
   
  -        DatatypeValidator* psviMemberType = 0;
           // If validating, then insure that its legal to have no content
           if (fValidate)
           {
  @@ -2854,9 +2915,10 @@
                       fPSVIElemContext.fErrorOccurred = true;
                       ((SchemaElementDecl 
*)(elemDecl))->setValidity(PSVIDefs::INVALID);
                   }
  -                else if (fPSVIHandler)
  +                else 
                   {
  -                    fPSVIElemContext.fIsSpecified = ((SchemaValidator*) 
fValidator)->getIsElemSpecified();
  +                    if (fPSVIHandler)
  +                        fPSVIElemContext.fIsSpecified = ((SchemaValidator*) 
fValidator)->getIsElemSpecified();
                       // note that if we're empty, won't be a current DV
                       if (fPSVIElemContext.fCurrentDV && 
fPSVIElemContext.fCurrentDV->getType() == DatatypeValidator::Union)
                           psviMemberType = 
fValidationContext->getValidatingMemberType();
  @@ -2931,6 +2993,48 @@
                   , isRoot
                   , fPrefixBuf.getRawBuffer()
               );
  +            // pass information about type info:
  +            if(fGrammarType == Grammar::SchemaGrammarType)
  +            {
  +                const XMLCh *typeName = SchemaSymbols::fgATTVAL_ANYTYPE;
  +                const XMLCh *typeURI = SchemaSymbols::fgURI_SCHEMAFORSCHEMA; 
  +                if(!fPSVIElemContext.fErrorOccurred)
  +                {
  +                    if(fPSVIElemContext.fCurrentTypeInfo != 0)
  +                    {
  +                        if(fPSVIElemContext.fCurrentTypeInfo->getAnonymous())
  +                            typeName = XMLUni::fgZeroLenString;
  +                        else 
  +                            typeName = 
fPSVIElemContext.fCurrentTypeInfo->getTypeLocalName();
  +                        typeURI = fPSVIElemContext.fCurrentTypeInfo->getTypeUri();
  +                    } 
  +                    else
  +                    {
  +                        DatatypeValidator *actualDV = 
(psviMemberType)?psviMemberType:fPSVIElemContext.fCurrentDV;
  +                        if(actualDV)
  +                        {
  +                            if(actualDV->getAnonymous())
  +                                typeName = XMLUni::fgZeroLenString;
  +                            else
  +                                typeName = actualDV->getTypeLocalName();
  +                            typeURI = actualDV->getTypeUri();
  +                        }
  +                    }
  +                }
  +                else 
  +                {
  +                    // idiosyncratically, if there's an
  +                    // error but this element was simpleType-validated,
  +                    // the tests demand anySimpleType be returned
  +                    if(fPSVIElemContext.fCurrentDV)
  +                        typeName = SchemaSymbols::fgDT_ANYSIMPLETYPE;
  +                }
  +                fDocHandler->elementTypeInfo(typeName, typeURI);
  +            }
  +            else 
  +            {
  +                fDocHandler->elementTypeInfo(XMLUni::fgZeroLenString, 
XMLUni::fgZeroLenString); 
  +            }
           }
   
           // reset xsi:type ComplexTypeInfo
  @@ -2970,6 +3074,8 @@
               fValidate = fElemStack.getValidationFlag();
           }
       }
  +    else    // not empty
  +        fErrorStack->push(fPSVIElemContext.fErrorOccurred);
   
       return true;
   }
  @@ -3408,9 +3514,6 @@
       // decrease element depth
       fPSVIElemContext.fElemDepth--;
   
  -    // reset error occurred
  -    fPSVIElemContext.fErrorOccurred = 
  -        fPSVIElemContext.fErrorOccurred && fErrorStack->pop();
   }
   
   void IGXMLScanner::resetPSVIElemContext()
  
  
  
  1.51      +35 -27    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.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- IGXMLScanner2.cpp 8 Dec 2003 00:11:26 -0000       1.50
  +++ IGXMLScanner2.cpp 14 Dec 2003 21:09:26 -0000      1.51
  @@ -270,10 +270,10 @@
                                   );
                                   if(fGrammarType == Grammar::SchemaGrammarType) {
                                       ((SchemaAttDef 
*)(attDef))->setValidity(PSVIDefs::INVALID);
  +                                    fPSVIElemContext.fErrorOccurred = true;
                                       if (getPSVIHandler())
                                       {
                                           attrValid = PSVIItem::VALIDITY_INVALID;
  -                                        fPSVIElemContext.fErrorOccurred = true;
                                       }                                
                                   }
                               }
  @@ -292,10 +292,10 @@
                                   );
                                   if(fGrammarType == Grammar::SchemaGrammarType) {
                                       ((SchemaAttDef 
*)(attDef))->setValidity(PSVIDefs::INVALID);
  +                                    fPSVIElemContext.fErrorOccurred = true;
                                       if (getPSVIHandler())
                                       {
                                           attrValid = PSVIItem::VALIDITY_INVALID;
  -                                        fPSVIElemContext.fErrorOccurred = true;
                                       }
                                   }
                               }
  @@ -390,7 +390,7 @@
                       ((SchemaAttDef *)(attDef))->setValidity(PSVIDefs::VALID);
                   ((SchemaAttDef *)(attDef))->setValidationAttempted(PSVIDefs::FULL);
               }
  -            if(getPSVIHandler() && fGrammarType == Grammar::SchemaGrammarType )
  +            if(fGrammarType == Grammar::SchemaGrammarType )
               {
                   // if we've found either an attDef or an attDefForWildCard,
                   // then we're doing full validation and it may still be valid.
  @@ -398,18 +398,24 @@
                   {
                       if(!laxThisOne && !skipThisOne)
                       {
  -                        attrValid = PSVIItem::VALIDITY_INVALID;
                           fPSVIElemContext.fErrorOccurred = true;
  -                    }
  -                    else if(laxThisOne)
  +                    } 
  +                    if(getPSVIHandler())
                       {
  -                        attrValid = PSVIItem::VALIDITY_NOTKNOWN;
  -                        attrAssessed = PSVIItem::VALIDATION_PARTIAL;
  -                    }
  -                    else
  -                    {
  -                        attrValid = PSVIItem::VALIDITY_NOTKNOWN;
  -                        attrAssessed = PSVIItem::VALIDATION_NONE;
  +                        if(!laxThisOne && !skipThisOne)
  +                        {
  +                            attrValid = PSVIItem::VALIDITY_INVALID;
  +                        }
  +                        else if(laxThisOne)
  +                        {
  +                            attrValid = PSVIItem::VALIDITY_NOTKNOWN;
  +                            attrAssessed = PSVIItem::VALIDATION_PARTIAL;
  +                        }
  +                        else
  +                        {
  +                            attrValid = PSVIItem::VALIDITY_NOTKNOWN;
  +                            attrAssessed = PSVIItem::VALIDATION_NONE;
  +                        }
                       }
                   }
               }
  @@ -487,10 +493,11 @@
                           , elemDecl
                       );
                       attrValidator = 
((SchemaValidator*)fValidator)->getMostRecentAttrValidator();
  -                    if(getPSVIHandler() && ((SchemaValidator 
*)fValidator)->getErrorOccurred())
  +                    if(((SchemaValidator *)fValidator)->getErrorOccurred())
                       {
                           fPSVIElemContext.fErrorOccurred = true;
  -                        attrValid = PSVIItem::VALIDITY_INVALID;
  +                        if(getPSVIHandler())
  +                            attrValid = PSVIItem::VALIDITY_INVALID;
                       }
                   }
                   else // no decl; default DOMTypeInfo to anySimpleType
  @@ -546,9 +553,12 @@
                           if(fGrammarType == Grammar::SchemaGrammarType)
                           {
                               attrValidator = 
((SchemaValidator*)fValidator)->getMostRecentAttrValidator();
  -                            if (getPSVIHandler()
  -                                && ((SchemaValidator 
*)fValidator)->getErrorOccurred())
  -                                attrValid = PSVIItem::VALIDITY_INVALID;
  +                            if(((SchemaValidator *)fValidator)->getErrorOccurred())
  +                            {
  +                                fPSVIElemContext.fErrorOccurred = true;
  +                                if (getPSVIHandler())
  +                                    attrValid = PSVIItem::VALIDITY_INVALID;
  +                            }
                           }
                       }
                       else if(fGrammarType == Grammar::SchemaGrammarType)
  @@ -889,6 +899,7 @@
                       {
                           ((SchemaAttDef *)(curDef))->setValidity(PSVIDefs::INVALID);
                           ((SchemaElementDecl 
*)elemDecl)->updateValidityFromAttribute((SchemaAttDef *)curDef);
  +                        fPSVIElemContext.fErrorOccurred = true;
                           if (getPSVIHandler())
                           {
                               QName *attQName = ((SchemaAttDef 
*)curDef)->getAttName();
  @@ -899,7 +910,6 @@
                                   fURIStringPool->getValueForId(attQName->getURI())
                               );
                               
prohibitedAttr->updateValidity(PSVIItem::VALIDITY_INVALID);
  -                            fPSVIElemContext.fErrorOccurred = true;
                           }
                       }
                   }
  @@ -1248,16 +1258,14 @@
       fSeeXsi = false;
   
       // Reset PSVI context
  -    if (fPSVIHandler)
  -    {
  -        if (!fPSVIElement)
  -            fPSVIElement = new (fMemoryManager) PSVIElement(fMemoryManager);
  +    // note that we always need this around for DOMTypeInfo
  +    if (!fPSVIElement)
  +        fPSVIElement = new (fMemoryManager) PSVIElement(fMemoryManager);
   
  -        if (!fErrorStack)
  -            fErrorStack = new (fMemoryManager) ValueStackOf<bool>(8, 
fMemoryManager);
  +    if (!fErrorStack)
  +        fErrorStack = new (fMemoryManager) ValueStackOf<bool>(8, fMemoryManager);
   
  -        resetPSVIElemContext();
  -    }
  +    resetPSVIElemContext();
   
       // Reset the validators
       fDTDValidator->reset();
  
  
  
  1.65      +142 -56   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.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- SGXMLScanner.cpp  10 Dec 2003 05:14:42 -0000      1.64
  +++ SGXMLScanner.cpp  14 Dec 2003 21:09:26 -0000      1.65
  @@ -941,6 +941,9 @@
       XMLElementDecl* tempElement = topElem->fThisElement;
       const XMLCh* rawNameBuf = fQNameBuf.getRawBuffer();
   
  +    // reset error occurred
  +    fPSVIElemContext.fErrorOccurred = fErrorStack->pop();
  +
       if ((topUri != uriId) ||
           (!XMLString::equals(tempElement->getBaseName(), &rawNameBuf[prefixColonPos 
+ 1])))
       {
  @@ -968,24 +971,24 @@
           );
       }
   
  -    if (fPSVIHandler)
  +    if (fValidate && topElem->fThisElement->isDeclared())
       {
  -        if (fValidate && topElem->fThisElement->isDeclared())
  +        fPSVIElemContext.fCurrentDV = ((SchemaValidator*) 
fValidator)->getCurrentDatatypeValidator();
  +        fPSVIElemContext.fCurrentTypeInfo = ((SchemaValidator*) 
fValidator)->getCurrentTypeInfo();
  +        if (fPSVIHandler)
           {
  -            fPSVIElemContext.fCurrentDV = ((SchemaValidator*) 
fValidator)->getCurrentDatatypeValidator();
  -            fPSVIElemContext.fCurrentTypeInfo = ((SchemaValidator*) 
fValidator)->getCurrentTypeInfo();
               fPSVIElemContext.fNormalizedValue = ((SchemaValidator*) 
fValidator)->getNormalizedValue();
   
               if (XMLString::equals(fPSVIElemContext.fNormalizedValue, 
XMLUni::fgZeroLenString))
                   fPSVIElemContext.fNormalizedValue = 0;
   
           }
  -        else
  -        {
  -            fPSVIElemContext.fCurrentDV = 0;
  -            fPSVIElemContext.fCurrentTypeInfo = 0;
  -            fPSVIElemContext.fNormalizedValue = 0;
  -        }
  +    }
  +    else
  +    {
  +        fPSVIElemContext.fCurrentDV = 0;
  +        fPSVIElemContext.fCurrentTypeInfo = 0;
  +        fPSVIElemContext.fNormalizedValue = 0;
       }
   
       //  If validation is enabled, then lets pass him the list of children and
  @@ -1036,14 +1039,12 @@
           }
   
           // update PSVI info
  +        if (((SchemaValidator*) fValidator)->getErrorOccurred())
  +            fPSVIElemContext.fErrorOccurred = true;
  +        else if (fPSVIElemContext.fCurrentDV && 
fPSVIElemContext.fCurrentDV->getType() == DatatypeValidator::Union)
  +            psviMemberType = fValidationContext->getValidatingMemberType();
           if (fPSVIHandler)
  -        {
               fPSVIElemContext.fIsSpecified = ((SchemaValidator*) 
fValidator)->getIsElemSpecified();
  -            if (((SchemaValidator*) fValidator)->getErrorOccurred())
  -                fPSVIElemContext.fErrorOccurred = true;
  -            else if (fPSVIElemContext.fCurrentDV && 
fPSVIElemContext.fCurrentDV->getType() == DatatypeValidator::Union)
  -                psviMemberType = fValidationContext->getValidatingMemberType();
  -        }
   
           // call matchers and de-activate context
           int oldCount = fMatcherStack->getMatcherCount();
  @@ -1116,13 +1117,52 @@
               , isRoot
               , fPrefixBuf.getRawBuffer()
           );
  +        // pass information about type info:
  +        const XMLCh *typeName = SchemaSymbols::fgATTVAL_ANYTYPE;
  +        const XMLCh *typeURI = SchemaSymbols::fgURI_SCHEMAFORSCHEMA; 
  +        if(!fPSVIElemContext.fErrorOccurred)
  +        {
  +            if(fPSVIElemContext.fCurrentTypeInfo != 0)
  +            {
  +                if(fPSVIElemContext.fCurrentTypeInfo->getAnonymous())
  +                    typeName = XMLUni::fgZeroLenString;
  +                else 
  +                    typeName = 
fPSVIElemContext.fCurrentTypeInfo->getTypeLocalName();
  +                typeURI = fPSVIElemContext.fCurrentTypeInfo->getTypeUri();
  +            } 
  +            else
  +            {
  +                DatatypeValidator *actualDV = 
(psviMemberType)?psviMemberType:fPSVIElemContext.fCurrentDV;
  +                if(actualDV)
  +                {
  +                    if(actualDV->getAnonymous())
  +                        typeName = XMLUni::fgZeroLenString;
  +                    else
  +                        typeName = actualDV->getTypeLocalName();
  +                    typeURI = actualDV->getTypeUri();
  +                }
  +            }
  +        }
  +        else 
  +        {
  +            // idiosyncratically, if there's an
  +            // error but this element was simpleType-validated,
  +            // the tests demand anySimpleType be returned
  +            if(fPSVIElemContext.fCurrentDV)
  +                typeName = SchemaSymbols::fgDT_ANYSIMPLETYPE;
  +        }
  +        fDocHandler->elementTypeInfo(typeName, typeURI);
       }
   
       // reset xsi:type ComplexTypeInfo    
       ((SchemaElementDecl*)topElem->fThisElement)->reset();
       if (!isRoot)
  +    {
           ((SchemaElementDecl*)(fElemStack.topElement()->fThisElement))->
               
setXsiComplexTypeInfo(((SchemaValidator*)fValidator)->getCurrentTypeInfo());
  +        // update error information
  +        fErrorStack->push(fErrorStack->pop() || fPSVIElemContext.fErrorOccurred);
  +    }
   
       // If this was the root, then done with content
       gotData = !isRoot;
  @@ -1508,6 +1548,8 @@
           }
       }
   
  +    // this info needed for DOMTypeInfo
  +    fPSVIElemContext.fErrorOccurred = false;
   
       //  We do something different here according to whether we found the
       //  element or not.
  @@ -1534,6 +1576,7 @@
                   , elemDecl->getFullName()
               );
               ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
  +            fPSVIElemContext.fErrorOccurred = true;
           }
       }
       else
  @@ -1550,6 +1593,7 @@
               if(elemDecl->getCreateReason() == XMLElementDecl::NoReason) {
                   ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
                   ((SchemaElementDecl 
*)(elemDecl))->setValidationAttempted(PSVIDefs::FULL);
  +                fPSVIElemContext.fErrorOccurred = true;
               }
               if (laxThisOne) {
                   fValidate = false;
  @@ -1589,8 +1633,6 @@
   
       if (fPSVIHandler)
       {
  -        fErrorStack->push(fPSVIElemContext.fErrorOccurred);
  -        fPSVIElemContext.fErrorOccurred = false;
           fPSVIElemContext.fElemDepth++;
   
           if (elemDecl->isDeclared())
  @@ -1601,8 +1643,12 @@
           {
               fPSVIElemContext.fFullValidationDepth = fPSVIElemContext.fElemDepth;
   
  +            /******
  +             * While we report an error for historical reasons, this should
  +             * actually result in lax assessment - NG.
               if (isRoot && fValidate)
                   fPSVIElemContext.fErrorOccurred = true;
  +            ******/
           }
       }
   
  @@ -1610,11 +1656,8 @@
       if (fValidate)
       {
           fValidator->validateElement(elemDecl);
  -        if (fPSVIHandler)
  -        {
  -            if (((SchemaValidator*) fValidator)->getErrorOccurred())
  -                fPSVIElemContext.fErrorOccurred = true;
  -        }
  +        if (((SchemaValidator*) fValidator)->getErrorOccurred())
  +            fPSVIElemContext.fErrorOccurred = true;
       }
   
       ComplexTypeInfo* typeinfo = (fValidate)
  @@ -1757,16 +1800,20 @@
           fElemStack.popTop();
   
           // reset current type info
  -        if (fPSVIHandler && fGrammarType == Grammar::SchemaGrammarType)
  +        DatatypeValidator* psviMemberType = 0;
  +        if (fGrammarType == Grammar::SchemaGrammarType)
           {
               if (fValidate && elemDecl->isDeclared())
               {
                   fPSVIElemContext.fCurrentDV = ((SchemaValidator*) 
fValidator)->getCurrentDatatypeValidator();
                   fPSVIElemContext.fCurrentTypeInfo = ((SchemaValidator*) 
fValidator)->getCurrentTypeInfo();
  -                fPSVIElemContext.fNormalizedValue = ((SchemaValidator*) 
fValidator)->getNormalizedValue();
  +                if(fPSVIHandler)
  +                {
  +                    fPSVIElemContext.fNormalizedValue = ((SchemaValidator*) 
fValidator)->getNormalizedValue();
   
  -                if (XMLString::equals(fPSVIElemContext.fNormalizedValue, 
XMLUni::fgZeroLenString))
  -                    fPSVIElemContext.fNormalizedValue = 0;
  +                    if (XMLString::equals(fPSVIElemContext.fNormalizedValue, 
XMLUni::fgZeroLenString))
  +                        fPSVIElemContext.fNormalizedValue = 0;
  +                }
               }
               else
               {
  @@ -1777,7 +1824,6 @@
           }
   
           // If validating, then insure that its legal to have no content
  -        DatatypeValidator* psviMemberType = 0;
           if (fValidate)
           {
               const int res = fValidator->checkContent(elemDecl, 0, 0);
  @@ -1794,13 +1840,15 @@
                   ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
               }
   
  -            if (fPSVIHandler)
  +            if (((SchemaValidator*) fValidator)->getErrorOccurred())
  +                fPSVIElemContext.fErrorOccurred = true;
  +            // note that if we're empty, won't be a current DV
  +            else 
               {
  -                if (((SchemaValidator*) fValidator)->getErrorOccurred())
  -                    fPSVIElemContext.fErrorOccurred = true;
  -                // note that if we're empty, won't be a current DV
  -                else if (fPSVIElemContext.fCurrentDV && 
fPSVIElemContext.fCurrentDV->getType() == DatatypeValidator::Union)
  -                        psviMemberType = 
fValidationContext->getValidatingMemberType();
  +                if (fPSVIHandler)
  +                    fPSVIElemContext.fIsSpecified = ((SchemaValidator*) 
fValidator)->getIsElemSpecified();
  +                if (fPSVIElemContext.fCurrentDV && 
fPSVIElemContext.fCurrentDV->getType() == DatatypeValidator::Union)
  +                    psviMemberType = fValidationContext->getValidatingMemberType(); 
               }
   
               // call matchers and de-activate context
  @@ -1870,6 +1918,41 @@
                   , isRoot
                   , fPrefixBuf.getRawBuffer()
               );
  +            // pass information about type info:
  +            const XMLCh *typeName = SchemaSymbols::fgATTVAL_ANYTYPE;
  +            const XMLCh *typeURI = SchemaSymbols::fgURI_SCHEMAFORSCHEMA; 
  +            if(!fPSVIElemContext.fErrorOccurred)
  +            {
  +                if(fPSVIElemContext.fCurrentTypeInfo != 0)
  +                {
  +                    if(fPSVIElemContext.fCurrentTypeInfo->getAnonymous())
  +                        typeName = XMLUni::fgZeroLenString;
  +                    else 
  +                        typeName = 
fPSVIElemContext.fCurrentTypeInfo->getTypeLocalName();
  +                    typeURI = fPSVIElemContext.fCurrentTypeInfo->getTypeUri();
  +                } 
  +                else
  +                {
  +                    DatatypeValidator *actualDV = 
(psviMemberType)?psviMemberType:fPSVIElemContext.fCurrentDV;
  +                    if(actualDV)
  +                    {
  +                        if(actualDV->getAnonymous())
  +                            typeName = XMLUni::fgZeroLenString;
  +                        else
  +                            typeName = actualDV->getTypeLocalName();
  +                        typeURI = actualDV->getTypeUri();
  +                    }
  +                }
  +            }
  +            else 
  +            {
  +                // idiosyncratically, if there's an
  +                // error but this element was simpleType-validated,
  +                // the tests demand anySimpleType be returned
  +                if(fPSVIElemContext.fCurrentDV)
  +                    typeName = SchemaSymbols::fgDT_ANYSIMPLETYPE;
  +            }
  +            fDocHandler->elementTypeInfo(typeName, typeURI);
           }
   
           // reset xsi:type ComplexTypeInfo        
  @@ -1892,6 +1975,8 @@
               fValidate = fElemStack.getValidationFlag();
           }
       }
  +    else    // not empty
  +        fErrorStack->push(fPSVIElemContext.fErrorOccurred);
   
       return true;
   }
  @@ -2329,10 +2414,10 @@
                                       , attDef->getFullName()
                                   );
                                   ((SchemaAttDef 
*)(attDef))->setValidity(PSVIDefs::INVALID);
  +                                fPSVIElemContext.fErrorOccurred = true;
                                   if (getPSVIHandler())
                                   {
                                       attrValid = PSVIItem::VALIDITY_INVALID;
  -                                    fPSVIElemContext.fErrorOccurred = true;
                                   }
                               }
                           }
  @@ -2348,10 +2433,10 @@
                                       , attDef->getFullName()
                                   );
                                   ((SchemaAttDef 
*)(attDef))->setValidity(PSVIDefs::INVALID);
  +                                fPSVIElemContext.fErrorOccurred = true;
                                   if (getPSVIHandler())
                                   {
                                       attrValid = PSVIItem::VALIDITY_INVALID;
  -                                    fPSVIElemContext.fErrorOccurred = true;
                                   }
                               }
                           }
  @@ -2420,16 +2505,19 @@
                   ((SchemaAttDef *)(attDef))->setValidationAttempted(PSVIDefs::FULL);
               }
   
  -            if(getPSVIHandler())
  +            // if we've found either an attDef or an attDefForWildCard,
  +            // then we're doing full validation and it may still be valid.
  +            if(!attDef && !attDefForWildCard)
               {
  -                // if we've found either an attDef or an attDefForWildCard,
  -                // then we're doing full validation and it may still be valid.
  -                if(!attDef && !attDefForWildCard)
  +                if(!laxThisOne && !skipThisOne)
  +                {
  +                    fPSVIElemContext.fErrorOccurred = true;
  +                } 
  +                if(getPSVIHandler())
                   {
                       if(!laxThisOne && !skipThisOne)
                       {
                           attrValid = PSVIItem::VALIDITY_INVALID;
  -                        fPSVIElemContext.fErrorOccurred = true;
                       }
                       else if(laxThisOne)
                       {
  @@ -2516,10 +2604,11 @@
                           , elemDecl
                       );
                       attrValidator = ((SchemaValidator 
*)fValidator)->getMostRecentAttrValidator();
  -                    if(getPSVIHandler() && ((SchemaValidator 
*)fValidator)->getErrorOccurred())
  +                    if(((SchemaValidator *)fValidator)->getErrorOccurred())
                       {
  -                        attrValid = PSVIItem::VALIDITY_INVALID;
                           fPSVIElemContext.fErrorOccurred = true;
  +                        if(getPSVIHandler())
  +                            attrValid = PSVIItem::VALIDITY_INVALID;
                       }
                   }
                   else // no decl; default DOMTypeInfo to anySimpleType
  @@ -2571,10 +2660,11 @@
                               , elemDecl
                           );
                           attrValidator = ((SchemaValidator 
*)fValidator)->getMostRecentAttrValidator();
  -                        if(getPSVIHandler() && ((SchemaValidator 
*)fValidator)->getErrorOccurred())
  +                        if(((SchemaValidator *)fValidator)->getErrorOccurred())
                           {
  -                            attrValid = PSVIItem::VALIDITY_INVALID;
                               fPSVIElemContext.fErrorOccurred = true;
  +                            if(getPSVIHandler())
  +                                attrValid = PSVIItem::VALIDITY_INVALID;
                           }
                       }
                       else
  @@ -2867,6 +2957,7 @@
                           , curDef->getFullName()
                       );
                       ((SchemaAttDef *)curDef)->setValidity(PSVIDefs::INVALID);       
  
  +                    fPSVIElemContext.fErrorOccurred = true;
                       if (getPSVIHandler())
                       {
                           QName *attQName = ((SchemaAttDef *)curDef)->getAttName();
  @@ -3209,16 +3300,14 @@
       fDoSchema = true;
   
       // Reset PSVI context
  -    if (fPSVIHandler)
  -    {
  -        if (!fPSVIElement)
  -            fPSVIElement = new (fMemoryManager) PSVIElement(fMemoryManager);
  +    // Note that we always need this around for DOMTypeInfo
  +    if (!fPSVIElement)
  +        fPSVIElement = new (fMemoryManager) PSVIElement(fMemoryManager);
   
  -        if (!fErrorStack)
  -            fErrorStack = new (fMemoryManager) ValueStackOf<bool>(8, 
fMemoryManager);
  +    if (!fErrorStack)
  +        fErrorStack = new (fMemoryManager) ValueStackOf<bool>(8, fMemoryManager);
   
  -        resetPSVIElemContext();
  -    }
  +    resetPSVIElemContext();
   
       // Reset the validators
       fSchemaValidator->reset();
  @@ -4833,9 +4922,6 @@
       // decrease element depth
       fPSVIElemContext.fElemDepth--;
   
  -    // reset error occurred
  -    fPSVIElemContext.fErrorOccurred = 
  -        fPSVIElemContext.fErrorOccurred && fErrorStack->pop();
   }
   
   void SGXMLScanner::resetPSVIElemContext()
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to