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/01 17:47:06 UTC

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

knoaman     02/04/01 07:47:06

  Modified:    c/src/xercesc/validators/schema ComplexTypeInfo.hpp
                        SchemaElementDecl.hpp SchemaValidator.cpp
                        SchemaValidator.hpp TraverseSchema.cpp
                        TraverseSchema.hpp XercesGroupInfo.cpp
                        XercesGroupInfo.hpp
  Log:
  Move Element Consistency checking (ref to global declarations) to SchemaValidator.
  
  Revision  Changes    Path
  1.4       +4 -1      xml-xerces/c/src/xercesc/validators/schema/ComplexTypeInfo.hpp
  
  Index: ComplexTypeInfo.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/ComplexTypeInfo.hpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ComplexTypeInfo.hpp	21 Mar 2002 15:34:40 -0000	1.3
  +++ ComplexTypeInfo.hpp	1 Apr 2002 15:47:06 -0000	1.4
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: ComplexTypeInfo.hpp,v 1.3 2002/03/21 15:34:40 knoaman Exp $
  + * $Id: ComplexTypeInfo.hpp,v 1.4 2002/04/01 15:47:06 knoaman Exp $
    */
   
   #if !defined(COMPLEXTYPEINFO_HPP)
  @@ -463,6 +463,9 @@
   
       if (!fElements) {
           fElements = new RefVectorOf<SchemaElementDecl>(8, false);
  +    }
  +    else if (fElements->containsElement(elem)) {
  +        return;
       }
   
       fElements->addElement(elem);
  
  
  
  1.5       +9 -0      xml-xerces/c/src/xercesc/validators/schema/SchemaElementDecl.hpp
  
  Index: SchemaElementDecl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaElementDecl.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SchemaElementDecl.hpp	21 Mar 2002 16:31:43 -0000	1.4
  +++ SchemaElementDecl.hpp	1 Apr 2002 15:47:06 -0000	1.5
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: SchemaElementDecl.hpp,v $
  + * Revision 1.5  2002/04/01 15:47:06  knoaman
  + * Move Element Consistency checking (ref to global declarations) to SchemaValidator.
  + *
    * Revision 1.4  2002/03/21 16:31:43  knoaman
    * Remove data/methods from SchemaElementDecl that are not used.
    *
  @@ -223,6 +226,7 @@
       XMLCh* getDefaultValue() const;
       XMLCh* getSubstitutionGroupName() const;
       ComplexTypeInfo* getComplexTypeInfo() const;
  +    virtual bool isGlobalDecl() const;
   
   
       // -----------------------------------------------------------------------
  @@ -459,6 +463,11 @@
       }
   
       return fAttWildCard;
  +}
  +
  +inline bool SchemaElementDecl::isGlobalDecl() const {
  +
  +    return (fEnclosingScope == Grammar::TOP_LEVEL_SCOPE);
   }
   
   // ---------------------------------------------------------------------------
  
  
  
  1.7       +63 -0     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SchemaValidator.cpp	25 Mar 2002 20:25:32 -0000	1.6
  +++ SchemaValidator.cpp	1 Apr 2002 15:47:06 -0000	1.7
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: SchemaValidator.cpp,v $
  + * Revision 1.7  2002/04/01 15:47:06  knoaman
  + * Move Element Consistency checking (ref to global declarations) to SchemaValidator.
  + *
    * Revision 1.6  2002/03/25 20:25:32  knoaman
    * Move particle derivation checking from TraverseSchema to SchemaValidator.
    *
  @@ -833,6 +836,7 @@
                   ComplexTypeInfo& curTypeInfo = complexTypeEnum.nextElement();
                   curTypeInfo.checkUniqueParticleAttribution(&sGrammar, fGrammarResolver, getScanner()->getURIStringPool(), this);
                   checkParticleDerivation(&sGrammar, &curTypeInfo);
  +                checkRefElementConsistency(&sGrammar, &curTypeInfo);
               }
   
               RefHashTableOf<XercesGroupInfo>* groupInfoRegistry = sGrammar.getGroupInfoRegistry();
  @@ -852,6 +856,9 @@
                           fSchemaErrorReporter.emitError(XMLErrs::DisplayErrorMessage, XMLUni::fgXMLErrDomain, curGroup.getLocator(), excep.getMessage());
   					}
                   }
  +
  +                if (curGroup.getCheckElementConsistency())
  +                    checkRefElementConsistency(&sGrammar, 0, &curGroup);
               }
           }
       }
  @@ -961,6 +968,62 @@
       fDatatypeBuffer.append(toFill.getRawBuffer());
   }
   
  +
  +// ---------------------------------------------------------------------------
  +//  SchemaValidator: Particle Derivation Checking
  +// ---------------------------------------------------------------------------
  +void SchemaValidator::checkRefElementConsistency(SchemaGrammar* const currentGrammar,
  +                                                 const ComplexTypeInfo* const curTypeInfo,
  +                                                 const XercesGroupInfo* const curGroup) {
  +
  +    unsigned int elemCount = (curTypeInfo) ? curTypeInfo->elementCount() : curGroup->elementCount();
  +    int elemScope = (curTypeInfo) ? curTypeInfo->getScopeDefined() : curGroup->getScope();
  +    XSDLocator* typeInfoLocator = (curTypeInfo) ? curTypeInfo->getLocator() : curGroup->getLocator();
  +
  +    for (unsigned int i=0; i < elemCount; i++) {
  +
  +        const SchemaElementDecl* elemDecl = (curTypeInfo) ? curTypeInfo->elementAt(i) : curGroup->elementAt(i);
  +
  +        if (elemDecl->isGlobalDecl()) {
  +
  +            unsigned int elemURI = elemDecl->getURI();
  +            const XMLCh* elemName = elemDecl->getBaseName();
  +            const SchemaElementDecl* other = (SchemaElementDecl*)
  +                currentGrammar->getElemDecl(elemURI, elemName, 0, elemScope);
  +
  +            if (other
  +                && (elemDecl->getComplexTypeInfo() != other->getComplexTypeInfo() ||
  +                    elemDecl->getDatatypeValidator() != other->getDatatypeValidator())) {
  +                fSchemaErrorReporter.emitError(XMLErrs::DuplicateElementDeclaration,
  +                                               XMLUni::fgXMLErrDomain, typeInfoLocator, elemName);
  +                continue;
  +            }
  +
  +            RefHash2KeysTableOf<ElemVector>* validSubsGroups = currentGrammar->getValidSubstitutionGroups();
  +            ValueVectorOf<SchemaElementDecl*>* subsElements = validSubsGroups->get(elemName, elemURI);
  +
  +            if (subsElements) {
  +
  +                unsigned subsElemSize = subsElements->size();
  +
  +                for (unsigned int j=0; j < subsElemSize; j++) {
  +
  +                    SchemaElementDecl* subsElem = subsElements->elementAt(j);
  +                    const XMLCh* subsElemName = subsElem->getBaseName();
  +                    other = (SchemaElementDecl*)
  +                        currentGrammar->getElemDecl(subsElem->getURI(), subsElemName, 0, elemScope);
  +
  +                    if (other
  +                        && (subsElem->getComplexTypeInfo() != other->getComplexTypeInfo()
  +                            || subsElem->getDatatypeValidator() != other->getDatatypeValidator())) {
  +                        fSchemaErrorReporter.emitError(XMLErrs::DuplicateElementDeclaration,
  +                                                       XMLUni::fgXMLErrDomain, typeInfoLocator, elemName);
  +                    }
  +                }
  +            }
  +        }
  +    }
  +}
   
   // ---------------------------------------------------------------------------
   //  SchemaValidator: Particle Derivation Checking
  
  
  
  1.3       +14 -4     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SchemaValidator.hpp	25 Mar 2002 20:25:32 -0000	1.2
  +++ SchemaValidator.hpp	1 Apr 2002 15:47:06 -0000	1.3
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: SchemaValidator.hpp,v $
  + * Revision 1.3  2002/04/01 15:47:06  knoaman
  + * Move Element Consistency checking (ref to global declarations) to SchemaValidator.
  + *
    * Revision 1.2  2002/03/25 20:25:32  knoaman
    * Move particle derivation checking from TraverseSchema to SchemaValidator.
    *
  @@ -128,6 +131,8 @@
          , const unsigned int        uriId);
   
       void setNillable(bool isNil);
  +    void setErrorHandler(ErrorHandler* const handler);
  +    void setExitOnFirstFatal(const bool newValue);
   
       // -----------------------------------------------------------------------
       //  Implementation of the XMLValidator interface
  @@ -182,6 +187,15 @@
       // -----------------------------------------------------------------------
       void normalizeWhiteSpace(DatatypeValidator* dV, const XMLCh* const value, XMLBuffer& toFill);
   
  +
  +private:
  +    // -----------------------------------------------------------------------
  +    //  Element Consitency Checking methods
  +    // -----------------------------------------------------------------------
  +    void checkRefElementConsistency(SchemaGrammar* const currentGrammar,
  +                                    const ComplexTypeInfo* const curTypeInfo,
  +                                    const XercesGroupInfo* const curGroup = 0);
  +
       // -----------------------------------------------------------------------
       //  Particle Derivation Checking methods
       // -----------------------------------------------------------------------
  @@ -264,10 +278,6 @@
                           const int baseScope,
                           const ComplexTypeInfo* const baseInfo);
   
  -    void setErrorHandler(ErrorHandler* const handler);
  -    void setExitOnFirstFatal(const bool newValue);
  -
  -private:
       // -----------------------------------------------------------------------
       //  Private data members
       //
  
  
  
  1.13      +80 -181   xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp
  
  Index: TraverseSchema.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- TraverseSchema.cpp	26 Mar 2002 14:20:14 -0000	1.12
  +++ TraverseSchema.cpp	1 Apr 2002 15:47:06 -0000	1.13
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: TraverseSchema.cpp,v 1.12 2002/03/26 14:20:14 knoaman Exp $
  + * $Id: TraverseSchema.cpp,v 1.13 2002/04/01 15:47:06 knoaman Exp $
    */
   
   // ---------------------------------------------------------------------------
  @@ -225,15 +225,12 @@
       , fIdentityConstraintNames(0)
       , fSubstitutionGroups(0)
       , fValidSubstitutionGroups(0)
  -    , fRefElements(0)
  -    , fRefElemScope(0)
       , fIC_NodeListNS(0)
       , fIC_ElementsNS(0)
       , fIC_NamespaceDepthNS(0)
       , fParser(0)
       , fPreprocessedNodes(0)
       , fLocator(0)
  -    , fRefElemLocators(0)    
   {
   
       try {
  @@ -264,14 +261,6 @@
   // ---------------------------------------------------------------------------
   void TraverseSchema::doTraverseSchema(const IDOM_Element* const schemaRoot) {
   
  -    // initialize
  -    if (fFullConstraintChecking) {
  -
  -        fRefElements = new RefVectorOf<QName>(32);
  -        fRefElemScope = new ValueVectorOf<int>(32);
  -        fRefElemLocators = new RefVectorOf<XSDLocator>(32);
  -    }
  -
       // process children nodes
       processChildren(schemaRoot);
   
  @@ -295,11 +284,6 @@
               }
           }
       }
  -
  -    // Element consistency checks - substitution groups
  -    if (fFullConstraintChecking) {
  -        checkRefElementConsistency();
  -    }
   }
   
   void TraverseSchema::preprocessSchema(IDOM_Element* const schemaRoot,
  @@ -772,9 +756,6 @@
           // Traverse new schema
           // --------------------------------------------------------
           SchemaInfo* saveInfo = fSchemaInfo;
  -        Janitor<RefVectorOf<QName> > janElem(fRefElements);
  -        Janitor<ValueVectorOf<int> > janElemScope(fRefElemScope);
  -        Janitor<RefVectorOf<XSDLocator> > janElemLocators(fRefElemLocators);
   
           restoreSchemaInfo(importInfo, SchemaInfo::IMPORT);
           doTraverseSchema(importInfo->getRoot());
  @@ -783,21 +764,6 @@
           // Restore old schema information
           // --------------------------------------------------------
           restoreSchemaInfo(saveInfo, SchemaInfo::IMPORT);
  -
  -        // reset fRefElements && fRefElemScope
  -        if (fFullConstraintChecking) {
  -
  -            RefVectorOf<QName>* tmpElems = fRefElements;
  -            ValueVectorOf<int>* tmpElemScope = fRefElemScope;
  -            RefVectorOf<XSDLocator>* tmpElemLocators = fRefElemLocators;
  -
  -            fRefElements = janElem.release();
  -            fRefElemScope = janElemScope.release();
  -            fRefElemLocators = janElemLocators.release();
  -            janElem.reset(tmpElems);
  -            janElemScope.reset(tmpElemScope);
  -            janElemLocators.reset(tmpElemLocators);
  -        }
       }
   }
   
  @@ -910,19 +876,13 @@
   
           if (!XMLString::compareString(childName, SchemaSymbols::fgELT_ELEMENT)) {
   
  -            bool toDelete = true;
  -            Janitor<QName> janQName(0);
  -            QName* eltQName = traverseElementDecl(child, toDelete);
  +            QName* eltQName = traverseElementDecl(child);
   
               if (eltQName == 0) {
                   continue;
               }
  -			
  -            if (toDelete) {
  -                janQName.reset(eltQName);
  -            }
   
  -            contentSpecNode = new ContentSpecNode(eltQName);
  +            contentSpecNode = new ContentSpecNode(eltQName, false);
               seeParticle = true;
           }
           else if (!XMLString::compareString(childName, SchemaSymbols::fgELT_GROUP)) {
  @@ -1444,22 +1404,20 @@
       fCurrentGroupInfo = saveGroupInfo;
       fCurrentScope = saveScope;
   
  -    if (fFullConstraintChecking && fRedefineComponents &&
  -        fRedefineComponents->get(SchemaSymbols::fgELT_GROUP, nameIndex)) {
  -
  -        fBuffer.set(fullName);
  -        fBuffer.append(SchemaSymbols::fgRedefIdentifier);
  -        XercesGroupInfo* baseGroupInfo = fGroupRegistry->get(fBuffer.getRawBuffer());
  +    if (fFullConstraintChecking) {
   
  -        if (baseGroupInfo) {
  +        XSDLocator* aLocator = new XSDLocator();
   
  -            XSDLocator* aLocator = new XSDLocator();
  -            aLocator->setValues(fStringPool->getValueForId(fStringPool->addOrFind(fSchemaInfo->getCurrentSchemaURL())),
  -                                0, ((XSDElementNSImpl*) elem)->getLineNo(),
  -                                ((XSDElementNSImpl*) elem)->getColumnNo());
  +        groupInfo->setLocator(aLocator);
  +        aLocator->setValues(fStringPool->getValueForId(fStringPool->addOrFind(fSchemaInfo->getCurrentSchemaURL())),
  +                            0, ((XSDElementNSImpl*) elem)->getLineNo(),
  +                            ((XSDElementNSImpl*) elem)->getColumnNo());
  +		
  +        if (fRedefineComponents && fRedefineComponents->get(SchemaSymbols::fgELT_GROUP, nameIndex)) {
   
  -            groupInfo->setBaseGroup(baseGroupInfo);
  -            groupInfo->setLocator(aLocator);
  +            fBuffer.set(fullName);
  +            fBuffer.append(SchemaSymbols::fgRedefIdentifier);
  +            groupInfo->setBaseGroup(fGroupRegistry->get(fBuffer.getRawBuffer()));            
           }
       }
   
  @@ -1795,19 +1753,13 @@
   
           if (!XMLString::compareString(childName, SchemaSymbols::fgELT_ELEMENT)) {
   
  -            bool toDelete = true;
  -            Janitor<QName> janQName(0);
  -            QName* eltQName = traverseElementDecl(child, toDelete);
  +            QName* eltQName = traverseElementDecl(child);
   
               if (eltQName == 0) {
                   continue;
               }
   
  -            if (toDelete) {
  -                janQName.reset(eltQName);
  -            }
  -
  -            contentSpecNode = new ContentSpecNode(eltQName);
  +            contentSpecNode = new ContentSpecNode(eltQName, false);
               checkMinMax(contentSpecNode, child, All_Element);
           }
           else {
  @@ -2217,7 +2169,7 @@
     *
     * @param elem:  the declaration of the element under consideration
     */
  -QName* TraverseSchema::traverseElementDecl(const IDOM_Element* const elem, bool& toDelete,
  +QName* TraverseSchema::traverseElementDecl(const IDOM_Element* const elem,
                                              const bool topLevel) {
   
       const XMLCh* name = getElementAttValue(elem, SchemaSymbols::fgATT_NAME);
  @@ -2262,7 +2214,7 @@
               reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::BadAttWithRef);
           }
   
  -        return processElementDeclRef(elem, ref, toDelete);
  +        return processElementDeclRef(elem, ref);
       }
   
       // Name is notEmpty
  @@ -4197,8 +4149,7 @@
                   }
               }
   
  -            bool toDelete = true;
  -            QName* elmQName = traverseElementDecl(child, toDelete, true);
  +            QName* elmQName = traverseElementDecl(child, true);
               delete elmQName;
           }
           else if (!XMLString::compareString(name, SchemaSymbols::fgELT_ATTRIBUTEGROUP)) {
  @@ -4496,8 +4447,7 @@
   
   
   QName* TraverseSchema::processElementDeclRef(const IDOM_Element* const elem,
  -                                             const XMLCh* const refName,
  -                                             bool& toDelete) {
  +                                             const XMLCh* const refName) {
   
       IDOM_Element* content = checkContent(elem, XUtil::getFirstChildElement(elem), true);
   
  @@ -4510,7 +4460,7 @@
       const XMLCh* uriStr = resolvePrefixToURI(elem, prefix);
       QName*       eltName = new QName(prefix , localPart, uriStr != 0
                                          ? fURIStringPool->addOrFind(uriStr)
  -                                       : fEmptyNamespaceURI); // StringPool.EMPTY_STRING == 0
  +                                       : fEmptyNamespaceURI);
   
       //if from another schema, just return the element QName
       if (XMLString::compareString(uriStr, fTargetNSURIString) != 0) {
  @@ -4535,22 +4485,23 @@
           }
           else {
   
  +            delete eltName;
  +            eltName = traverseElementDecl(targetElem, true);
  +            refElemDecl = (SchemaElementDecl*)
  +                fSchemaGrammar->getElemDecl(uriID, localPart, 0, Grammar::TOP_LEVEL_SCOPE);
  +
               // restore schema information
               fSchemaInfo = saveInfo;
           }
       }
   
  -    if (fFullConstraintChecking) {
  +    if (fFullConstraintChecking && refElemDecl) {
   
  -        XSDLocator* aLocator = new XSDLocator();
  +        if (fCurrentComplexType)
  +            fCurrentComplexType->addElement(refElemDecl);
   
  -        toDelete = false;
  -        aLocator->setValues(fStringPool->getValueForId(fStringPool->addOrFind(fSchemaInfo->getCurrentSchemaURL())),
  -                            0, ((XSDElementNSImpl*) elem)->getLineNo(),
  -                            ((XSDElementNSImpl*) elem)->getColumnNo());
  -        fRefElements->addElement(eltName);
  -        fRefElemScope->addElement(fCurrentScope);
  -        fRefElemLocators->addElement(aLocator);
  +        if (fCurrentGroupInfo)
  +            fCurrentGroupInfo->addElement(refElemDecl);
       }
   
       return eltName;
  @@ -4949,8 +4900,7 @@
   
           if (subsGroupElem != 0) {
   
  -            bool toDelete = true;
  -            QName* subsGroupQName = traverseElementDecl(subsGroupElem, toDelete, true);
  +            QName* subsGroupQName = traverseElementDecl(subsGroupElem, true);
               Janitor<QName> janQName(subsGroupQName);
   
               if (subsGroupQName) {
  @@ -6244,56 +6194,6 @@
       }
   }
   
  -void TraverseSchema::checkRefElementConsistency() {
  -
  -    unsigned int refElemSize = fRefElements->size();
  -
  -    for (unsigned int i=0; i < refElemSize; i++) {
  -
  -        int elemScope = fRefElemScope->elementAt(i);
  -        QName* elemQName = fRefElements->elementAt(i);
  -        XSDLocator* elemLocator = fRefElemLocators->elementAt(i);
  -        unsigned int elemURI = elemQName->getURI();
  -        const XMLCh* elemName = elemQName->getLocalPart();
  -        const SchemaElementDecl* elemDecl = (SchemaElementDecl*)
  -            fSchemaGrammar->getElemDecl(elemURI, elemName, 0, Grammar::TOP_LEVEL_SCOPE);
  -
  -        if (elemDecl) {
  -
  -            const SchemaElementDecl* other = (SchemaElementDecl*)
  -                fSchemaGrammar->getElemDecl(elemURI, elemName, 0, elemScope);
  -
  -            if (other
  -                && (elemDecl->getComplexTypeInfo() != other->getComplexTypeInfo() ||
  -                    elemDecl->getDatatypeValidator() != other->getDatatypeValidator())) {
  -                reportSchemaError(elemLocator, XMLUni::fgXMLErrDomain, XMLErrs::DuplicateElementDeclaration, elemName);
  -                continue;
  -            }
  -
  -            ValueVectorOf<SchemaElementDecl*>* subsElements = fValidSubstitutionGroups->get(elemName, elemURI);
  -
  -            if (subsElements) {
  -
  -                unsigned subsElemSize = subsElements->size();
  -
  -                for (unsigned int j=0; j < subsElemSize; j++) {
  -
  -                    SchemaElementDecl* subsElem = subsElements->elementAt(j);
  -                    const XMLCh* subsElemName = subsElem->getBaseName();
  -                    SchemaElementDecl* sameScopeElem = (SchemaElementDecl*)
  -                        fSchemaGrammar->getElemDecl(subsElem->getURI(), subsElemName, 0, elemScope);
  -
  -                    if (sameScopeElem
  -                        && (subsElem->getComplexTypeInfo() != sameScopeElem->getComplexTypeInfo()
  -                            || subsElem->getDatatypeValidator() != sameScopeElem->getDatatypeValidator())) {
  -                        reportSchemaError(elemLocator, XMLUni::fgXMLErrDomain, XMLErrs::DuplicateElementDeclaration, subsElemName);
  -                    }
  -                }
  -            }
  -        }
  -    }
  -}
  -
   void
   TraverseSchema::buildValidSubstitutionListB(const IDOM_Element* const elem,
                                               SchemaElementDecl* const elemDecl,
  @@ -6652,43 +6552,40 @@
   
               SchemaGrammar*     aGrammar = fSchemaGrammar;
               SchemaElementDecl* elemDecl = baseTypeInfo->elementAt(i);
  -
  -            if (!elemDecl) {
  -                continue;
  -            }
  -
               int elemURI = elemDecl->getURI();
  +            int elemScope = elemDecl->getEnclosingScope();
   
  -            if (elemURI != fTargetNSURI && elemURI != schemaURI && elemURI != fEmptyNamespaceURI) {
  -
  -                Grammar* aGrammar =
  -                    fGrammarResolver->getGrammar(fURIStringPool->getValueForId(elemURI));
  +            if (elemScope != Grammar::TOP_LEVEL_SCOPE) {
   
  -                if (!aGrammar || aGrammar->getGrammarType() != Grammar::SchemaGrammarType) {
  -                    continue; // REVISIT - error message
  -                }
  -            }
  +                if (elemURI != fTargetNSURI && elemURI != schemaURI && elemURI != fEmptyNamespaceURI) {
   
  -            const XMLCh*             localPart = elemDecl->getBaseName();
  -            const SchemaElementDecl* other = (SchemaElementDecl*)
  -                aGrammar->getElemDecl(elemURI, localPart, 0, newTypeScope);
  +                    Grammar* aGrammar =
  +                        fGrammarResolver->getGrammar(fURIStringPool->getValueForId(elemURI));
   
  -            if (other) {
  -
  -                if (elemDecl->getComplexTypeInfo() != other->getComplexTypeInfo()
  -                    || elemDecl->getDatatypeValidator() != other->getDatatypeValidator()) {
  -                    reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DuplicateElementDeclaration, localPart);
  +                    if (!aGrammar || aGrammar->getGrammarType() != Grammar::SchemaGrammarType) {
  +                        continue; // REVISIT - error message
  +                    }
                   }
  -            }
  -            else {
   
  -                int elemScope = elemDecl->getEnclosingScope();
  +                const XMLCh*             localPart = elemDecl->getBaseName();
  +                const SchemaElementDecl* other = (SchemaElementDecl*)
  +                    aGrammar->getElemDecl(elemURI, localPart, 0, newTypeScope);
  +
  +                if (other) {
  +
  +                    if (elemDecl->getComplexTypeInfo() != other->getComplexTypeInfo()
  +                        || elemDecl->getDatatypeValidator() != other->getDatatypeValidator()) {
  +                        reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DuplicateElementDeclaration, localPart);
  +                    }
   
  -                newTypeInfo->addElement(elemDecl);
  +                    continue;
  +                }
                   elemDecl->setEnclosingScope(newTypeScope);
                   ((SchemaGrammar*) aGrammar)->putGroupElemDecl(elemDecl);
                   elemDecl->setEnclosingScope(elemScope);
               }
  +
  +            newTypeInfo->addElement(elemDecl);
           }
       }
   }
  @@ -6702,38 +6599,43 @@
       unsigned int elemCount = fromGroup->elementCount();
       int newScope = (typeInfo) ? typeInfo->getScopeDefined() : 0;
   
  +    if (typeInfo)
  +        fromGroup->setCheckElementConsistency(false);
  +
       for (unsigned int i = 0; i < elemCount; i++) {
   
           SchemaElementDecl*       elemDecl = fromGroup->elementAt(i);
   
           if (typeInfo) {
  -            int                      elemURI = elemDecl->getURI();
  -            const XMLCh*             localPart = elemDecl->getBaseName();
  -            const SchemaElementDecl* other = (SchemaElementDecl*)
  -                    fSchemaGrammar->getElemDecl(elemURI, localPart, 0, fCurrentScope);
  -
  -            if (other) {
  -
  -                if (elemDecl->getComplexTypeInfo() != other->getComplexTypeInfo()
  -                    || elemDecl->getDatatypeValidator() != other->getDatatypeValidator()) {
  -                   reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DuplicateElementDeclaration, localPart);
  -                }
  -
  -                continue;
  -            }
   
               int elemScope = elemDecl->getEnclosingScope();
   
  -            elemDecl->setEnclosingScope(newScope);
  -            typeInfo->addElement(elemDecl);
  -            fSchemaGrammar->putGroupElemDecl(elemDecl);
  -            elemDecl->setEnclosingScope(elemScope);
  +            if (elemScope != Grammar::TOP_LEVEL_SCOPE) {
  +
  +                int                      elemURI = elemDecl->getURI();
  +                const XMLCh*             localPart = elemDecl->getBaseName();
  +                const SchemaElementDecl* other = (SchemaElementDecl*)
  +                        fSchemaGrammar->getElemDecl(elemURI, localPart, 0, fCurrentScope);
  +
  +                if (other) {
  +
  +                    if (elemDecl->getComplexTypeInfo() != other->getComplexTypeInfo()
  +                        || elemDecl->getDatatypeValidator() != other->getDatatypeValidator()) {
  +                       reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DuplicateElementDeclaration, localPart);
  +                    }
  +
  +                    continue;
  +                }
   
  -            if (toGroup) {
  -                toGroup->addElement(elemDecl);
  +                elemDecl->setEnclosingScope(newScope);
  +                fSchemaGrammar->putGroupElemDecl(elemDecl);
  +                elemDecl->setEnclosingScope(elemScope);
               }
  +
  +            typeInfo->addElement(elemDecl);
           }
  -        else {
  +
  +        if (toGroup) {
               toGroup->addElement(elemDecl);
           }
       }
  @@ -7830,9 +7732,6 @@
       delete fRedefineComponents;
       delete fIdentityConstraintNames;
       delete fSubstitutionGroups;
  -    delete fRefElements;
  -    delete fRefElemScope;
  -    delete fRefElemLocators;
       delete fIC_ElementsNS;
       delete fIC_NamespaceDepthNS;
       delete fIC_NodeListNS;
  
  
  
  1.7       +3 -8      xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.hpp
  
  Index: TraverseSchema.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TraverseSchema.hpp	25 Mar 2002 20:25:32 -0000	1.6
  +++ TraverseSchema.hpp	1 Apr 2002 15:47:06 -0000	1.7
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: TraverseSchema.hpp,v 1.6 2002/03/25 20:25:32 knoaman Exp $
  + * $Id: TraverseSchema.hpp,v 1.7 2002/04/01 15:47:06 knoaman Exp $
    */
   
   #if !defined(TRAVERSESCHEMA_HPP)
  @@ -204,7 +204,7 @@
                                           const int typeNameIndex,
                                           const int finalSet,
                                           int baseRefContext);
  -    QName*              traverseElementDecl(const IDOM_Element* const childElem, bool& toDelete,
  +    QName*              traverseElementDecl(const IDOM_Element* const childElem,
                                               const bool topLevel = false);
       const XMLCh*        traverseNotationDecl(const IDOM_Element* const childElem);
       const XMLCh*        traverseNotationDecl(const IDOM_Element* const childElem,
  @@ -356,8 +356,7 @@
         * Process a 'ref' of an Element declaration
         */
       QName* processElementDeclRef(const IDOM_Element* const elem,
  -                                 const XMLCh* const refName,
  -                                 bool& toDelete);
  +                                 const XMLCh* const refName);
   
       /**
         * Process a 'ref' of an Attribute declaration
  @@ -541,7 +540,6 @@
   
       void checkFixedFacet(const IDOM_Element* const, const XMLCh* const,
                            const DatatypeValidator* const, unsigned int&);
  -    void checkRefElementConsistency();
       void buildValidSubstitutionListF(const IDOM_Element* const elem,
                                        SchemaElementDecl* const,
                                        SchemaElementDecl* const);
  @@ -770,8 +768,6 @@
       RefHash2KeysTableOf<IdentityConstraint>*       fIdentityConstraintNames;
       RefHash2KeysTableOf<SchemaElementDecl>*        fSubstitutionGroups;
       RefHash2KeysTableOf<ElemVector>*               fValidSubstitutionGroups;
  -    RefVectorOf<QName>*                            fRefElements;
  -    ValueVectorOf<int>*                            fRefElemScope;
       RefHashTableOf<ValueVectorOf<IDOM_Element*> >* fIC_NodeListNS;
       RefHashTableOf<ElemVector>*                    fIC_ElementsNS;
       RefHashTableOf<ValueVectorOf<unsigned int> >*  fIC_NamespaceDepthNS;
  @@ -779,7 +775,6 @@
       RefHashTableOf<SchemaInfo>*                    fPreprocessedNodes;
       XSDErrorReporter                               fErrorReporter;
       XSDLocator*                                    fLocator;
  -    RefVectorOf<XSDLocator>*                       fRefElemLocators;
   
       friend class GeneralAttributeCheck;
   };
  
  
  
  1.3       +5 -1      xml-xerces/c/src/xercesc/validators/schema/XercesGroupInfo.cpp
  
  Index: XercesGroupInfo.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/XercesGroupInfo.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XercesGroupInfo.cpp	25 Mar 2002 20:25:32 -0000	1.2
  +++ XercesGroupInfo.cpp	1 Apr 2002 15:47:06 -0000	1.3
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: XercesGroupInfo.cpp,v $
  + * Revision 1.3  2002/04/01 15:47:06  knoaman
  + * Move Element Consistency checking (ref to global declarations) to SchemaValidator.
  + *
    * Revision 1.2  2002/03/25 20:25:32  knoaman
    * Move particle derivation checking from TraverseSchema to SchemaValidator.
    *
  @@ -81,7 +84,8 @@
   //  XercesGroupInfo: Constructors and Destructor
   // ---------------------------------------------------------------------------
   XercesGroupInfo::XercesGroupInfo()
  -    : fScope(-1)
  +    : fCheckElementConsistency(true)
  +    , fScope(-1)
       , fContentSpec(0)
       , fElements(0)
       , fBaseGroup(0)
  
  
  
  1.3       +14 -1     xml-xerces/c/src/xercesc/validators/schema/XercesGroupInfo.hpp
  
  Index: XercesGroupInfo.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/XercesGroupInfo.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XercesGroupInfo.hpp	25 Mar 2002 20:25:32 -0000	1.2
  +++ XercesGroupInfo.hpp	1 Apr 2002 15:47:06 -0000	1.3
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XercesGroupInfo.hpp,v 1.2 2002/03/25 20:25:32 knoaman Exp $
  + * $Id: XercesGroupInfo.hpp,v 1.3 2002/04/01 15:47:06 knoaman Exp $
    */
   
   #if !defined(XERCESGROUPINFO_HPP)
  @@ -94,6 +94,7 @@
   	// -----------------------------------------------------------------------
       //  Getter methods
       // -----------------------------------------------------------------------
  +    bool                     getCheckElementConsistency() const;
       int                      getScope() const;
       unsigned int             elementCount() const;
       ContentSpecNode*         getContentSpec() const;
  @@ -110,6 +111,7 @@
       void addElement(SchemaElementDecl* const toAdd);
       void setLocator(XSDLocator* const aLocator);
       void setBaseGroup(XercesGroupInfo* const baseGroup);
  +    void setCheckElementConsistency(const bool aValue);
   
   private:
       // -----------------------------------------------------------------------
  @@ -121,6 +123,7 @@
       // -----------------------------------------------------------------------
       //  Private data members
       // -----------------------------------------------------------------------
  +    bool                            fCheckElementConsistency;
       int                             fScope;
       ContentSpecNode*                fContentSpec;
       RefVectorOf<SchemaElementDecl>* fElements;
  @@ -168,6 +171,11 @@
       return fBaseGroup;
   }
   
  +inline bool XercesGroupInfo::getCheckElementConsistency() const {
  +
  +    return fCheckElementConsistency;
  +}
  +
   // ---------------------------------------------------------------------------
   //  XercesGroupInfo: Setter methods
   // ---------------------------------------------------------------------------}
  @@ -190,6 +198,11 @@
   inline void XercesGroupInfo::setBaseGroup(XercesGroupInfo* const baseGroup) {
   
       fBaseGroup = baseGroup;
  +}
  +
  +inline void XercesGroupInfo::setCheckElementConsistency(const bool aValue) {
  +
  +    fCheckElementConsistency = aValue;
   }
   
   #endif
  
  
  

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