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 2001/11/15 18:10:20 UTC

cvs commit: xml-xerces/c/src/validators/schema/identity IC_Field.cpp IC_Field.hpp IC_Selector.cpp IC_Selector.hpp IdentityConstraint.cpp IdentityConstraint.hpp XPathMatcher.cpp XPathMatcher.hpp XercesXPath.cpp XercesXPath.hpp

knoaman     01/11/15 09:10:19

  Modified:    c/src/validators/schema ComplexTypeInfo.cpp
                        ComplexTypeInfo.hpp TraverseSchema.cpp
                        TraverseSchema.hpp
               c/src/validators/schema/identity IC_Field.cpp IC_Field.hpp
                        IC_Selector.cpp IC_Selector.hpp
                        IdentityConstraint.cpp IdentityConstraint.hpp
                        XPathMatcher.cpp XPathMatcher.hpp XercesXPath.cpp
                        XercesXPath.hpp
  Log:
  Particle derivation checking support.
  
  Revision  Changes    Path
  1.23      +4 -0      xml-xerces/c/src/validators/schema/ComplexTypeInfo.cpp
  
  Index: ComplexTypeInfo.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/ComplexTypeInfo.cpp,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- ComplexTypeInfo.cpp	2001/11/07 21:50:28	1.22
  +++ ComplexTypeInfo.cpp	2001/11/15 17:10:19	1.23
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: ComplexTypeInfo.cpp,v $
  + * Revision 1.23  2001/11/15 17:10:19  knoaman
  + * Particle derivation checking support.
  + *
    * Revision 1.22  2001/11/07 21:50:28  tng
    * Fix comment log that lead to error.
    *
  @@ -143,6 +146,7 @@
   ComplexTypeInfo::ComplexTypeInfo()
       : fAbstract(false)
       , fAdoptContentSpec(true)
  +    , fAttWithTypeId(false)
       , fDerivedBy(0)
       , fBlockSet(0)
       , fFinalSet(0)
  
  
  
  1.11      +14 -1     xml-xerces/c/src/validators/schema/ComplexTypeInfo.hpp
  
  Index: ComplexTypeInfo.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/ComplexTypeInfo.hpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ComplexTypeInfo.hpp	2001/10/04 15:08:56	1.10
  +++ ComplexTypeInfo.hpp	2001/11/15 17:10:19	1.11
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: ComplexTypeInfo.hpp,v 1.10 2001/10/04 15:08:56 knoaman Exp $
  + * $Id: ComplexTypeInfo.hpp,v 1.11 2001/11/15 17:10:19 knoaman Exp $
    */
   
   #if !defined(COMPLEXTYPEINFO_HPP)
  @@ -103,6 +103,7 @@
       // -----------------------------------------------------------------------
       bool                     getAbstract() const;
       bool                     getAdoptContentSpec() const;
  +    bool                     containsAttWithTypeId() const;
       int                      getDerivedBy() const;
       int                      getBlockSet() const;
       int                      getFinalSet() const;
  @@ -133,6 +134,7 @@
       // -----------------------------------------------------------------------
       void setAbstract(const bool isAbstract);
       void setAdoptContentSpec(const bool toAdopt);
  +    void setAttWithTypeId(const bool value);
       void setDerivedBy(const int derivedBy);
       void setBlockSet(const int blockSet);
       void setFinalSet(const int finalSet);
  @@ -194,6 +196,7 @@
       // -----------------------------------------------------------------------
       bool                               fAbstract;
       bool                               fAdoptContentSpec;
  +    bool                               fAttWithTypeId;
       int                                fDerivedBy;
       int                                fBlockSet;
       int                                fFinalSet;
  @@ -230,6 +233,11 @@
       return fAdoptContentSpec;
   }
   
  +inline bool ComplexTypeInfo::containsAttWithTypeId() const {
  +
  +    return fAttWithTypeId;
  +}
  +
   inline int ComplexTypeInfo::getDerivedBy() const {
   
       return fDerivedBy;
  @@ -363,6 +371,11 @@
   inline void ComplexTypeInfo::setAdoptContentSpec(const bool toAdopt) {
   
       fAdoptContentSpec = toAdopt;
  +}
  +
  +inline void ComplexTypeInfo::setAttWithTypeId(const bool value) {
  +
  +    fAttWithTypeId = value;
   }
   
   inline void ComplexTypeInfo::setDerivedBy(const int derivedBy) {
  
  
  
  1.59      +1027 -161 xml-xerces/c/src/validators/schema/TraverseSchema.cpp
  
  Index: TraverseSchema.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/TraverseSchema.cpp,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- TraverseSchema.cpp	2001/11/14 22:03:05	1.58
  +++ TraverseSchema.cpp	2001/11/15 17:10:19	1.59
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: TraverseSchema.cpp,v 1.58 2001/11/14 22:03:05 peiyongz Exp $
  + * $Id: TraverseSchema.cpp,v 1.59 2001/11/15 17:10:19 knoaman Exp $
    */
   
   // ---------------------------------------------------------------------------
  @@ -76,7 +76,6 @@
   #include <validators/schema/SchemaGrammar.hpp>
   #include <validators/schema/SchemaAttDef.hpp>
   #include <internal/XMLReader.hpp>
  -#include <validators/common/ContentSpecNode.hpp>
   #include <validators/schema/ComplexTypeInfo.hpp>
   #include <validators/schema/NamespaceScope.hpp>
   #include <validators/schema/SchemaAttDefList.hpp>
  @@ -85,14 +84,11 @@
   #include <framework/LocalFileInputSource.hpp>
   #include <framework/URLInputSource.hpp>
   #include <parsers/DOMParser.hpp>
  -#include <validators/datatype/InvalidDatatypeValueException.hpp>
  -#include <validators/datatype/InvalidDatatypeFacetException.hpp>
   #include <validators/schema/identity/XPathException.hpp>
   #include <validators/schema/GeneralAttributeCheck.hpp>
   #include <validators/schema/XercesGroupInfo.hpp>
   #include <validators/schema/XercesAttGroupInfo.hpp>
   #include <util/HashPtr.hpp>
  -#include <util/SchemaDateTimeException.hpp>
   
   // ---------------------------------------------------------------------------
   //  TraverseSchema: Local declaration
  @@ -367,7 +363,7 @@
       }
   
       fSchemaInfo = currInfo;
  -    fSchemaInfoList->put((void*) fSchemaInfo->getCurrentSchemaURL(), fSchemaInfo);
  +    fSchemaInfoList->put((void*) fSchemaInfo->getCurrentSchemaURL(), fSchemaInfo->getTargetNSURI(), fSchemaInfo);
   
       // process children nodes
       fCurrentScope = Grammar::TOP_LEVEL_SCOPE;
  @@ -398,6 +394,7 @@
       // Element consistency checks - substitution groups
       if (fFullConstraintChecking) {
           checkRefElementConsistency();
  +        checkParticleDerivation();
       }
   }
   
  @@ -505,7 +502,7 @@
       }
   
       const XMLCh* includeURL = srcToFill->getSystemId();
  -    SchemaInfo* includeSchemaInfo = fSchemaInfoList->get(includeURL);
  +    SchemaInfo* includeSchemaInfo = fSchemaInfoList->get(includeURL, fTargetNSURI);
   
       if (includeSchemaInfo) {
   
  @@ -540,8 +537,8 @@
   
           if (!root.isNull()) {
   
  -            const XMLCh* targetNSURIString = getElementAttValue(root,SchemaSymbols::fgATT_TARGETNAMESPACE);
  -		    unsigned int targetNSLength = XMLString::stringLen(targetNSURIString);
  +            const XMLCh* targetNSURIString = getTargetNamespaceString(root);
  +            unsigned int targetNSLength = XMLString::stringLen(targetNSURIString);
   
               // check to see if targetNameSpace is right
               if (targetNSLength != 0
  @@ -573,7 +570,7 @@
                                            XMLString::replicate(includeURL),
                                            fTargetNSURIString, fStringPool, root);
   
  -            fSchemaInfoList->put((void*) fSchemaInfo->getCurrentSchemaURL(), fSchemaInfo);
  +            fSchemaInfoList->put((void*) fSchemaInfo->getCurrentSchemaURL(), fSchemaInfo->getTargetNSURI(), fSchemaInfo);
               saveInfo->addSchemaInfo(fSchemaInfo, SchemaInfo::INCLUDE);
               processChildren(root);
   
  @@ -649,8 +646,13 @@
       }
   
       const XMLCh* importURL = srcToFill->getSystemId();
  -    SchemaInfo* importSchemaInfo = fSchemaInfoList->get(importURL);
  +    SchemaInfo* importSchemaInfo = 0;
   
  +    if (nameSpace)
  +        importSchemaInfo = fSchemaInfoList->get(importURL, fURIStringPool->addOrFind(nameSpace));
  +    else
  +        importSchemaInfo = fSchemaInfoList->get(importURL, fEmptyNamespaceURI);
  +
       if (importSchemaInfo) {
   
           fSchemaInfo->addSchemaInfo(importSchemaInfo, SchemaInfo::IMPORT);
  @@ -705,7 +707,7 @@
               return;
           }
   
  -        const XMLCh* targetNSURIString = getElementAttValue(root,SchemaSymbols::fgATT_TARGETNAMESPACE);
  +        const XMLCh* targetNSURIString = getTargetNamespaceString(root);
   
           if (XMLString::compareString(targetNSURIString, nameSpace) != 0) {
               reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ImportNamespaceDifference,
  @@ -951,7 +953,13 @@
       if (XMLString::stringLen(name) == 0) { // anonymous simpleType
           name = genAnonTypeName(fgAnonSNamePrefix);
       }
  +    else if (!XMLString::isValidNCName(name)) {
   
  +        reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidDeclarationName,
  +                          SchemaSymbols::fgELT_SIMPLETYPE, name);
  +        return -1;
  +    }
  +
       fBuffer.set(fTargetNSURIString);
       fBuffer.append(chComma);
       fBuffer.append(name);
  @@ -1166,7 +1174,7 @@
       const XMLCh* finalAttVal = getElementAttValue(elem, SchemaSymbols::fgATT_FINAL);
       const XMLCh* abstractAttVal = getElementAttValue(elem, SchemaSymbols::fgATT_ABSTRACT);
       int blockSet = parseBlockSet(blockAttVal, C_Block);
  -    int finalSet = parseFinalSet(finalAttVal, ECS_Final);
  +    int finalSet = parseFinalSet(finalAttVal, EC_Final);
   
       typeInfo->setBlockSet(blockSet);
       typeInfo->setFinalSet(finalSet);
  @@ -1272,7 +1280,6 @@
       }
   
       int saveScope = fCurrentScope;
  -//    unsigned int fullNameIndex = fStringPool->addOrFind(fBuffer.getRawBuffer());
       ContentSpecNode* specNode = 0;
       XercesGroupInfo* saveGroupInfo = fCurrentGroupInfo;
       
  @@ -1331,6 +1338,21 @@
       fCurrentGroupInfo = saveGroupInfo;
       fCurrentScope = saveScope;
   
  +    if (fRedefineComponents && fRedefineComponents->get(SchemaSymbols::fgELT_GROUP, nameIndex)) {
  +
  +        fBuffer.set(fullName);
  +        fBuffer.append(SchemaSymbols::fgRedefIdentifier);
  +        XercesGroupInfo* baseGroupInfo = fGroupRegistry->get(fBuffer.getRawBuffer());
  +
  +        try {
  +            checkParticleDerivationOk(groupInfo->getContentSpec(), groupInfo->getScope(),
  +                                      baseGroupInfo->getContentSpec(), baseGroupInfo->getScope());
  +        }
  +        catch (const RuntimeException& excep) {
  +            reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage());
  +        }
  +    }
  +
       return groupInfo;
   }
   
  @@ -1750,10 +1772,37 @@
       const XMLCh* defaultVal = getElementAttValue(elem, SchemaSymbols::fgATT_DEFAULT);
       const XMLCh* fixedVal = getElementAttValue(elem, SchemaSymbols::fgATT_FIXED);
       const XMLCh* useVal = getElementAttValue(elem, SchemaSymbols::fgATT_USE);
  +    const XMLCh* attForm = getElementAttValue(elem, SchemaSymbols::fgATT_FORM);
  +    const XMLCh* dvType = getElementAttValue(elem, SchemaSymbols::fgATT_TYPE);
       DOM_Element  simpleType = checkContent(elem, XUtil::getFirstChildElement(elem), true);
  +    bool         badContent = false;    
   
  -    if(defaultVal) {
  +    while (simpleType != 0) {
   
  +        DOMString contentName = simpleType.getLocalName();
  +        fBuffer.set(contentName.rawBuffer(), contentName.length());
  +
  +        if (XMLString::compareString(SchemaSymbols::fgELT_SIMPLETYPE,
  +                                     fBuffer.getRawBuffer()) == 0) {
  +
  +            if (XUtil::getNextSiblingElement(simpleType) != 0) {
  +                badContent = true;
  +            }
  +            break;
  +        }
  +
  +        badContent = true;
  +        simpleType = XUtil::getNextSiblingElement(simpleType);
  +    }
  +
  +    if (badContent) {
  +        reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidAttributeContent,
  +                          (name) ? SchemaSymbols::fgATT_NAME : SchemaSymbols::fgATT_REF,
  +                          (name) ? name : ref);
  +    }
  +
  +    if (defaultVal) {
  +
           if (fixedVal) {
   
               fixedVal = 0;
  @@ -1774,8 +1823,13 @@
           if (!nameEmpty) {
               reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::LocalAttributeWithNameRef, name);
           }
  +
  +        // Check ref representation OK - 3.2.3::3.2
  +        if (attForm || dvType || (simpleType != 0)) {
  +            reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttributeRefContentError);
  +        }
   
  -        processAttributeDeclRef(elem, simpleType, typeInfo, ref, useVal);
  +        processAttributeDeclRef(elem, typeInfo, ref, useVal, defaultVal, fixedVal);
           return;
       }
   
  @@ -1788,7 +1842,6 @@
       }
   
       // Check for duplicate declaration
  -    const XMLCh* attForm = getElementAttValue(elem, SchemaSymbols::fgATT_FORM);
       const XMLCh* qualified = SchemaSymbols::fgATTVAL_QUALIFIED;
       int uriIndex = fEmptyNamespaceURI;
   
  @@ -1810,29 +1863,13 @@
           return;
       }
   
  -    const XMLCh* typeAttr = getElementAttValue(elem, SchemaSymbols::fgATT_TYPE);
       DatatypeValidator*  dv = 0;
       XMLAttDef::AttTypes attType;
  -    DOMString contentName;
       SchemaInfo* saveInfo = fSchemaInfo;
   
  -    while (simpleType != 0) {
  -
  -        contentName = simpleType.getLocalName();
  -        fBuffer.set(contentName.rawBuffer(), contentName.length());
  -
  -        if (XMLString::compareString(SchemaSymbols::fgELT_SIMPLETYPE,
  -                                     fBuffer.getRawBuffer()) == 0) {
  -            break;
  -        }
  -
  -        reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidAttributeContent, fBuffer.getRawBuffer());
  -        simpleType = XUtil::getNextSiblingElement(simpleType);
  -    }
  -
       if (simpleType != 0) {
   
  -        if (XMLString::stringLen(typeAttr) != 0) {
  +        if (XMLString::stringLen(dvType) != 0) {
               reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttributeWithTypeAndSimpleType);
           }
   
  @@ -1845,15 +1882,17 @@
           }
   
       }
  -    else if (XMLString::stringLen(typeAttr) == 0) {
  +    else if (XMLString::stringLen(dvType) == 0) {
   
           attType = XMLAttDef::Simple;
           dv = fDatatypeRegistry->getDatatypeValidator(SchemaSymbols::fgDT_STRING);
       }
       else {
   
  -        const XMLCh* localPart = getLocalPart(typeAttr);
  -        const XMLCh* prefix = getPrefix(typeAttr);
  +        checkEnumerationRequiredNotation(name, dvType);
  +
  +        const XMLCh* localPart = getLocalPart(dvType);
  +        const XMLCh* prefix = getPrefix(dvType);
           const XMLCh* typeURI = resolvePrefixToURI(prefix);        
   
           if (XMLString::compareString(typeURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA)  == 0) {
  @@ -1952,23 +1991,24 @@
   
       // validate fixed/default values
       const XMLCh* valueToCheck = defaultVal ? defaultVal : fixedVal;
  +    bool  ofTypeID = (dv && dv->getType() == DatatypeValidator::ID);
   
       if (attType == XMLAttDef::Simple && dv && valueToCheck) {
   
  -        try {
  -            dv->validate(valueToCheck);
  -        }
  -        catch(const InvalidDatatypeValueException& idve) {
  -            reportSchemaError(XMLUni::fgValidityDomain,
  -                              XMLValid::DisplayErrorMessage, idve.getMessage());
  -        }
  -        catch (const InvalidDatatypeFacetException& idfe) {
  -            reportSchemaError(XMLUni::fgValidityDomain,
  -                              XMLValid::DisplayErrorMessage, idfe.getMessage());
  +        if (ofTypeID) {
  +            reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttDeclPropCorrect3,
  +                             SchemaSymbols::fgATT_NAME, name);
           }
  -        catch(...) {
  -            reportSchemaError(XMLUni::fgValidityDomain,
  -                              XMLValid::DatatypeValidationFailure, valueToCheck);
  +        else {
  +            try {
  +                dv->validate(valueToCheck);
  +            }
  +            catch (const XMLException& excep) {
  +                reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage());
  +            }
  +            catch(...) {
  +                reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DatatypeValidationFailure, valueToCheck);
  +            }
           }
       }
   
  @@ -2008,10 +2048,19 @@
       }
       else {
   	
  -        bool toClone = false;		
  +        bool toClone = false;
   
           if (typeInfo) {
   
  +            if (ofTypeID) {
  +
  +                if (typeInfo->containsAttWithTypeId()) {
  +                    reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttDeclPropCorrect5);
  +                }
  +
  +                typeInfo->setAttWithTypeId(ofTypeID);
  +            }
  +
               toClone = true;
               typeInfo->addAttDef(attDef);
           }
  @@ -2300,7 +2349,6 @@
                                   subsElements = aGrammar->getValidSubstitutionGroups()->get(subsElemBaseName, subsElemURI);
   
                                   if (subsElements) {
  -
                                       subsElements = new ValueVectorOf<SchemaElementDecl*>(*subsElements);
                                       fValidSubstitutionGroups->put(subsElemBaseName, subsElemURI, subsElements);
                                   }
  @@ -2390,13 +2438,8 @@
                   validator->validate(deflt);
               }
           }
  -        catch(const InvalidDatatypeValueException& idve) {
  -            reportSchemaError(XMLUni::fgValidityDomain,
  -                              XMLValid::DisplayErrorMessage, idve.getMessage());
  -        }
  -        catch (const InvalidDatatypeFacetException& idfe) {
  -            reportSchemaError(XMLUni::fgValidityDomain,
  -                              XMLValid::DisplayErrorMessage, idfe.getMessage());
  +        catch (const XMLException& excep) {
  +            reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage());
           }
           catch(...) {
               reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DatatypeValidationFailure, deflt);
  @@ -2658,17 +2701,8 @@
                     qualifiedName, baseValidator, 0, 0, true, finalSet);
           }
       }
  -    catch(const SchemaDateTimeException& idtve) {
  -        reportSchemaError(XMLUni::fgValidityDomain,
  -                          XMLValid::DisplayErrorMessage, idtve.getMessage());
  -    }
  -    catch(const InvalidDatatypeValueException& idve) {
  -        reportSchemaError(XMLUni::fgValidityDomain,
  -                          XMLValid::DisplayErrorMessage, idve.getMessage());
  -    }
  -    catch (const InvalidDatatypeFacetException& idfe) {
  -        reportSchemaError(XMLUni::fgValidityDomain,
  -                          XMLValid::DisplayErrorMessage, idfe.getMessage());
  +    catch (const XMLException& excep) {
  +        reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage());
       }
       catch(...) {
           reportSchemaError(XMLUni::fgXMLErrDomain,
  @@ -2863,17 +2897,8 @@
                      (qualifiedName, baseValidator, facets, enums, false, finalSet);
           }
       }
  -    catch(const SchemaDateTimeException& idtve) {
  -        reportSchemaError(XMLUni::fgValidityDomain,
  -                          XMLValid::DisplayErrorMessage, idtve.getMessage());
  -    }
  -    catch(const InvalidDatatypeValueException& idve) {
  -        reportSchemaError(XMLUni::fgValidityDomain,
  -                          XMLValid::DisplayErrorMessage, idve.getMessage());
  -    }
  -    catch (const InvalidDatatypeFacetException& idfe) {
  -        reportSchemaError(XMLUni::fgValidityDomain,
  -                          XMLValid::DisplayErrorMessage, idfe.getMessage());
  +    catch (const XMLException& excep) {
  +        reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage());
       }
       catch(...) {
   
  @@ -2978,21 +3003,11 @@
                   janValidators.orphan();
               }
           }
  -    }
  -    catch(const SchemaDateTimeException& idtve) {
  -        reportSchemaError(XMLUni::fgValidityDomain,
  -                          XMLValid::DisplayErrorMessage, idtve.getMessage());
       }
  -    catch(const InvalidDatatypeValueException& idve) {
  +    catch (const XMLException& excep) {
           janValidators.orphan();
  -        reportSchemaError(XMLUni::fgValidityDomain,
  -                          XMLValid::DisplayErrorMessage, idve.getMessage());
  +        reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage());
       }
  -    catch (const InvalidDatatypeFacetException& idfe) {
  -        janValidators.orphan();
  -        reportSchemaError(XMLUni::fgValidityDomain,
  -                          XMLValid::DisplayErrorMessage, idfe.getMessage());
  -    }
       catch(...) {
           janValidators.orphan();
           reportSchemaError(XMLUni::fgXMLErrDomain,
  @@ -3299,13 +3314,8 @@
                           )
                       );
                   }
  -                catch(const InvalidDatatypeValueException& idve) {
  -                    reportSchemaError(XMLUni::fgValidityDomain,
  -                          XMLValid::DisplayErrorMessage, idve.getMessage());
  -                }
  -                catch (const InvalidDatatypeFacetException& idfe) {
  -                    reportSchemaError(XMLUni::fgValidityDomain,
  -                          XMLValid::DisplayErrorMessage, idfe.getMessage());
  +                catch (const XMLException& excep) {
  +                    reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage());
                   }
                   catch(...) {
                       reportSchemaError(XMLUni::fgXMLErrDomain,
  @@ -3620,6 +3630,13 @@
           return;
       }
   
  +    if (!XMLString::isValidNCName(name)) {
  +        reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidDeclarationName,
  +                          SchemaSymbols::fgELT_KEY, name);
  +        return;
  +    }
  +
  +
       if (!fIdentityConstraintNames) {
           fIdentityConstraintNames = new RefHash2KeysTableOf<IdentityConstraint>(29, false);
       }
  @@ -3676,6 +3693,12 @@
           return;
       }
   
  +    if (!XMLString::isValidNCName(name)) {
  +        reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidDeclarationName,
  +                          SchemaSymbols::fgELT_UNIQUE, name);
  +        return;
  +    }
  +
       if (!fIdentityConstraintNames) {
           fIdentityConstraintNames = new RefHash2KeysTableOf<IdentityConstraint>(29, false);
       }
  @@ -3735,6 +3758,12 @@
           return;
       }
   
  +    if (!XMLString::isValidNCName(name)) {
  +        reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidDeclarationName,
  +                          SchemaSymbols::fgELT_KEYREF, name);
  +        return;
  +    }
  +
       const XMLCh* prefix = getPrefix(refer);
       const XMLCh* localPart = getLocalPart(refer);
       const XMLCh* uriStr = resolvePrefixToURI(prefix, namespaceDepth);
  @@ -4394,12 +4423,7 @@
   
       if (!XMLString::compareString(blockStr, SchemaSymbols::fgATTVAL_POUNDALL)) {
           
  -        blockSet = SchemaSymbols::EXTENSION + SchemaSymbols::RESTRICTION;
  -		
  -		if (blockType == ES_Block) {
  -			blockSet += SchemaSymbols::SUBSTITUTION;
  -        }
  -
  +        blockSet = SchemaSymbols::EXTENSION + SchemaSymbols::RESTRICTION + SchemaSymbols::SUBSTITUTION;
           return blockSet;
       }
   
  @@ -4455,16 +4479,9 @@
       int finalSet = 0;
   
       if (!XMLString::compareString(finalStr, SchemaSymbols::fgATTVAL_POUNDALL)) {
  -
  -        finalSet = SchemaSymbols::RESTRICTION;
  -
  -        if (finalType == S_Final) {
  -            finalSet += SchemaSymbols::LIST + SchemaSymbols::UNION;
  -        }
  -        else {
  -            finalSet += SchemaSymbols::EXTENSION;
  -        }
   
  +        finalSet = SchemaSymbols::RESTRICTION + SchemaSymbols::LIST + 
  +                   SchemaSymbols::UNION + SchemaSymbols::EXTENSION;
           return finalSet;
       }
   
  @@ -4635,7 +4652,7 @@
   
           Grammar* aGrammar = fGrammarResolver->getGrammar(typeURI);
   
  -        if (!aGrammar || (aGrammar->getGrammarType() != Grammar::SchemaGrammarType)) {
  +        if (!aGrammar || aGrammar->getGrammarType() != Grammar::SchemaGrammarType) {
   
               reportSchemaError(XMLUni::fgValidityDomain, XMLValid::GrammarNotFound, typeURI);
               return 0;
  @@ -4898,7 +4915,7 @@
       const XMLCh* block = getElementAttValue(elem,SchemaSymbols::fgATT_BLOCK);
       const XMLCh* final = getElementAttValue(elem,SchemaSymbols::fgATT_FINAL);
       int blockSet = parseBlockSet(block, ES_Block);
  -    int finalSet = parseFinalSet(final, ECS_Final);
  +    int finalSet = parseFinalSet(final, EC_Final);
       int elementMiscFlags = 0;
       const XMLCh* nillable = getElementAttValue(elem, SchemaSymbols::fgATT_NILLABLE);
       const XMLCh* abstract = getElementAttValue(elem, SchemaSymbols::fgATT_ABSTRACT);
  @@ -4939,21 +4956,11 @@
   
   
   void TraverseSchema::processAttributeDeclRef(const DOM_Element& elem,
  -                                             const DOM_Element& simpleContent,
                                                ComplexTypeInfo* const typeInfo,
                                                const XMLCh* const refName,
  -                                             const XMLCh* const useAttr) {
  -
  -    // REVISIT - fixedValue & defaultValue - is it valid to overwrite the 'ref'
  -    // attribute. For now, we are keeping the actual attribute declaration info
  -    // as is.
  -
  -    // Check ref representation OK - 3.2.3::3.2
  -    if (!elem.getAttribute(SchemaSymbols::fgATT_FORM).equals("")
  -        || !elem.getAttribute(SchemaSymbols::fgATT_TYPE).equals("")
  -        || simpleContent != 0) {
  -        reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttributeRefContentError);
  -    }
  +                                             const XMLCh* const useAttr,
  +                                             const XMLCh* const defaultVal,
  +                                             const XMLCh* const fixedVal) {
   
       if (!typeInfo && !fCurrentAttGroupInfo) {
           return;
  @@ -5020,35 +5027,97 @@
           reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::TopLevelAttributeNotFound, refName);
           return;
       }
  +
  +    XMLAttDef::DefAttTypes refAttDefType = refAttDef->getDefaultType();
  +    const XMLCh* refAttValue = refAttDef->getValue();
  +    bool invalidAttUse = false;
  +
  +    if (refAttDefType == XMLAttDef::Fixed &&
  +        (defaultVal || (fixedVal && XMLString::compareString(fixedVal, refAttValue)))) {
  +
  +        invalidAttUse = true;
  +        reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttUseCorrect, refName);
  +    }
   
  -    bool required        = (XMLString::compareString(useAttr,SchemaSymbols::fgATTVAL_REQUIRED) == 0);
  -    bool prohibited      = (XMLString::compareString(useAttr,SchemaSymbols::fgATTVAL_PROHIBITED) == 0);
  -    QName* attQName      = refAttDef->getAttName();
  +    bool required = (XMLString::compareString(useAttr,SchemaSymbols::fgATTVAL_REQUIRED) == 0);
  +    bool prohibited = (XMLString::compareString(useAttr,SchemaSymbols::fgATTVAL_PROHIBITED) == 0);
  +    QName* attQName = refAttDef->getAttName();
  +    DatatypeValidator* attDV = refAttDef->getDatatypeValidator();
       SchemaAttDef* attDef = new SchemaAttDef(attQName->getPrefix(),
                                               attQName->getLocalPart(),
                                               attQName->getURI(),
  -                                            refAttDef->getType());
  -
  -    attDef->setValue(refAttDef->getValue());
  -    attDef->setDatatypeValidator(refAttDef->getDatatypeValidator());
  +                                            refAttValue,
  +                                            refAttDef->getType(),
  +                                            refAttDefType);
   
  -    if (prohibited) {
  -        attDef->setDefaultType(XMLAttDef::Prohibited);
  +    if (refAttDefType == XMLAttDef::Fixed) {
  +        if (required && !invalidAttUse) {
  +            attDef->setDefaultType(XMLAttDef::Required_And_Fixed);
  +        }
       }
  -    else if (required){
  +    else {
   
  -        if (refAttDef->getDefaultType() == XMLAttDef::Fixed) {
  -            attDef->setDefaultType(XMLAttDef::Required_And_Fixed);
  +        if (prohibited) {
  +            attDef->setDefaultType(XMLAttDef::Prohibited);
           }
           else {
  -            attDef->setDefaultType(XMLAttDef::Required);
  +
  +            const XMLCh* valueConstraint = defaultVal;
  +
  +            if (required){
  +
  +                if (fixedVal) {
  +
  +                    attDef->setDefaultType(XMLAttDef::Required_And_Fixed);                    
  +                    valueConstraint = fixedVal;
  +                }
  +                else {
  +                    attDef->setDefaultType(XMLAttDef::Required);
  +                }
  +            }
  +
  +            if (valueConstraint) {
  +
  +                // validate content of value constraint
  +                if (attDV) {
  +
  +                    if (attDV->getType() == DatatypeValidator::ID) {
  +                        reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttDeclPropCorrect3,
  +                                          SchemaSymbols::fgATT_REF, refName);
  +                    }
  +                    else {
  +                        try {
  +                            attDV->validate(valueConstraint);
  +                        }
  +                        catch(const XMLException& excep) {
  +                            reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage());
  +                        }
  +                        catch (...) {
  +                            reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DatatypeValidationFailure, valueConstraint);
  +                        }
  +                    }
  +                }
  +
  +                attDef->setValue(valueConstraint);
  +            }
           }
       }
   
  +    attDef->setDatatypeValidator(attDV);
  +
       bool toClone = false;
   
       if (typeInfo) {
   
  +        if (attDV && attDV->getType() == DatatypeValidator::ID) {
  +
  +            if (typeInfo->containsAttWithTypeId()) {
  +                reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttDeclPropCorrect5);
  +            }
  +
  +            typeInfo->setAttWithTypeId(true);
  +        }
  +
           toClone = true;
           typeInfo->addAttDef(attDef);
       }
  @@ -5296,6 +5365,13 @@
                       reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::EmptyComplexRestrictionDerivation);
                   }
               }
  +            else { // if base has no content spec, invalid derivation
  +                if (!baseTypeInfo->getContentSpec()) {
  +
  +                    reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::PD_EmptyBase);
  +                    throw TraverseSchema::InvalidComplexTypeInfo; //REVISIT - should we continue
  +                }
  +            }
   
               // Delay particle constraint checking (5.3) until we have processed
               // the whole schema.
  @@ -5516,7 +5592,6 @@
   bool TraverseSchema::isValidFacet(const XMLCh* const component,
                                     const XMLCh* const name) {
   
  -    // TO DO
       if (!XMLString::compareString(name, SchemaSymbols::fgELT_MINEXCLUSIVE) ||
           !XMLString::compareString(name, SchemaSymbols::fgELT_MININCLUSIVE) ||
           !XMLString::compareString(name, SchemaSymbols::fgELT_MAXEXCLUSIVE) ||
  @@ -5526,9 +5601,8 @@
           !XMLString::compareString(name, SchemaSymbols::fgELT_LENGTH) ||
           !XMLString::compareString(name, SchemaSymbols::fgELT_MINLENGTH) ||
           !XMLString::compareString(name, SchemaSymbols::fgELT_MAXLENGTH) ||
  -        !XMLString::compareString(name, SchemaSymbols::fgELT_PERIOD) ||
  -        !XMLString::compareString(name, SchemaSymbols::fgELT_DURATION) ||
           !XMLString::compareString(name, SchemaSymbols::fgELT_ENUMERATION) ||
  +        !XMLString::compareString(name, SchemaSymbols::fgELT_WHITESPACE) || 
           !XMLString::compareString(name, SchemaSymbols::fgELT_PATTERN) ||
           !XMLString::compareString(name, SchemaSymbols::fgELT_ANNOTATION)) {
           return true;
  @@ -5715,16 +5789,19 @@
                   continue;
               }
   
  -            SchemaAttDef* newAttDef = new SchemaAttDef(attName->getPrefix(),
  -                                                       attName->getLocalPart(),
  -                                                       attName->getURI(),
  -                                                       attDef.getValue(),
  -                                                       attDef.getType(),
  -                                                       attDef.getDefaultType(),
  -                                                       attDef.getEnumeration());
  +            if (attDef.getDefaultType() != XMLAttDef::Prohibited) {
  +            
  +                SchemaAttDef* newAttDef = new SchemaAttDef(attName->getPrefix(),
  +                                                           attName->getLocalPart(),
  +                                                           attName->getURI(),
  +                                                           attDef.getValue(),
  +                                                           attDef.getType(),
  +                                                           attDef.getDefaultType(),
  +                                                           attDef.getEnumeration());
   
  -            newAttDef->setDatatypeValidator(attDef.getDatatypeValidator());
  -            typeInfo->addAttDef(newAttDef);
  +                newAttDef->setDatatypeValidator(attDef.getDatatypeValidator());
  +                typeInfo->addAttDef(newAttDef);
  +            }
           }
       }
   }
  @@ -5738,6 +5815,8 @@
           typeInfo->setContentType(SchemaElementDecl::Any);
           typeInfo->setDatatypeValidator(0);
           typeInfo->setContentSpec(0);
  +        typeInfo->setBaseComplexTypeInfo(0);
  +        typeInfo->setBaseDatatypeValidator(0);
       }
   }
   
  @@ -6121,6 +6200,7 @@
               if (isSubstitutionGroupValid(subsElemDecl, chainElem->getComplexTypeInfo(),
                                            chainElem->getDatatypeValidator(), 0, false)) {
                   validSubs->addElement(chainElem);
  +                buildValidSubstitutionListB(chainElem, subsElemDecl);
               }
           }
       }
  @@ -6464,6 +6544,17 @@
                   continue;
               }
   
  +            DatatypeValidator* attDV = attDef->getDatatypeValidator();
  +
  +            if (attDV && attDV->getType() == DatatypeValidator::ID) {
  +
  +                if (typeInfo->containsAttWithTypeId()) {
  +                    reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttDeclPropCorrect5);
  +                }
  +
  +                typeInfo->setAttWithTypeId(true);
  +            }
  +
               typeInfo->addAttDef(new SchemaAttDef(attDef));
   
               if (toAttGroup) {
  @@ -6728,8 +6819,13 @@
   
               XMLAttDef::DefAttTypes baseAttDefType = baseAttDef->getDefaultType();
               XMLAttDef::DefAttTypes childAttDefType = childAttDef.getDefaultType();
  +
  +            // Constraint 2.1.1 & 3 + check for prohibited base attribute
  +            if (baseAttDefType == XMLAttDef::Prohibited
  +                && childAttDefType != XMLAttDef::Prohibited) {
  +                reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_8, childLocalPart);
  +            }
   
  -            // Constraint 2.1.1 & 3
               if ((baseAttDefType & XMLAttDef::Required)
                   && !(childAttDefType & XMLAttDef::Required)) {
                   reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_2, childLocalPart);
  @@ -6890,7 +6986,7 @@
           return false;
       }
   
  -    SchemaInfo* redefSchemaInfo = fSchemaInfoList->get(includeURL);
  +    SchemaInfo* redefSchemaInfo = fSchemaInfoList->get(includeURL, fTargetNSURI);
   
       if (redefSchemaInfo) {
   
  @@ -6931,7 +7027,7 @@
               return false;
           }
   
  -        const XMLCh* targetNSURIString = getElementAttValue(root,SchemaSymbols::fgATT_TARGETNAMESPACE);
  +        const XMLCh* targetNSURIString = getTargetNamespaceString(root); //getElementAttValue(root,SchemaSymbols::fgATT_TARGETNAMESPACE);
   		unsigned int targetNSLength = XMLString::stringLen(targetNSURIString);
   
           // check to see if targetNameSpace is right
  @@ -6961,10 +7057,10 @@
           fSchemaInfo = new SchemaInfo(fElemAttrDefaultQualified, fBlockDefault, 
                                        fFinalDefault, fTargetNSURI, fCurrentScope,
                                        fScopeCount, namespaceDepth,
  -									 XMLString::replicate(includeURL),
  +                                     XMLString::replicate(includeURL),
                                        fTargetNSURIString, fStringPool, root);
   
  -        fSchemaInfoList->put((void*) fSchemaInfo->getCurrentSchemaURL(), fSchemaInfo);
  +        fSchemaInfoList->put((void*) fSchemaInfo->getCurrentSchemaURL(), fSchemaInfo->getTargetNSURI(), fSchemaInfo);
           redefSchemaInfo->addSchemaInfo(fSchemaInfo, SchemaInfo::INCLUDE);
       }
   
  @@ -7330,6 +7426,776 @@
       }
   }
   
  +void TraverseSchema::checkParticleDerivation() {
  +
  +    RefHashTableOfEnumerator<ComplexTypeInfo> complexTypeEnum(fComplexTypeRegistry);
  +
  +    while (complexTypeEnum.hasMoreElements()) {
  +
  +        ComplexTypeInfo& curTypeInfo = complexTypeEnum.nextElement();
  +        ComplexTypeInfo* baseTypeInfo = 0;
  +        ContentSpecNode* curSpecNode = 0;
  +
  +        if (curTypeInfo.getDerivedBy() == SchemaSymbols::RESTRICTION
  +            && ((baseTypeInfo = curTypeInfo.getBaseComplexTypeInfo()) != 0)
  +            && ((curSpecNode = curTypeInfo.getContentSpec()) != 0)) {
  +
  +            try {
  +                checkParticleDerivationOk(curSpecNode, curTypeInfo.getScopeDefined(),
  +                                          baseTypeInfo->getContentSpec(),
  +                                          baseTypeInfo->getScopeDefined(), baseTypeInfo);
  +            }
  +            catch (const RuntimeException& excep) {
  +                reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage());
  +            }
  +        }
  +    }
  +}
  +
  +void TraverseSchema::checkParticleDerivationOk(ContentSpecNode* const curNode,
  +                                               const int derivedScope,
  +                                               ContentSpecNode* const baseNode,
  +                                               const int baseScope,
  +                                               const ComplexTypeInfo* const baseInfo) {
  +
  +    // Check for pointless occurrences of all, choice, sequence.  The result is
  +    // the contentspec which is not pointless. If the result is a non-pointless
  +    // group, Vector is filled  in with the children of interest
  +    if (!curNode || !baseNode)
  +        return;
  +
  +    ContentSpecNode* curSpecNode = curNode;
  +    ContentSpecNode* baseSpecNode = baseNode;
  +    ValueVectorOf<ContentSpecNode*> curVector(8);
  +    ValueVectorOf<ContentSpecNode*> baseVector(8);
  +    ContentSpecNode::NodeTypes curNodeType = curSpecNode->getType();
  +    ContentSpecNode::NodeTypes baseNodeType = baseSpecNode->getType();
  +
  +    if (curNodeType == ContentSpecNode::Sequence ||
  +        curNodeType == ContentSpecNode::Choice ||
  +        curNodeType == ContentSpecNode::All) {
  +        curSpecNode = checkForPointlessOccurrences(curSpecNode, curNodeType, &curVector);
  +    }
  +
  +    if (baseNodeType == ContentSpecNode::Sequence ||
  +        baseNodeType == ContentSpecNode::Choice ||
  +        baseNodeType == ContentSpecNode::All) {
  +        baseSpecNode = checkForPointlessOccurrences(baseSpecNode, baseNodeType, &baseVector);
  +    }
  +
  +    curNodeType = curSpecNode->getType();
  +    baseNodeType = baseSpecNode->getType();
  +
  +    switch (curNodeType & 0x0f) {
  +    case ContentSpecNode::Leaf:
  +        {
  +            switch (baseNodeType & 0x0f) {
  +            case ContentSpecNode::Leaf:
  +                {
  +                    checkNameAndTypeOK(curSpecNode, derivedScope, baseSpecNode, baseScope, baseInfo);
  +                    return;
  +                }
  +            case ContentSpecNode::Any:
  +            case ContentSpecNode::Any_Other:
  +            case ContentSpecNode::Any_NS:
  +                {
  +                    checkNSCompat(curSpecNode, baseSpecNode);
  +                    return;
  +                }
  +            case ContentSpecNode::Choice:
  +            case ContentSpecNode::Sequence:
  +            case ContentSpecNode::All:
  +                {
  +                    checkRecurseAsIfGroup(curSpecNode, derivedScope, baseSpecNode, baseScope, &baseVector, baseInfo);
  +                    return;
  +                }
  +            default:
  +                {
  +                    ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType);
  +                }
  +            }		
  +        }
  +    case ContentSpecNode::Any:
  +    case ContentSpecNode::Any_Other:
  +    case ContentSpecNode::Any_NS:
  +        {
  +            switch (baseNodeType & 0x0f) {
  +            case ContentSpecNode::Any:
  +            case ContentSpecNode::Any_Other:
  +            case ContentSpecNode::Any_NS:
  +                {
  +                     checkNSSubset(curSpecNode, baseSpecNode);
  +                     return;
  +                }
  +            case ContentSpecNode::Choice:
  +            case ContentSpecNode::Sequence:
  +            case ContentSpecNode::All:
  +            case ContentSpecNode::Leaf:
  +                {
  +                    ThrowXML(RuntimeException, XMLExcepts::PD_ForbiddenRes1);
  +                }
  +            default:
  +                {
  +                    ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType);
  +                }
  +            }
  +        }
  +    case ContentSpecNode::All:
  +        {
  +            switch (baseNodeType & 0x0f) {
  +            case ContentSpecNode::Any:
  +            case ContentSpecNode::Any_Other:
  +            case ContentSpecNode::Any_NS:
  +                {
  +                    checkNSRecurseCheckCardinality(curSpecNode, &curVector, derivedScope, baseSpecNode);
  +                    return;
  +                }
  +            case ContentSpecNode::All:
  +                {
  +                    checkRecurse(curSpecNode, derivedScope, &curVector, baseSpecNode, baseScope, &baseVector, baseInfo);
  +                    return;
  +                }
  +            case ContentSpecNode::Choice:
  +            case ContentSpecNode::Sequence:
  +            case ContentSpecNode::Leaf:
  +                {
  +                    ThrowXML(RuntimeException, XMLExcepts::PD_ForbiddenRes2);
  +                }
  +            default:
  +                {
  +                    ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType);
  +                }
  +            }
  +        }
  +    case ContentSpecNode::Choice:
  +        {
  +            switch (baseNodeType & 0x0f) {
  +            case ContentSpecNode::Any:
  +            case ContentSpecNode::Any_Other:
  +            case ContentSpecNode::Any_NS:
  +                {
  +                    checkNSRecurseCheckCardinality(curSpecNode, &curVector, derivedScope, baseSpecNode);
  +                    return;
  +                }
  +            case ContentSpecNode::Choice:
  +                {
  +                    checkRecurse(curSpecNode, derivedScope, &curVector, baseSpecNode, baseScope, &baseVector, baseInfo, true);
  +                    return;
  +                }
  +            case ContentSpecNode::All:
  +            case ContentSpecNode::Sequence:
  +            case ContentSpecNode::Leaf:
  +                {
  +                    ThrowXML(RuntimeException, XMLExcepts::PD_ForbiddenRes3);
  +                }
  +            default:
  +                {
  +                    ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType);
  +                }
  +            }
  +        }
  +    case ContentSpecNode::Sequence:
  +        {
  +            switch (baseNodeType & 0x0f) {
  +            case ContentSpecNode::Any:
  +            case ContentSpecNode::Any_Other:
  +            case ContentSpecNode::Any_NS:
  +                {
  +                    checkNSRecurseCheckCardinality(curSpecNode, &curVector, derivedScope, baseSpecNode);
  +                    return;
  +                }
  +            case ContentSpecNode::All:
  +                {
  +                    checkRecurseUnordered(curSpecNode, &curVector, derivedScope, baseSpecNode, &baseVector, baseScope, baseInfo);
  +                    return;
  +                }
  +            case ContentSpecNode::Sequence:
  +                {
  +                    checkRecurse(curSpecNode, derivedScope, &curVector, baseSpecNode, baseScope, &baseVector, baseInfo);
  +                    return;
  +                }
  +            case ContentSpecNode::Choice:
  +                {
  +                    checkMapAndSum(curSpecNode, &curVector, derivedScope, baseSpecNode, &baseVector, baseScope, baseInfo);
  +                    return;
  +                }
  +            case ContentSpecNode::Leaf:
  +                {
  +                    ThrowXML(RuntimeException, XMLExcepts::PD_ForbiddenRes4);
  +                }
  +            default:
  +                {
  +                    ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType);
  +                }
  +            }
  +        }
  +    }
  +}
  +
  +ContentSpecNode*
  +TraverseSchema::checkForPointlessOccurrences(ContentSpecNode* const specNode,
  +                                             const ContentSpecNode::NodeTypes nodeType,
  +                                             ValueVectorOf<ContentSpecNode*>* const nodes) {
  +
  +    ContentSpecNode* rightNode = specNode->getSecond();
  +
  +    if (!rightNode) {
  +
  +         gatherChildren(nodeType, specNode->getFirst(), nodes);
  +
  +         if (nodes->size() == 1) {
  +            return nodes->elementAt(0);
  +        }
  +
  +        return specNode;
  +    }
  +
  +    gatherChildren(nodeType, specNode->getFirst(), nodes);
  +    gatherChildren(nodeType, rightNode, nodes);
  +
  +    return specNode;
  +}
  +
  +void TraverseSchema::gatherChildren(const ContentSpecNode::NodeTypes parentNodeType,
  +                                    ContentSpecNode* const specNode,
  +                                    ValueVectorOf<ContentSpecNode*>* const nodes) {
  +
  +    if (!specNode) {
  +        return;
  +    }
  +
  +    int min = specNode->getMinOccurs();
  +    int max = specNode->getMaxOccurs();
  +    ContentSpecNode::NodeTypes nodeType = specNode->getType();
  +    ContentSpecNode* rightNode = specNode->getSecond();
  +
  +    if (nodeType == ContentSpecNode::Leaf ||
  +        (nodeType & 0x0f) == ContentSpecNode::Any ||
  +        (nodeType & 0x0f) == ContentSpecNode::Any_NS ||
  +        (nodeType & 0x0f) == ContentSpecNode::Any_Other) {
  +        nodes->addElement(specNode);
  +    }
  +    else if (min !=1 || max != 1) {
  +        nodes->addElement(specNode);
  +    }
  +    else if (!rightNode) {
  +        gatherChildren(nodeType, specNode->getFirst(), nodes);
  +    }
  +    else if (parentNodeType == nodeType) {
  +
  +        gatherChildren(nodeType, specNode->getFirst(), nodes);
  +        gatherChildren(nodeType, rightNode, nodes);
  +    }
  +    else {
  +        nodes->addElement(specNode);
  +    }
  +}
  +
  +void
  +TraverseSchema::checkNSCompat(const ContentSpecNode* const derivedSpecNode,
  +                              const ContentSpecNode* const baseSpecNode) {
  +
  +    // check Occurrence ranges
  +    if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(),
  +                             baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) {
  +        ThrowXML1(RuntimeException, XMLExcepts::PD_OccurRangeE,
  +                  derivedSpecNode->getElement()->getLocalPart());
  +    }
  +
  +    // check wildcard subset
  +    if (!wildcardEltAllowsNamespace(baseSpecNode, derivedSpecNode->getElement()->getURI())) {
  +        ThrowXML1(RuntimeException, XMLExcepts::PD_NSCompat1,
  +                  derivedSpecNode->getElement()->getLocalPart());
  +    }
  +}
  +
  +bool
  +TraverseSchema::wildcardEltAllowsNamespace(const ContentSpecNode* const baseSpecNode,
  +                                           const unsigned int derivedURI) {
  +
  +    ContentSpecNode::NodeTypes nodeType = baseSpecNode->getType();
  +
  +    if ((nodeType & 0x0f) == ContentSpecNode::Any) {
  +        return true;
  +    }
  +
  +    unsigned int baseURI = baseSpecNode->getElement()->getURI();
  +
  +    if ((nodeType & 0x0f) == ContentSpecNode::Any_NS) {
  +        if (derivedURI == baseURI) {
  +           return true;
  +        }
  +    }
  +    else { // must be ANY_OTHER
  +        if (derivedURI != baseURI && derivedURI != (unsigned int) fEmptyNamespaceURI) {
  +            return true;
  +        }
  +    }
  +
  +    return false;
  +}
  +
  +void
  +TraverseSchema::checkNameAndTypeOK(const ContentSpecNode* const derivedSpecNode,
  +                                   const int derivedScope,
  +                                   const ContentSpecNode* const baseSpecNode,
  +                                   const int baseScope,
  +                                   const ComplexTypeInfo* const baseInfo) {
  +
  +    unsigned int derivedURI = derivedSpecNode->getElement()->getURI();
  +    unsigned int baseURI = baseSpecNode->getElement()->getURI();
  +    const XMLCh* derivedName = derivedSpecNode->getElement()->getLocalPart();
  +    const XMLCh* baseName = baseSpecNode->getElement()->getLocalPart();
  +
  +    if (XMLString::compareString(derivedName, baseName) || derivedURI != baseURI) {
  +        ThrowXML(RuntimeException, XMLExcepts::PD_NameTypeOK1);
  +    }
  +
  +	// case of mixed complex types with attributes only
  +    if (derivedURI == XMLElementDecl::fgPCDataElemId) {
  +        return;
  +    }
  +
  +    if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(),
  +                             baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) {
  +        ThrowXML1(RuntimeException, XMLExcepts::PD_OccurRangeE, derivedName);
  +    }
  +
  +    SchemaGrammar* aGrammar = fSchemaGrammar;
  +    const XMLCh* schemaURI = fURIStringPool->getValueForId(derivedURI);
  +
  +    if ((derivedURI != (unsigned int) fTargetNSURI) && 
  +        (derivedURI != (unsigned int) fEmptyNamespaceURI)) {
  +        aGrammar= (SchemaGrammar*) fGrammarResolver->getGrammar(schemaURI);
  +    }
  +
  +    if (!aGrammar) { //something is wrong
  +        return;
  +    }
  +
  +    SchemaElementDecl* derivedElemDecl = findElement(derivedScope, derivedURI, derivedName, aGrammar);
  +
  +    if (!derivedElemDecl) {
  +        return;
  +    }
  +
  +    SchemaElementDecl* baseElemDecl = 
  +        findElement(baseScope, baseURI, baseName, aGrammar, baseInfo);
  +
  +    if (!baseElemDecl) {
  +        return;
  +    }
  +
  +    int derivedFlags = derivedElemDecl->getMiscFlags();
  +    int baseFlags = baseElemDecl->getMiscFlags();
  +
  +    if (((baseFlags & SchemaSymbols::NILLABLE) == 0) &&
  +		((derivedFlags & SchemaSymbols::NILLABLE) != 0)) {
  +        ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK2, derivedName);
  +    }
  +
  +    const XMLCh* derivedDefVal = derivedElemDecl->getDefaultValue();
  +    const XMLCh* baseDefVal = baseElemDecl->getDefaultValue();
  +
  +    if (baseDefVal && (baseFlags & SchemaSymbols::FIXED) != 0 &&
  +        ((derivedFlags & SchemaSymbols::FIXED) == 0 ||
  +         XMLString::compareString(derivedDefVal, baseDefVal))) {
  +        ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK3, derivedName);
  +    }
  +
  +    int derivedBlockSet = derivedElemDecl->getBlockSet();
  +    int baseBlockSet = baseElemDecl->getBlockSet();
  +
  +    if ((derivedBlockSet & baseBlockSet) != baseBlockSet) {
  +        ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK4, derivedName);
  +    }
  +
  +    // check identity constraints
  +    checkICRestriction(derivedElemDecl, baseElemDecl, derivedName, baseName);
  +
  +    // check that the derived element's type is derived from the base's.
  +    checkTypesOK(derivedElemDecl, baseElemDecl, derivedName);
  +
  +}
  +
  +SchemaElementDecl* 
  +TraverseSchema::findElement(const int scope, const unsigned int uriIndex,
  +                            const XMLCh* const name, 
  +                            SchemaGrammar* const grammar,
  +                            const ComplexTypeInfo* const typeInfo) {
  +
  +    // check for element at given scope first
  +    SchemaElementDecl* elemDecl = (SchemaElementDecl*) grammar->getElemDecl(uriIndex, name, 0, scope);
  +
  +    // if not found, check at global scope
  +    if (!elemDecl) {
  +
  +        elemDecl = (SchemaElementDecl*)
  +            grammar->getElemDecl(uriIndex, name, 0, Grammar::TOP_LEVEL_SCOPE);
  +
  +        // if still not found, and base is specified, look it up there
  +        if (!elemDecl && typeInfo) {
  +
  +            const ComplexTypeInfo* baseInfo = typeInfo;
  +
  +            while (baseInfo) {
  +
  +                elemDecl = (SchemaElementDecl*)
  +                    grammar->getElemDecl(uriIndex, name, 0, baseInfo->getScopeDefined());
  +
  +                if (elemDecl) {
  +                   break;
  +                }
  +
  +                baseInfo = baseInfo->getBaseComplexTypeInfo();
  +            }
  +        }
  +    }
  +
  +    return elemDecl;
  +}
  +
  +void 
  +TraverseSchema::checkICRestriction(const SchemaElementDecl* const derivedElemDecl,
  +                                   const SchemaElementDecl* const baseElemDecl,
  +                                   const XMLCh* const derivedElemName,
  +                                   const XMLCh* const baseElemName) {
  +
  +    // REVIST - need to get more clarification
  +    unsigned int derivedICCount = derivedElemDecl->getIdentityConstraintCount();
  +    unsigned int baseICCount = baseElemDecl->getIdentityConstraintCount();
  +
  +    if (derivedICCount > baseICCount) {
  +        ThrowXML2(RuntimeException, XMLExcepts::PD_NameTypeOK6, derivedElemName, baseElemName);
  +    }
  +
  +    for (unsigned int i=0; i < derivedICCount; i++) {
  +
  +        bool found = false;
  +        IdentityConstraint* ic= derivedElemDecl->getIdentityConstraintAt(i);
  +
  +        for (unsigned int j=0; j < baseICCount; j++) {
  +            if (*ic == *(baseElemDecl->getIdentityConstraintAt(j))) {
  +
  +                found = true;
  +                break;
  +            }
  +        }
  +
  +        if (!found) {
  +            ThrowXML2(RuntimeException, XMLExcepts::PD_NameTypeOK7, derivedElemName, baseElemName);
  +        }
  +    }
  +}
  +
  +void
  +TraverseSchema::checkTypesOK(const SchemaElementDecl* const derivedElemDecl,
  +                             const SchemaElementDecl* const baseElemDecl,
  +                             const XMLCh* const derivedElemName) {
  +
  +    SchemaElementDecl::ModelTypes baseType = baseElemDecl->getModelType();
  +
  +    if (baseType == SchemaElementDecl::Any) {
  +        return;
  +    }
  +
  +    ComplexTypeInfo* rInfo = derivedElemDecl->getComplexTypeInfo();
  +    ComplexTypeInfo* bInfo = baseElemDecl->getComplexTypeInfo();
  +
  +    if (derivedElemDecl->getModelType() == SchemaElementDecl::Simple) {
  +
  +        if (baseType != SchemaElementDecl::Simple) {
  +            ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK5, derivedElemName);
  +        }
  +
  +        if (!rInfo) {
  +
  +            DatatypeValidator* bDV = baseElemDecl->getDatatypeValidator();
  +
  +            if (bInfo || bDV == 0 || 
  +				!bDV->isSubstitutableBy(derivedElemDecl->getDatatypeValidator())) {
  +                ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK5, derivedElemName);
  +            }
  +
  +            return;
  +        }
  +    }
  +
  +    for (; rInfo && rInfo != bInfo; rInfo = rInfo->getBaseComplexTypeInfo());
  +
  +    if (rInfo == 0 || rInfo->getDerivedBy() != SchemaSymbols::RESTRICTION) {
  +        ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK5, derivedElemName);
  +    }
  +}
  +
  +void
  +TraverseSchema::checkRecurseAsIfGroup(ContentSpecNode* const derivedSpecNode,
  +                                      const int derivedScope,
  +                                      const ContentSpecNode* const baseSpecNode,
  +                                      const int baseScope,
  +                                      ValueVectorOf<ContentSpecNode*>* const baseNodes,
  +                                      const ComplexTypeInfo* const baseInfo) {
  +
  +    ContentSpecNode::NodeTypes baseType = baseSpecNode->getType();
  +    ValueVectorOf<ContentSpecNode*> derivedNodes(1);
  +    bool toLax = false;
  +
  +    //Treat the element as if it were in a group of the same variety as base
  +    ContentSpecNode derivedGroupNode(baseType, derivedSpecNode, 0, false);
  +
  +    derivedNodes.addElement(derivedSpecNode);
  +
  +    if (baseSpecNode->getType() == ContentSpecNode::Choice) {
  +        toLax = true;
  +    }
  +
  +    checkRecurse(&derivedGroupNode, derivedScope, &derivedNodes,
  +                 baseSpecNode, baseScope, baseNodes, baseInfo, toLax);
  +}
  +
  +void 
  +TraverseSchema::checkRecurse(const ContentSpecNode* const derivedSpecNode,
  +                             const int derivedScope,
  +                             ValueVectorOf<ContentSpecNode*>* const derivedNodes,
  +                             const ContentSpecNode* const baseSpecNode,
  +                             const int baseScope,
  +                             ValueVectorOf<ContentSpecNode*>* const baseNodes,
  +                             const ComplexTypeInfo* const baseInfo,
  +                             const bool toLax) {
  +
  +    if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(),
  +                             baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) {
  +        ThrowXML(RuntimeException, XMLExcepts::PD_Recurse1);
  +    }
  +
  +    // check for mapping of children
  +    unsigned int count1= derivedNodes->size();
  +    unsigned int count2= baseNodes->size();
  +    unsigned int current = 0;
  +
  +    for (unsigned int i=0; i<count1; i++) {
  +
  +        ContentSpecNode* derivedNode = derivedNodes->elementAt(i);
  +        bool matched = false;
  +
  +        for (unsigned int j = current; j<count2 && !matched; j++) {
  +
  +            ContentSpecNode* baseNode = baseNodes->elementAt(j);
  +            current++;
  +
  +            try {
  +
  +                checkParticleDerivationOk(derivedNode, derivedScope, baseNode, baseScope, baseInfo);
  +                matched = true;
  +            }
  +            catch(const RuntimeException&) {
  +                if (!toLax && !emptiableParticle(baseNode)) {
  +                    ThrowXML(RuntimeException, XMLExcepts::PD_Recurse2);
  +                }
  +            }
  +        }
  +
  +        // did not find a match
  +        if (!matched) {
  +            ThrowXML(RuntimeException, XMLExcepts::PD_Recurse2);
  +        }
  +    }
  +
  +    // Now, see if there are some elements in the base we didn't match up
  +    // in case of Sequence or All
  +    if (!toLax) {
  +        for (unsigned int j = current; j < count2; j++) {
  +            if (!emptiableParticle(baseNodes->elementAt(j))) {
  +                ThrowXML(RuntimeException, XMLExcepts::PD_Recurse2);
  +            }
  +        }
  +    }
  +}
  +
  +void TraverseSchema::checkNSSubset(const ContentSpecNode* const derivedSpecNode,
  +                                   const ContentSpecNode* const baseSpecNode) {
  +
  +    // check Occurrence ranges
  +    if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(),
  +                             baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) {
  +        ThrowXML(RuntimeException, XMLExcepts::PD_NSSubset1);
  +    }
  +
  +    if (!isWildCardEltSubset(derivedSpecNode, baseSpecNode)) {
  +        ThrowXML(RuntimeException, XMLExcepts::PD_NSSubset2);
  +    }
  +}
  +
  +bool
  +TraverseSchema::isWildCardEltSubset(const ContentSpecNode* const derivedSpecNode,
  +                                    const ContentSpecNode* const baseSpecNode) {
  +
  +    ContentSpecNode::NodeTypes baseType = baseSpecNode->getType();
  +
  +    if ((baseType & 0x0f) == ContentSpecNode::Any) {
  +        return true;
  +    }
  +
  +    ContentSpecNode::NodeTypes derivedType = derivedSpecNode->getType();
  +    unsigned int baseURI = baseSpecNode->getElement()->getURI();
  +    unsigned int derivedURI = derivedSpecNode->getElement()->getURI();
  +
  +    if (((derivedType & 0x0f) == ContentSpecNode::Any_Other) &&
  +        ((baseType & 0x0f) == ContentSpecNode::Any_Other) &&
  +        baseURI == derivedURI) {
  +        return true;
  +    }
  +
  +    if ((derivedType & 0x0f) == ContentSpecNode::Any_NS) {
  +
  +        if (((baseType & 0x0f) == ContentSpecNode::Any_NS) &&
  +            baseURI == derivedURI) {
  +            return true;
  +        }
  +
  +        if (((baseType & 0x0f) == ContentSpecNode::Any_Other) &&
  +            baseURI != derivedURI) {
  +            return true;
  +        }
  +    }
  +
  +    return false;
  +}
  +
  +void 
  +TraverseSchema::checkNSRecurseCheckCardinality(const ContentSpecNode* const derivedSpecNode,
  +                                               ValueVectorOf<ContentSpecNode*>* const derivedNodes,
  +                                               const int derivedScope,
  +                                               ContentSpecNode* const baseSpecNode) {
  +
  +    // Implement total range check
  +    int derivedMin = getMinTotalRange(derivedSpecNode);
  +    int derivedMax = getMaxTotalRange(derivedSpecNode);
  +
  +    // check Occurrence ranges
  +    if (!isOccurrenceRangeOK(derivedMin, derivedMax, baseSpecNode->getMinOccurs(),
  +                              baseSpecNode->getMaxOccurs())) {
  +        ThrowXML(RuntimeException, XMLExcepts::PD_NSRecurseCheckCardinality1);
  +    }
  +
  +    // Check that each member of the group is a valid restriction of the wildcard
  +    unsigned int nodesCount = derivedNodes->size();
  +
  +    for (unsigned int i = 0; i < nodesCount; i++) {
  +        checkParticleDerivationOk(derivedNodes->elementAt(i), derivedScope, baseSpecNode, -1);
  +    }
  +}
  +
  +void 
  +TraverseSchema::checkRecurseUnordered(const ContentSpecNode* const derivedSpecNode,
  +                                      ValueVectorOf<ContentSpecNode*>* const derivedNodes, 
  +                                      const int derivedScope,
  +                                      ContentSpecNode* const baseSpecNode, 
  +                                      ValueVectorOf<ContentSpecNode*>* const baseNodes, 
  +                                      const int baseScope,
  +                                      const ComplexTypeInfo* const baseInfo) {
  +
  +    // check Occurrence ranges
  +    if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(),
  +                             baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) {
  +        ThrowXML(RuntimeException, XMLExcepts::PD_Recurse1);
  +    }
  +
  +    unsigned int       derivedCount= derivedNodes->size();
  +    unsigned int       baseCount = baseNodes->size();
  +    bool*              foundIt = new bool[baseCount];
  +    ArrayJanitor<bool> janFoundIt(foundIt);
  +
  +    for (unsigned k=0; k < baseCount; k++) {
  +        foundIt[k] = false;
  +    }
  +
  +    // check for mapping of children
  +    for (unsigned int i = 0; i < derivedCount; i++) {
  +
  +        ContentSpecNode* derivedNode = derivedNodes->elementAt(i);
  +        bool matched = false;
  +
  +        for (unsigned int j = 0; j < baseCount && !matched; j++) {
  +
  +            try {
  +
  +                checkParticleDerivationOk(derivedNode, derivedScope, baseNodes->elementAt(j), baseScope, baseInfo);
  +
  +                if (foundIt[j]) {
  +                    ThrowXML(RuntimeException, XMLExcepts::PD_RecurseUnordered);
  +                }
  +
  +                foundIt[j] = true;
  +                matched = true;
  +            }
  +            catch (const RuntimeException&) {
  +            }
  +        }
  +
  +        // didn't find a match.
  +        if (!matched) {
  +	        ThrowXML(RuntimeException, XMLExcepts::PD_RecurseUnordered);
  +        }
  +    }
  +
  +    // For all unmapped particles in base, check to see it it's emptiable or not
  +    for (unsigned int j=0; j < baseCount; j++) {
  +        if (!foundIt[j] && !emptiableParticle(baseNodes->elementAt(j))) {
  +	        ThrowXML(RuntimeException, XMLExcepts::PD_RecurseUnordered);
  +        }			
  +    }
  +}
  +
  +void 
  +TraverseSchema::checkMapAndSum(const ContentSpecNode* const derivedSpecNode,
  +                               ValueVectorOf<ContentSpecNode*>* const derivedNodes, 
  +                               const int derivedScope,
  +                               ContentSpecNode* const baseSpecNode, 
  +                               ValueVectorOf<ContentSpecNode*>* const baseNodes, 
  +                               const int baseScope,
  +                               const ComplexTypeInfo* const baseInfo) {
  +
  +    // check Occurrence ranges
  +    int derivedCount = derivedNodes->size();
  +    int baseCount = baseNodes->size();
  +    int derivedMin = derivedSpecNode->getMinOccurs() * derivedCount;
  +    int derivedMax = derivedSpecNode->getMaxOccurs();
  +
  +    if (derivedMax != SchemaSymbols::UNBOUNDED) {
  +        derivedMax *= derivedCount;
  +    }
  +
  +    if (!isOccurrenceRangeOK(derivedMin, derivedMax, baseSpecNode->getMinOccurs(),
  +                             baseSpecNode->getMaxOccurs())) {
  +        ThrowXML(RuntimeException, XMLExcepts::PD_Recurse1);
  +    }
  +
  +    // check for mapping of children
  +    for (int i = 0; i < derivedCount; i++) {
  +
  +        ContentSpecNode* derivedNode = derivedNodes->elementAt(i);
  +        bool matched = false;
  +
  +        for (int j = 0; j < baseCount && !matched; j++) {
  +
  +            try {
  +
  +                checkParticleDerivationOk(derivedNode, derivedScope, baseNodes->elementAt(j), baseScope, baseInfo);
  +                matched = true;
  +            }
  +            catch (const RuntimeException&) {
  +            }
  +        }
  +
  +        // didn't find a match.
  +        if (!matched) {
  +	        ThrowXML(RuntimeException, XMLExcepts::PD_MapAndSum);
  +        }
  +    }
  +
  +}
  +
   // ---------------------------------------------------------------------------
   //  TraverseSchema: Error reporting methods
   // ---------------------------------------------------------------------------
  @@ -7380,7 +8246,7 @@
       fGlobalDeclarations = new RefHash2KeysTableOf<XMLCh>(29, false);
       fNotationRegistry = new RefHash2KeysTableOf<XMLCh>(13, false);
       fSubstitutionGroups = new RefHash2KeysTableOf<SchemaElementDecl>(29, false);
  -    fSchemaInfoList = new RefHashTableOf<SchemaInfo>(29);
  +    fSchemaInfoList = new RefHash2KeysTableOf<SchemaInfo>(29);
   }
   
   void TraverseSchema::cleanUp() {
  
  
  
  1.26      +111 -5    xml-xerces/c/src/validators/schema/TraverseSchema.hpp
  
  Index: TraverseSchema.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/TraverseSchema.hpp,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- TraverseSchema.hpp	2001/11/02 14:13:45	1.25
  +++ TraverseSchema.hpp	2001/11/15 17:10:19	1.26
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: TraverseSchema.hpp,v 1.25 2001/11/02 14:13:45 knoaman Exp $
  + * $Id: TraverseSchema.hpp,v 1.26 2001/11/15 17:10:19 knoaman Exp $
    */
   
   #if !defined(TRAVERSESCHEMA_HPP)
  @@ -73,9 +73,11 @@
   #include <dom/DOM_Element.hpp>
   #include <dom/DOM_Attr.hpp>
   #include <framework/XMLBuffer.hpp>
  +#include <framework/XMLErrorCodes.hpp>
   #include <validators/schema/SchemaSymbols.hpp>
   #include <util/ValueVectorOf.hpp>
   #include <util/RefHash2KeysTableOf.hpp>
  +#include <validators/common/ContentSpecNode.hpp>
   #include <validators/schema/SchemaGrammar.hpp>
   #include <validators/schema/SchemaInfo.hpp>
   
  @@ -332,10 +334,11 @@
         * Process a 'ref' of an Attribute declaration
         */
       void processAttributeDeclRef(const DOM_Element& elem,
  -                                 const DOM_Element& simpleTypeContent,
                                    ComplexTypeInfo* const typeInfo,
                                    const XMLCh* const refName,
  -                                 const XMLCh* const useVal);
  +                                 const XMLCh* const useVal,
  +                                 const XMLCh* const defaultVal,
  +                                 const XMLCh* const fixedVal);
   
       /**
         * Process a 'ref' on a group
  @@ -528,6 +531,8 @@
                                   XercesAttGroupInfo* const toAttGroup,
                                   ComplexTypeInfo* const typeInfo);
   
  +    const XMLCh* getTargetNamespaceString(const DOM_Element& elem);
  +
       /**
         * Attribute wild card intersection.
         *
  @@ -660,6 +665,80 @@
                             ValueVectorOf<SchemaInfo*>* const infoList);
   
       // -----------------------------------------------------------------------
  +    //  Particle Derivation Checking methods
  +    // -----------------------------------------------------------------------
  +    void checkParticleDerivation();
  +    void checkParticleDerivationOk(ContentSpecNode* const curNode,
  +                                   const int derivedScope,
  +                                   ContentSpecNode* const baseNode,
  +                                   const int baseScope,
  +                                   const ComplexTypeInfo* const baseInfo = 0);
  +    ContentSpecNode* checkForPointlessOccurrences(ContentSpecNode* const specNode,
  +                                                  const ContentSpecNode::NodeTypes nodeType,
  +                                                  ValueVectorOf<ContentSpecNode*>* const nodes);
  +    void gatherChildren(const ContentSpecNode::NodeTypes parentNodeType,
  +                        ContentSpecNode* const specNode,
  +                        ValueVectorOf<ContentSpecNode*>* const nodes);
  +    bool isOccurrenceRangeOK(const int min1, const int max1, const int min2, const int max2);
  +    void checkNSCompat(const ContentSpecNode* const derivedSpecNode,
  +                       const ContentSpecNode* const baseSpecNode);
  +    bool wildcardEltAllowsNamespace(const ContentSpecNode* const baseSpecNode,
  +                                    const unsigned int derivedURI);
  +    void checkNameAndTypeOK(const ContentSpecNode* const derivedSpecNode,
  +                            const int derivedScope,
  +                            const ContentSpecNode* const baseSpecNode,
  +                            const int baseScope,
  +                            const ComplexTypeInfo* const baseInfo = 0);
  +    SchemaElementDecl* findElement(const int scope,
  +                                   const unsigned int uriIndex,
  +                                   const XMLCh* const name,
  +                                   SchemaGrammar* const grammar,
  +                                   const ComplexTypeInfo* const typeInfo = 0);
  +    void checkICRestriction(const SchemaElementDecl* const derivedElemDecl,
  +                            const SchemaElementDecl* const baseElemDecl,
  +                            const XMLCh* const derivedElemName,
  +                            const XMLCh* const baseElemName);
  +    void checkTypesOK(const SchemaElementDecl* const derivedElemDecl,
  +                      const SchemaElementDecl* const baseElemDecl,
  +                      const XMLCh* const derivedElemName);
  +    void checkRecurseAsIfGroup(ContentSpecNode* const derivedSpecNode,
  +                               const int derivedScope,
  +                               const ContentSpecNode* const baseSpecNode,
  +                               const int baseScope,
  +                               ValueVectorOf<ContentSpecNode*>* const nodes,
  +                               const ComplexTypeInfo* const baseInfo);
  +    void checkRecurse(const ContentSpecNode* const derivedSpecNode,
  +                      const int derivedScope,
  +                      ValueVectorOf<ContentSpecNode*>* const derivedNodes,
  +                      const ContentSpecNode* const baseSpecNode,
  +                      const int baseScope,
  +                      ValueVectorOf<ContentSpecNode*>* const baseNodes,
  +                      const ComplexTypeInfo* const baseInfo,
  +                      const bool toLax = false);
  +    void checkNSSubset(const ContentSpecNode* const derivedSpecNode,
  +                       const ContentSpecNode* const baseSpecNode);
  +    bool isWildCardEltSubset(const ContentSpecNode* const derivedSpecNode,
  +                             const ContentSpecNode* const baseSpecNode);
  +    void checkNSRecurseCheckCardinality(const ContentSpecNode* const derivedSpecNode,
  +                                        ValueVectorOf<ContentSpecNode*>* const derivedNodes,
  +                                        const int derivedScope,
  +                                        ContentSpecNode* const baseSpecNode);
  +    void checkRecurseUnordered(const ContentSpecNode* const derivedSpecNode,
  +                               ValueVectorOf<ContentSpecNode*>* const derivedNodes, 
  +                               const int derivedScope,
  +                               ContentSpecNode* const baseSpecNode, 
  +                               ValueVectorOf<ContentSpecNode*>* const baseNodes, 
  +                               const int baseScope,
  +                               const ComplexTypeInfo* const baseInfo);
  +    void checkMapAndSum(const ContentSpecNode* const derivedSpecNode,
  +                        ValueVectorOf<ContentSpecNode*>* const derivedNodes, 
  +                        const int derivedScope,
  +                        ContentSpecNode* const baseSpecNode, 
  +                        ValueVectorOf<ContentSpecNode*>* const baseNodes, 
  +                        const int baseScope,
  +                        const ComplexTypeInfo* const baseInfo);
  +
  +    // -----------------------------------------------------------------------
       //  Private constants
       // -----------------------------------------------------------------------
       enum
  @@ -667,13 +746,16 @@
           ES_Block
           , C_Block
           , S_Final
  +        , EC_Final
           , ECS_Final
       };
   
       enum ExceptionCodes
       {
           NoException = 0,
  -        InvalidComplexTypeInfo = 1
  +        InvalidComplexTypeInfo = 1,
  +        ParticleDerivationNotOK = 2,
  +        InvalidContentSpecType = 3
       };
   
       enum
  @@ -710,7 +792,7 @@
       RefHashTableOf<ComplexTypeInfo>*              fComplexTypeRegistry;
       RefHashTableOf<XercesGroupInfo>*              fGroupRegistry;
       RefHashTableOf<XercesAttGroupInfo>*           fAttGroupRegistry;
  -    RefHashTableOf<SchemaInfo>*                   fSchemaInfoList;
  +    RefHash2KeysTableOf<SchemaInfo>*              fSchemaInfoList;
       SchemaInfo*                                   fSchemaInfo;
       XercesGroupInfo*                              fCurrentGroupInfo;
       XercesAttGroupInfo*                           fCurrentAttGroupInfo;
  @@ -818,6 +900,18 @@
       return XMLUni::fgZeroLenString;
   }
   
  +inline const XMLCh* 
  +TraverseSchema::getTargetNamespaceString(const DOM_Element& elem) {
  +
  +    const XMLCh* targetNS = getElementAttValue(elem, SchemaSymbols::fgATT_TARGETNAMESPACE);
  +
  +    if (targetNS && XMLString::stringLen(targetNS) == 0) {
  +        reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidTargetNSValue);
  +    }
  +
  +    return targetNS;
  +}
  +
   inline bool TraverseSchema::isBaseFromAnotherSchema(const XMLCh* const baseURI)
   {
       if (XMLString::compareString(baseURI,fTargetNSURIString) != 0
  @@ -894,6 +988,18 @@
       for (int i=0; i < redefineCounter; i++) {
           newTypeName.append(SchemaSymbols::fgRedefIdentifier);
       }
  +}
  +
  +inline bool
  +TraverseSchema::isOccurrenceRangeOK(const int min1, const int max1,
  +                                    const int min2, const int max2) {
  +
  +    if (min1 >= min2 &&
  +        (max2 == SchemaSymbols::UNBOUNDED || 
  +         (max1 != SchemaSymbols::UNBOUNDED && max1 <= max2))) {
  +        return true;
  +    }
  +    return false;
   }
   
   #endif
  
  
  
  1.2       +17 -1     xml-xerces/c/src/validators/schema/identity/IC_Field.cpp
  
  Index: IC_Field.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/identity/IC_Field.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IC_Field.cpp	2001/11/02 14:08:40	1.1
  +++ IC_Field.cpp	2001/11/15 17:10:19	1.2
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: IC_Field.cpp,v $
  + * Revision 1.2  2001/11/15 17:10:19  knoaman
  + * Particle derivation checking support.
  + *
    * Revision 1.1  2001/11/02 14:08:40  knoaman
    * Add support for identity constraints.
    *
  @@ -113,6 +116,19 @@
   IC_Field::~IC_Field()
   {
       delete fXPath;
  +}
  +
  +// ---------------------------------------------------------------------------
  +//  IC_Field: operators
  +// ---------------------------------------------------------------------------
  +bool IC_Field::operator== (const IC_Field& other) const {
  +
  +    return (*fXPath == *(other.fXPath));
  +}
  +
  +bool IC_Field::operator!= (const IC_Field& other) const {
  +
  +    return !operator==(other);
   }
   
   // ---------------------------------------------------------------------------
  
  
  
  1.2       +7 -1      xml-xerces/c/src/validators/schema/identity/IC_Field.hpp
  
  Index: IC_Field.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/identity/IC_Field.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IC_Field.hpp	2001/11/02 14:08:40	1.1
  +++ IC_Field.hpp	2001/11/15 17:10:19	1.2
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: IC_Field.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
  + * $Id: IC_Field.hpp,v 1.2 2001/11/15 17:10:19 knoaman Exp $
    */
   
   #if !defined(IC_FIELD_HPP)
  @@ -82,6 +82,12 @@
       IC_Field(XercesXPath* const xpath,
                IdentityConstraint* const identityConstraint);
   	~IC_Field();
  +
  +    // -----------------------------------------------------------------------
  +    //  operators
  +    // -----------------------------------------------------------------------
  +    bool operator== (const IC_Field& other) const;
  +    bool operator!= (const IC_Field& other) const;
   
   	// -----------------------------------------------------------------------
       //  Getter methods
  
  
  
  1.2       +21 -3     xml-xerces/c/src/validators/schema/identity/IC_Selector.cpp
  
  Index: IC_Selector.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/identity/IC_Selector.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IC_Selector.cpp	2001/11/02 14:08:40	1.1
  +++ IC_Selector.cpp	2001/11/15 17:10:19	1.2
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: IC_Selector.cpp,v $
  + * Revision 1.2  2001/11/15 17:10:19  knoaman
  + * Particle derivation checking support.
  + *
    * Revision 1.1  2001/11/02 14:08:40  knoaman
    * Add support for identity constraints.
    *
  @@ -94,10 +97,12 @@
   }
   
   void SelectorMatcher::startElement(const XMLElementDecl& elemDecl,
  +                                   const unsigned int urlId,
  +                                   const XMLCh* const elemPrefix,
                                      const RefVectorOf<XMLAttr>& attrList,
                                      const unsigned int attrCount) {
   
  -    XPathMatcher::startElement(elemDecl, attrList, attrCount);
  +    XPathMatcher::startElement(elemDecl, urlId, elemPrefix, attrList, attrCount);
       fElementDepth++;
       
       // activate the fields, if selector is matched
  @@ -114,7 +119,7 @@
               IC_Field* field = ic->getFieldAt(i);
               XPathMatcher* matcher = fFieldActivator->activateField(field);
   
  -            matcher->startElement(elemDecl, attrList, attrCount);
  +            matcher->startElement(elemDecl, urlId, elemPrefix, attrList, attrCount);
           }
       }
   }
  @@ -144,6 +149,19 @@
   IC_Selector::~IC_Selector()
   {
       delete fXPath;
  +}
  +
  +// ---------------------------------------------------------------------------
  +//  IC_Selector: operators
  +// ---------------------------------------------------------------------------
  +bool IC_Selector::operator ==(const IC_Selector& other) const {
  +
  +    return (*fXPath == *(other.fXPath));
  +}
  +
  +bool IC_Selector::operator !=(const IC_Selector& other) const {
  +
  +    return !operator==(other);
   }
   
   // ---------------------------------------------------------------------------
  
  
  
  1.2       +9 -1      xml-xerces/c/src/validators/schema/identity/IC_Selector.hpp
  
  Index: IC_Selector.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/identity/IC_Selector.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IC_Selector.hpp	2001/11/02 14:08:40	1.1
  +++ IC_Selector.hpp	2001/11/15 17:10:19	1.2
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: IC_Selector.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
  + * $Id: IC_Selector.hpp,v 1.2 2001/11/15 17:10:19 knoaman Exp $
    */
   
   #if !defined(IC_SELECTOR_HPP)
  @@ -83,6 +83,12 @@
                   IdentityConstraint* const identityConstraint);
   	~IC_Selector();
   
  +    // -----------------------------------------------------------------------
  +    //  operators
  +    // -----------------------------------------------------------------------
  +    bool operator== (const IC_Selector& other) const;
  +    bool operator!= (const IC_Selector& other) const;
  +
   	// -----------------------------------------------------------------------
       //  Getter methods
       // -----------------------------------------------------------------------
  @@ -122,6 +128,8 @@
       // -----------------------------------------------------------------------
       void startDocumentFragment();
       void startElement(const XMLElementDecl& elemDecl,
  +                      const unsigned int urlId,
  +                      const XMLCh* const elemPrefix,
   		              const RefVectorOf<XMLAttr>& attrList,
                         const unsigned int attrCount);
       void endElement(const XMLElementDecl& elemDecl);
  
  
  
  1.2       +36 -1     xml-xerces/c/src/validators/schema/identity/IdentityConstraint.cpp
  
  Index: IdentityConstraint.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/identity/IdentityConstraint.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IdentityConstraint.cpp	2001/11/02 14:08:40	1.1
  +++ IdentityConstraint.cpp	2001/11/15 17:10:19	1.2
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: IdentityConstraint.cpp,v $
  + * Revision 1.2  2001/11/15 17:10:19  knoaman
  + * Particle derivation checking support.
  + *
    * Revision 1.1  2001/11/02 14:08:40  knoaman
    * Add support for identity constraints.
    *
  @@ -93,6 +96,38 @@
   IdentityConstraint::~IdentityConstraint()
   {
       cleanUp();
  +}
  +
  +// ---------------------------------------------------------------------------
  +//  IdentityConstraint: operators
  +// ---------------------------------------------------------------------------
  +bool IdentityConstraint::operator ==(const IdentityConstraint& other) const {
  +
  +    if (getType() != other.getType())
  +        return false;
  +
  +    if (XMLString::compareString(fIdentityConstraintName, other.fIdentityConstraintName))
  +        return false;
  +
  +    if (*fSelector != *(other.fSelector))
  +        return false;
  +
  +    unsigned int fieldCount = fFields->size();
  +
  +    if (fieldCount != other.fFields->size())
  +        return false;
  +
  +    for (unsigned int i = 0; i < fieldCount; i++) {
  +        if (*(fFields->elementAt(i)) != *(other.fFields->elementAt(i)))
  +            return false;
  +    }
  +
  +    return true;
  +}
  +
  +bool IdentityConstraint::operator !=(const IdentityConstraint& other) const {
  +
  +    return !operator==(other);
   }
   
   // ---------------------------------------------------------------------------
  
  
  
  1.2       +7 -1      xml-xerces/c/src/validators/schema/identity/IdentityConstraint.hpp
  
  Index: IdentityConstraint.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/identity/IdentityConstraint.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IdentityConstraint.hpp	2001/11/02 14:08:40	1.1
  +++ IdentityConstraint.hpp	2001/11/15 17:10:19	1.2
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: IdentityConstraint.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
  + * $Id: IdentityConstraint.hpp,v 1.2 2001/11/15 17:10:19 knoaman Exp $
    */
   
   #if !defined(IDENTITYCONSTRAINT_HPP)
  @@ -94,6 +94,12 @@
       //  Constructors/Destructor
       // -----------------------------------------------------------------------
   	virtual ~IdentityConstraint();
  +
  +    // -----------------------------------------------------------------------
  +    //  operators
  +    // -----------------------------------------------------------------------
  +    bool operator== (const IdentityConstraint& other) const;
  +    bool operator!= (const IdentityConstraint& other) const;
   
   	// -----------------------------------------------------------------------
       //  Getter methods
  
  
  
  1.2       +14 -6     xml-xerces/c/src/validators/schema/identity/XPathMatcher.cpp
  
  Index: XPathMatcher.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/identity/XPathMatcher.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XPathMatcher.cpp	2001/11/02 14:08:40	1.1
  +++ XPathMatcher.cpp	2001/11/15 17:10:19	1.2
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: XPathMatcher.cpp,v $
  + * Revision 1.2  2001/11/15 17:10:19  knoaman
  + * Particle derivation checking support.
  + *
    * Revision 1.1  2001/11/02 14:08:40  knoaman
    * Add support for identity constraints.
    *
  @@ -176,6 +179,8 @@
   }
   
   void XPathMatcher::startElement(const XMLElementDecl& elemDecl,
  +                                const unsigned int urlId,
  +                                const XMLCh* const elemPrefix,
   								const RefVectorOf<XMLAttr>& attrList,
                                   const unsigned int attrCount) {
   
  @@ -196,7 +201,7 @@
           int stepSize = locPath->getStepSize();
   
           while (fCurrentStep[i] < stepSize &&
  -               locPath->getStep(fCurrentStep[i])->getAxis()->getType() == XercesAxis::SELF) {
  +               locPath->getStep(fCurrentStep[i])->getAxisType() == XercesStep::SELF) {
               fCurrentStep[i]++;
           }
   
  @@ -220,7 +225,7 @@
           int descendantStep = fCurrentStep[i];
   
           while (fCurrentStep[i] < stepSize &&
  -               locPath->getStep(fCurrentStep[i])->getAxis()->getType() == XercesAxis::DESCENDANT) {
  +               locPath->getStep(fCurrentStep[i])->getAxisType() == XercesStep::DESCENDANT) {
               fCurrentStep[i]++;
           }
   
  @@ -232,14 +237,17 @@
   
           // match child::... step, if haven't consumed any self::node()
           if ((fCurrentStep[i] == startStep || fCurrentStep[i] > descendantStep) &&
  -            locPath->getStep(fCurrentStep[i])->getAxis()->getType() == XercesAxis::CHILD) {
  +            locPath->getStep(fCurrentStep[i])->getAxisType() == XercesStep::CHILD) {
   
               XercesStep* step = locPath->getStep(fCurrentStep[i]);
               XercesNodeTest* nodeTest = step->getNodeTest();
   
               if (nodeTest->getType() == XercesNodeTest::QNAME) {
  +
  +                QName elemQName(elemPrefix, elemDecl.getElementName()->getLocalPart(), urlId);
   
  -                if (!(*(nodeTest->getName()) == *(elemDecl.getElementName()))) {
  +//                if (!(*(nodeTest->getName()) == *(elemDecl.getElementName()))) {
  +                if (!(*(nodeTest->getName()) == elemQName)) {
   
                       if(fCurrentStep[i] > descendantStep) {
                           fCurrentStep[i] = descendantStep;
  @@ -269,7 +277,7 @@
   
           // match attribute::... step
           if (fCurrentStep[i] < stepSize &&
  -            locPath->getStep(fCurrentStep[i])->getAxis()->getType() == XercesAxis::ATTRIBUTE) {
  +            locPath->getStep(fCurrentStep[i])->getAxisType() == XercesStep::ATTRIBUTE) {
   
               if (attrCount) {
   
  
  
  
  1.2       +4 -2      xml-xerces/c/src/validators/schema/identity/XPathMatcher.hpp
  
  Index: XPathMatcher.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/identity/XPathMatcher.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XPathMatcher.hpp	2001/11/02 14:08:40	1.1
  +++ XPathMatcher.hpp	2001/11/15 17:10:19	1.2
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XPathMatcher.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
  + * $Id: XPathMatcher.hpp,v 1.2 2001/11/15 17:10:19 knoaman Exp $
    */
   
   #if !defined(XPATHMATCHER_HPP)
  @@ -110,7 +110,9 @@
       virtual void startDocumentFragment();
       virtual void endDocumentFragment();
       virtual void startElement(const XMLElementDecl& elemDecl,
  -		                      const RefVectorOf<XMLAttr>& attrList,
  +                              const unsigned int urlId,
  +                              const XMLCh* const elemPrefix,
  +                              const RefVectorOf<XMLAttr>& attrList,
                                 const unsigned int attrCount);
       virtual void endElement(const XMLElementDecl& elemDecl);
       virtual void docCharacters(const XMLCh* const chars, const unsigned int length);
  
  
  
  1.3       +99 -53    xml-xerces/c/src/validators/schema/identity/XercesXPath.cpp
  
  Index: XercesXPath.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/identity/XercesXPath.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XercesXPath.cpp	2001/11/07 14:25:36	1.2
  +++ XercesXPath.cpp	2001/11/15 17:10:19	1.3
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: XercesXPath.cpp,v $
  + * Revision 1.3  2001/11/15 17:10:19  knoaman
  + * Particle derivation checking support.
  + *
    * Revision 1.2  2001/11/07 14:25:36  knoaman
    * Fix compliation error on Unix.
    *
  @@ -95,33 +98,6 @@
   
   
   // ---------------------------------------------------------------------------
  -//  XercesAxis: Constructors and Destructor
  -// ---------------------------------------------------------------------------
  -XercesAxis::XercesAxis(const short aType)
  -    : fType(aType)
  -{
  -}
  -
  -XercesAxis::XercesAxis(const XercesAxis& other)
  -    : fType(other.fType)
  -{
  -}
  -
  -// ---------------------------------------------------------------------------
  -//  XercesAxis: Operators
  -// ---------------------------------------------------------------------------
  -XercesAxis& XercesAxis::operator=(const XercesAxis& other)
  -{
  -    if (this == &other)
  -        return *this;
  -
  -    fType = other.fType;
  -    return *this;
  -    
  -}
  -
  -
  -// ---------------------------------------------------------------------------
   //  XercesNodeTest: Constructors and Destructor
   // ---------------------------------------------------------------------------
   XercesNodeTest::XercesNodeTest(const short aType)
  @@ -164,21 +140,36 @@
       return *this;
   }
   
  +bool XercesNodeTest::operator ==(const XercesNodeTest& other) const {
  +
  +    if (this == &other)
  +        return true;
  +
  +    if (fType != other.fType)
  +        return false;
  +
  +    return (*fName == *(other.fName));
  +}
   
  +
  +bool XercesNodeTest::operator !=(const XercesNodeTest& other) const {
  +
  +    return !operator==(other);
  +}
  +
   // ---------------------------------------------------------------------------
   //  XercesStep: Constructors and Destructor
   // ---------------------------------------------------------------------------
  -XercesStep::XercesStep(XercesAxis* const axis, XercesNodeTest* const nodeTest)
  -    : fAxis(axis)
  +XercesStep::XercesStep(const unsigned short axisType, XercesNodeTest* const nodeTest)
  +    : fAxisType(axisType)
       , fNodeTest(nodeTest)
   {
   }
   
   XercesStep::XercesStep(const XercesStep& other)
  -    : fAxis(0)
  +    : fAxisType(other.fAxisType)
       , fNodeTest(0)
   {
  -    fAxis = new XercesAxis(*(other.fAxis));
       fNodeTest = new XercesNodeTest(*(other.fNodeTest));
   }
   
  @@ -191,12 +182,32 @@
       if (this == &other)
           return *this;
   
  -    *fAxis = *(other.fAxis);
  +    fAxisType = other.fAxisType;
       *fNodeTest = *(other.fNodeTest);
       return *this;
   }
   
  +bool XercesStep::operator==(const XercesStep& other) const {
  +
  +    if (this == &other)
  +        return true;
  +
  +    if (fAxisType != other.fAxisType)
  +        return false;
  +
  +    if (fAxisType == XercesStep::CHILD ||
  +        fAxisType == XercesStep::ATTRIBUTE) {
  +        return (*fNodeTest == *(other.fNodeTest));
  +    }
  +
  +    return true;
  +}
  +
  +bool XercesStep::operator!=(const XercesStep& other) const {
   
  +    return !operator==(other);
  +}
  +
   // ---------------------------------------------------------------------------
   //  XercesLocationPath: Constructors and Destructor
   // ---------------------------------------------------------------------------
  @@ -211,6 +222,29 @@
   }
   
   // ---------------------------------------------------------------------------
  +//  XercesLocationPath: Operators
  +// ---------------------------------------------------------------------------
  +bool XercesLocationPath::operator==(const XercesLocationPath& other) const {
  +
  +    unsigned int stepsSize = fSteps->size();
  +
  +    if (stepsSize != other.fSteps->size())
  +        return false;
  +
  +    for (unsigned int i=0; i < stepsSize; i++) {
  +        if (*(fSteps->elementAt(i)) != *(other.fSteps->elementAt(i)))
  +            return false;
  +    }
  +
  +    return true;
  +}
  +
  +bool XercesLocationPath::operator!=(const XercesLocationPath& other) const {
  +
  +    return !operator==(other);
  +}
  +
  +// ---------------------------------------------------------------------------
   //  XercesPath: Constructors and Destructor
   // ---------------------------------------------------------------------------
   XercesXPath::XercesXPath(const XMLCh* const xpathExpr,
  @@ -242,6 +276,29 @@
   
   
   // ---------------------------------------------------------------------------
  +//  XercesXPath: Operators
  +// ---------------------------------------------------------------------------
  +bool XercesXPath::operator==(const XercesXPath& other) const {
  +
  +    unsigned int locPathSize = fLocationPaths->size();
  +
  +    if (locPathSize != other.fLocationPaths->size())
  +        return false;
  +
  +    for (unsigned int i=0; i < locPathSize; i++) {
  +        if (*(fLocationPaths->elementAt(i)) != *(other.fLocationPaths->elementAt(i)))
  +            return false;
  +    }
  +
  +    return true;
  +}
  +
  +bool XercesXPath::operator!=(const XercesXPath& other) const {
  +
  +    return !operator==(other);
  +}
  +
  +// ---------------------------------------------------------------------------
   //  XercesPath: Helper methods
   // ---------------------------------------------------------------------------
   void XercesXPath::cleanUp() {
  @@ -261,10 +318,7 @@
           unsigned int stepSize = locPath->getStepSize();
   
           if (stepSize) {
  -
  -            XercesAxis* axis = locPath->getStep(stepSize - 1)->getAxis();
  -
  -            if (axis->getType() == XercesAxis::ATTRIBUTE) {
  +            if (locPath->getStep(stepSize - 1)->getAxisType() == XercesStep::ATTRIBUTE) {
                   ThrowXML(XPathException, XMLExcepts::XPath_NoAttrSelector);
               }        
   		}
  @@ -343,9 +397,8 @@
   
                   case XercesXPath::EXPRTOKEN_NAMETEST_ANY:
                       {
  -                        XercesAxis* axis = new XercesAxis(XercesAxis::ATTRIBUTE);
                           XercesNodeTest* nodeTest = new XercesNodeTest(XercesNodeTest::WILDCARD);
  -                        XercesStep* step = new XercesStep(axis, nodeTest);
  +                        XercesStep* step = new XercesStep(XercesStep::ATTRIBUTE, nodeTest);
                           stepsVector->addElement(step);
                           break;
                       }
  @@ -373,9 +426,8 @@
                           if (isNamespaceAtt) {
   
                               // build step
  -                            XercesAxis* axis = new XercesAxis(XercesAxis::ATTRIBUTE);
                               XercesNodeTest* nodeTest = new XercesNodeTest(prefix, uri);
  -                            XercesStep* step = new XercesStep(axis, nodeTest);
  +                            XercesStep* step = new XercesStep(XercesStep::ATTRIBUTE, nodeTest);
                               stepsVector->addElement(step);
                               break;
                           }
  @@ -386,9 +438,8 @@
                           QName aQName(prefix, localPart, uri);
   
                           // build step
  -                        XercesAxis* axis = new XercesAxis(XercesAxis::ATTRIBUTE);
                           XercesNodeTest* nodeTest = new XercesNodeTest(&aQName);
  -                        XercesStep* step = new XercesStep(axis, nodeTest);
  +                        XercesStep* step = new XercesStep(XercesStep::ATTRIBUTE, nodeTest);
                           stepsVector->addElement(step);
                           break;
                       }
  @@ -416,9 +467,8 @@
               }
           case XercesXPath::EXPRTOKEN_NAMETEST_ANY:
               {
  -                XercesAxis* axis = new XercesAxis(XercesAxis::CHILD);
                   XercesNodeTest* nodeTest = new XercesNodeTest(XercesNodeTest::WILDCARD);
  -                XercesStep* step = new XercesStep(axis, nodeTest);
  +                XercesStep* step = new XercesStep(XercesStep::CHILD, nodeTest);
                   stepsVector->addElement(step);
                   firstTokenOfLocationPath = false;
                   break;
  @@ -448,9 +498,8 @@
                   if (isNamespace) {
   
                       // build step
  -                    XercesAxis* axis = new XercesAxis(XercesAxis::CHILD);
                       XercesNodeTest* nodeTest = new XercesNodeTest(prefix, uri);
  -                    XercesStep* step = new XercesStep(axis, nodeTest);
  +                    XercesStep* step = new XercesStep(XercesStep::CHILD, nodeTest);
                       stepsVector->addElement(step);
                       break;
                   }
  @@ -460,9 +509,8 @@
                   QName aQName(prefix, localPart, uri);
   
                   // build step
  -                XercesAxis* axis = new XercesAxis(XercesAxis::CHILD);
                   XercesNodeTest* nodeTest = new XercesNodeTest(&aQName);
  -                XercesStep* step = new XercesStep(axis, nodeTest);
  +                XercesStep* step = new XercesStep(XercesStep::CHILD, nodeTest);
                   stepsVector->addElement(step);
                   firstTokenOfLocationPath = false;
                   break;
  @@ -470,9 +518,8 @@
           case XercesXPath::EXPRTOKEN_PERIOD:
               {
                   // build step
  -                XercesAxis* axis = new XercesAxis(XercesAxis::SELF);
                   XercesNodeTest* nodeTest = new XercesNodeTest(XercesNodeTest::NODE);
  -                XercesStep* step = new XercesStep(axis, nodeTest);
  +                XercesStep* step = new XercesStep(XercesStep::SELF, nodeTest);
                   stepsVector->addElement(step);
   
                   if (firstTokenOfLocationPath && i+1 < tokenCount) {
  @@ -494,9 +541,8 @@
                               }
                           }
                           // build step
  -                        axis = new XercesAxis(XercesAxis::DESCENDANT);
                           nodeTest = new XercesNodeTest(XercesNodeTest::NODE);
  -                        step = new XercesStep(axis, nodeTest);
  +                        step = new XercesStep(XercesStep::DESCENDANT, nodeTest);
                           stepsVector->addElement(step);
                       }
                   }
  @@ -1158,7 +1204,7 @@
   
           ch = data[currentOffset];
   
  -        if (!XMLReader::isNameChar(ch)) {
  +        if (ch == chColon || !XMLReader::isNameChar(ch)) {
               break;
           }
       }
  
  
  
  1.3       +31 -43    xml-xerces/c/src/validators/schema/identity/XercesXPath.hpp
  
  Index: XercesXPath.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/identity/XercesXPath.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XercesXPath.hpp	2001/11/06 19:02:06	1.2
  +++ XercesXPath.hpp	2001/11/15 17:10:19	1.3
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XercesXPath.hpp,v 1.2 2001/11/06 19:02:06 knoaman Exp $
  + * $Id: XercesXPath.hpp,v 1.3 2001/11/15 17:10:19 knoaman Exp $
    */
   
   #if !defined(XERCESXPATH_HPP)
  @@ -76,44 +76,6 @@
   class NamespaceScope;
   
   
  -class VALIDATORS_EXPORT XercesAxis
  -{
  -public:
  -    // -----------------------------------------------------------------------
  -    //  Constants
  -    // -----------------------------------------------------------------------
  -    enum {
  -        CHILD = 1,
  -        ATTRIBUTE = 2,
  -        SELF = 3,
  -        DESCENDANT = 4
  -    };
  -
  -    // -----------------------------------------------------------------------
  -    //  Constructors/Destructor
  -    // -----------------------------------------------------------------------
  -    XercesAxis(const short type);
  -    XercesAxis(const XercesAxis& other);
  -    ~XercesAxis() {}
  -
  -    // -----------------------------------------------------------------------
  -    //  Operators
  -    // -----------------------------------------------------------------------
  -    XercesAxis& operator= (const XercesAxis& other);
  -
  -	// -----------------------------------------------------------------------
  -    //  Getter methods
  -    // -----------------------------------------------------------------------
  -    short getType() const { return fType; }
  -
  -private:
  -    // -----------------------------------------------------------------------
  -    //  Data members
  -    // -----------------------------------------------------------------------
  -    short fType;
  -};
  -
  -
   class VALIDATORS_EXPORT XercesNodeTest
   {
   public:
  @@ -140,6 +102,8 @@
       //  Operators
       // -----------------------------------------------------------------------
       XercesNodeTest& operator= (const XercesNodeTest& other);
  +    bool operator== (const XercesNodeTest& other) const;
  +    bool operator!= (const XercesNodeTest& other) const;
   
   	// -----------------------------------------------------------------------
       //  Getter methods
  @@ -162,28 +126,40 @@
   class VALIDATORS_EXPORT XercesStep {
   public:
       // -----------------------------------------------------------------------
  +    //  Constants
  +    // -----------------------------------------------------------------------
  +    enum { // Axis type
  +        CHILD = 1,
  +        ATTRIBUTE = 2,
  +        SELF = 3,
  +        DESCENDANT = 4
  +    };
  +
  +    // -----------------------------------------------------------------------
       //  Constructors/Destructor
       // -----------------------------------------------------------------------
  -    XercesStep(XercesAxis* const axis, XercesNodeTest* const nodeTest);
  +    XercesStep(const unsigned short axisType, XercesNodeTest* const nodeTest);
       XercesStep(const XercesStep& other);
  -    ~XercesStep() { delete fAxis; delete fNodeTest; }
  +    ~XercesStep() { delete fNodeTest; }
   
       // -----------------------------------------------------------------------
       //  Operators
       // -----------------------------------------------------------------------
       XercesStep& operator= (const XercesStep& other);
  +    bool operator== (const XercesStep& other) const;
  +    bool operator!= (const XercesStep& other) const;
   
   	// -----------------------------------------------------------------------
       //  Getter methods
       // -----------------------------------------------------------------------
  -    XercesAxis* getAxis() const { return fAxis; }
  +    unsigned short getAxisType() const { return fAxisType; }
       XercesNodeTest* getNodeTest() const { return fNodeTest; }
   
   private:
       // -----------------------------------------------------------------------
       //  Data members
       // -----------------------------------------------------------------------
  -    XercesAxis* fAxis;
  +    unsigned short  fAxisType;
       XercesNodeTest* fNodeTest;
   };
   
  @@ -202,6 +178,12 @@
       ~XercesLocationPath() { delete fSteps; }
   
       // -----------------------------------------------------------------------
  +    //  Operators
  +    // -----------------------------------------------------------------------
  +    bool operator== (const XercesLocationPath& other) const;
  +    bool operator!= (const XercesLocationPath& other) const;
  +
  +    // -----------------------------------------------------------------------
       //  Access methods
       // -----------------------------------------------------------------------
       unsigned int getStepSize() const;
  @@ -294,6 +276,12 @@
                   const unsigned int emptyNamespaceId,
                   const bool isSelector = false);
   	~XercesXPath();
  +
  +    // -----------------------------------------------------------------------
  +    //  Operators
  +    // -----------------------------------------------------------------------
  +    bool operator== (const XercesXPath& other) const;
  +    bool operator!= (const XercesXPath& other) const;
   
       // -----------------------------------------------------------------------
       //  Constructors/Destructor
  
  
  

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