You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2002/04/19 15:33:23 UTC

cvs commit: xml-xerces/c/src/xercesc/validators/schema SchemaValidator.cpp SchemaValidator.hpp

knoaman     02/04/19 06:33:23

  Modified:    c/src/xercesc/internal XMLScanner.cpp
               c/src/xercesc/validators/schema SchemaValidator.cpp
                        SchemaValidator.hpp
  Log:
  Fix for bug 8236.
  
  Revision  Changes    Path
  1.4       +4 -1      xml-xerces/c/src/xercesc/internal/XMLScanner.cpp
  
  Index: XMLScanner.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XMLScanner.cpp	1 Apr 2002 16:43:14 -0000	1.3
  +++ XMLScanner.cpp	19 Apr 2002 13:33:23 -0000	1.4
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XMLScanner.cpp,v 1.3 2002/04/01 16:43:14 knoaman Exp $
  + * $Id: XMLScanner.cpp,v 1.4 2002/04/19 13:33:23 knoaman Exp $
    */
   
   
  @@ -3283,6 +3283,9 @@
                   );
               }
           }
  +
  +        if (fGrammarType == Grammar::SchemaGrammarType)
  +            ((SchemaElementDecl*)elemDecl)->setXsiComplexTypeInfo(0);
       }
   
       //
  
  
  
  1.9       +20 -8     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SchemaValidator.cpp	1 Apr 2002 20:17:55 -0000	1.8
  +++ SchemaValidator.cpp	19 Apr 2002 13:33:23 -0000	1.9
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: SchemaValidator.cpp,v $
  + * Revision 1.9  2002/04/19 13:33:23  knoaman
  + * Fix for bug 8236.
  + *
    * Revision 1.8  2002/04/01 20:17:55  peiyongz
    * Bug#7551: Exceptions are caught by value, rather than by reference
    *
  @@ -194,12 +197,15 @@
       , fXsiType(0)
       , fXsiTypeValidator(0)
       , fNil(false)
  +    , fTypeStack(0)
   {
  +    fTypeStack = new ValueStackOf<ComplexTypeInfo*>(8);
   }
   
   SchemaValidator::~SchemaValidator()
   {
       delete fXsiType;
  +    delete fTypeStack;
   }
   
   // ---------------------------------------------------------------------------
  @@ -216,6 +222,8 @@
       if (!elemDecl)
           ThrowXML(RuntimeException, XMLExcepts::Val_InvalidElemId);
   
  +    ((SchemaElementDecl*) elemDecl)->setXsiComplexTypeInfo(fTypeStack->pop());
  +
       //
       //  Get the content spec type of this element. This will tell us what
       //  to do to validate it.
  @@ -498,6 +506,9 @@
   
   void SchemaValidator::validateElement(const   XMLElementDecl*  elemDef)
   {
  +    ComplexTypeInfo* elemTypeInfo = ((SchemaElementDecl*)elemDef)->getComplexTypeInfo();
  +    fTypeStack->push(elemTypeInfo);
  +
       if (fXsiType) {
           // handle "xsi:type" right here
           unsigned int uri = fXsiType->getURI();
  @@ -572,7 +583,8 @@
                           ComplexTypeInfo* destType = ((SchemaElementDecl*)elemDef)->getComplexTypeInfo();
                           ComplexTypeInfo* tempType = typeInfo;
                           if (destType) {
  -                            while (tempType) {
  +
  +                            while (tempType) {                                 
                                   if (!XMLString::compareString(tempType->getTypeName(), destType->getTypeName()))
                                       break;
                                   tempType = tempType->getBaseComplexTypeInfo();
  @@ -599,8 +611,12 @@
                               }
                           }
   
  -                        if (!error)
  +                        if (!error) {
  +
                               ((SchemaElementDecl*)elemDef)->setXsiComplexTypeInfo(typeInfo);
  +                            fTypeStack->pop();
  +                            fTypeStack->push(typeInfo);
  +                        }
                       }
                       else {
                           // typeInfo not found
  @@ -640,12 +656,8 @@
           // xsi:type was not specified...
           // If the corresponding type is abstract, detect an error
           //
  -        ComplexTypeInfo* typeInfo = ((SchemaElementDecl*)elemDef)->getComplexTypeInfo();
  -
  -        if (typeInfo) {
  -            if (typeInfo->getAbstract()) {
  -                emitError(XMLValid::NoUseAbstractType, elemDef->getFullName());
  -            }
  +        if (elemTypeInfo && elemTypeInfo->getAbstract()) {
  +            emitError(XMLValid::NoUseAbstractType, elemDef->getFullName());
           }
       }
   
  
  
  
  1.4       +8 -0      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SchemaValidator.hpp	1 Apr 2002 15:47:06 -0000	1.3
  +++ SchemaValidator.hpp	19 Apr 2002 13:33:23 -0000	1.4
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: SchemaValidator.hpp,v $
  + * Revision 1.4  2002/04/19 13:33:23  knoaman
  + * Fix for bug 8236.
  + *
    * Revision 1.3  2002/04/01 15:47:06  knoaman
    * Move Element Consistency checking (ref to global declarations) to SchemaValidator.
    *
  @@ -99,6 +102,7 @@
   #include <xercesc/framework/XMLBuffer.hpp>
   #include <xercesc/framework/XMLValidator.hpp>
   #include <xercesc/util/RefVectorOf.hpp>
  +#include <xercesc/util/ValueStackOf.hpp>
   #include <xercesc/validators/common/GrammarResolver.hpp>
   #include <xercesc/validators/common/ContentSpecNode.hpp>
   #include <xercesc/validators/datatype/DatatypeValidator.hpp>
  @@ -308,6 +312,9 @@
       //
       //  fSchemaErrorReporter
       //      Report schema process errors
  +    //
  +    //  fTypeStack
  +    //      Stack of complex type declarations. 
       // -----------------------------------------------------------------------
       SchemaGrammar* fSchemaGrammar;
       GrammarResolver* fGrammarResolver;
  @@ -319,6 +326,7 @@
       XMLBuffer fDatatypeBuffer;
       bool fTrailing;
       XSDErrorReporter fSchemaErrorReporter;
  +    ValueStackOf<ComplexTypeInfo*>* fTypeStack;
   };
   
   
  
  
  

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