You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by pe...@apache.org on 2003/10/29 17:14:15 UTC

cvs commit: xml-xerces/c/src/xercesc/internal XObjectComparator.cpp XObjectComparator.hpp XTemplateComparator.cpp XTemplateComparator.hpp Makefile.in

peiyongz    2003/10/29 08:14:15

  Modified:    c/src/xercesc/internal Makefile.in
  Added:       c/src/xercesc/internal XObjectComparator.cpp
                        XObjectComparator.hpp XTemplateComparator.cpp
                        XTemplateComparator.hpp
  Log:
  XObjectComparator/XTemplateComparator
  
  Revision  Changes    Path
  1.17      +5 -1      xml-xerces/c/src/xercesc/internal/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/Makefile.in,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Makefile.in	17 Oct 2003 21:09:18 -0000	1.16
  +++ Makefile.in	29 Oct 2003 16:14:15 -0000	1.17
  @@ -98,10 +98,12 @@
   	XMLReader.hpp \
   	XMLScanner.hpp \
   	XMLScannerResolver.hpp \
  +	XObjectComparator.hpp \
   	XProtoType.hpp \
   	XSerializable.hpp \
   	XSerializationException.hpp \
   	XSerializeEngine.hpp \
  +	XTemplateComparator.hpp \
   	XTemplateSerializer.hpp
   				
   INTERNAL_CPP_PRIVHEADERS =
  @@ -125,8 +127,10 @@
   	XMLReader.$(TO) \
   	XMLScanner.$(TO) \
   	XMLScannerResolver.$(TO) \
  +	XObjectComparator.$(TO) \
   	XProtoType.$(TO) \
   	XSerializeEngine.$(TO) \
  +	XTemplateComparator.$(TO) \
   	XTemplateSerializer.$(TO)
   	
   all::	includes $(INTERNAL_CPP_OBJECTS)
  
  
  
  1.1                  xml-xerces/c/src/xercesc/internal/XObjectComparator.cpp
  
  Index: XObjectComparator.cpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xerces" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache\@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation, and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com .  For more information
   * on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   * $Log: XObjectComparator.cpp,v $
   * Revision 1.1  2003/10/29 16:14:15  peiyongz
   * XObjectComparator/XTemplateComparator
   *
   * $Id: XObjectComparator.cpp,v 1.1 2003/10/29 16:14:15 peiyongz Exp $
   *
   */
  
  // ---------------------------------------------------------------------------
  //  Includes
  // ---------------------------------------------------------------------------
  #include <xercesc/internal/XObjectComparator.hpp>
  #include <xercesc/internal/XTemplateComparator.hpp>
  
  XERCES_CPP_NAMESPACE_BEGIN
  
  /**********************************************************
   *
   * XMLGrammarPool
   *
   * Grammar
   *
   *   SchemaGrammar
   *   DTDGrammar
   *
   ***********************************************************/   
  bool XObjectComparator::isEquivalent(XMLGrammarPoolImpl* const lValue
                                     , XMLGrammarPoolImpl* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
  #ifndef _DEBUG
  
      return (
               XTemplateComparator::isEquivalent(lValue->fGrammarRegistry
                                               , rValue->fGrammarRegistry)  &&
               isEquivalent(lValue->fStringPool, rValue->fStringPool)
             );
  #else
  
      bool v1 = XTemplateComparator::isEquivalent(lValue->fGrammarRegistry
                                                , rValue->fGrammarRegistry);
      bool v2 = isEquivalent(lValue->fStringPool, rValue->fStringPool);
  
      return v1&&v2;
  
  #endif
  
  }
  
  bool XObjectComparator::isEquivalent(Grammar* const lValue
                                     , Grammar* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      if (lValue->getGrammarType() != rValue->getGrammarType())
          return false;
  
      if (lValue->getGrammarType() == Grammar::SchemaGrammarType)
      {
          return isEquivalent((SchemaGrammar*)lValue, (SchemaGrammar*)rValue);
      }
      else
      {
          return isEquivalent((DTDGrammar*)lValue, (DTDGrammar*)rValue);
      }
  
  }
  
  bool XObjectComparator::isBaseEquivalent(Grammar* const lValue
                                         , Grammar* const rValue)
  {
      return true;
  }
  
  
  bool XObjectComparator::isEquivalent(SchemaGrammar* const lValue
                                     , SchemaGrammar* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      if (!isBaseEquivalent(lValue, rValue))
          return false;
  
  #ifndef _DEBUG
      return (
              (lValue->fValidated == rValue->fValidated)                             &&
              XMLString::equals(lValue->fTargetNamespace, rValue->fTargetNamespace)  &&
              isEquivalent(lValue->fGramDesc, rValue->fGramDesc)                     &&
              isEquivalent(&(lValue->fDatatypeRegistry), 
                           &(rValue->fDatatypeRegistry))                             &&
              XTemplateComparator::isEquivalent(lValue->fElemDeclPool
                                              , rValue->fElemDeclPool)               &&
              XTemplateComparator::isEquivalent(lValue->fElemNonDeclPool
                                              , rValue->fElemNonDeclPool)            &&
              XTemplateComparator::isEquivalent(lValue->fGroupElemDeclPool
                                              , rValue->fGroupElemDeclPool)          &&
              XTemplateComparator::isEquivalent(lValue->fNotationDeclPool
                                              , rValue->fNotationDeclPool)           &&
              XTemplateComparator::isEquivalent(lValue->fAttributeDeclRegistry
                                              , rValue->fAttributeDeclRegistry)      &&
              XTemplateComparator::isEquivalent(lValue->fComplexTypeRegistry
                                              , rValue->fComplexTypeRegistry)        &&
              XTemplateComparator::isEquivalent(lValue->fGroupInfoRegistry
                                              , rValue->fGroupInfoRegistry)          &&
              XTemplateComparator::isEquivalent(lValue->fIDRefList
                                              , rValue->fIDRefList)                  &&
              XTemplateComparator::isEquivalent(lValue->fValidSubstitutionGroups
                                              , rValue->fValidSubstitutionGroups)
            );
  #else
  
      bool v1 = lValue->fValidated == rValue->fValidated;
      bool v2 = XMLString::equals(lValue->fTargetNamespace, rValue->fTargetNamespace);
      bool v3 = isEquivalent(lValue->fGramDesc, rValue->fGramDesc);
      bool v4 = isEquivalent(&(lValue->fDatatypeRegistry), &(rValue->fDatatypeRegistry));
      bool v5 = XTemplateComparator::isEquivalent(lValue->fElemDeclPool
                                                , rValue->fElemDeclPool);
      bool v6 = XTemplateComparator::isEquivalent(lValue->fElemNonDeclPool
                                                , rValue->fElemNonDeclPool);
      bool v7 = XTemplateComparator::isEquivalent(lValue->fGroupElemDeclPool
                                                , rValue->fGroupElemDeclPool) ;
      bool v8 = XTemplateComparator::isEquivalent(lValue->fNotationDeclPool
                                                , rValue->fNotationDeclPool);
      bool v9 = XTemplateComparator::isEquivalent(lValue->fAttributeDeclRegistry
                                                , rValue->fAttributeDeclRegistry);
      bool v10 = XTemplateComparator::isEquivalent(lValue->fComplexTypeRegistry
                                                , rValue->fComplexTypeRegistry);
      bool v11 = XTemplateComparator::isEquivalent(lValue->fGroupInfoRegistry
                                                , rValue->fGroupInfoRegistry);
      bool v12 = XTemplateComparator::isEquivalent(lValue->fIDRefList
                                                , rValue->fIDRefList);
      bool v13 = XTemplateComparator::isEquivalent(lValue->fValidSubstitutionGroups
                                                 , rValue->fValidSubstitutionGroups);
  
      return v1&&v2&&v3&&v4&&v5&&v6&&v7&&v8&&v9&&v10&&v11&&v12&&v13;
  
  #endif
  
  }
  
  /**********************************************************
   *
   * XMLGrammarDescription
   *
   *   XMLSchemaDescription
   *   XMLDTDDescription
   *
   ***********************************************************/   
  bool XObjectComparator::isEquivalent(XMLSchemaDescription* const lValue
                                     , XMLSchemaDescription* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      return true;
  }
  
  bool XObjectComparator::isEquivalent(XMLDTDDescription* const lValue
                                     , XMLDTDDescription* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      return true;
  }
  
  /**********************************************************
   *
   * XMLElementDecl
   *   SchemaElementDecl
   *   DTDElementDecl
   *
   ***********************************************************/    
  bool XObjectComparator::isBaseEquivalent(XMLElementDecl* const lValue
                                         , XMLElementDecl* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      return (
               (lValue->fCreateReason    == rValue->fCreateReason)                     &&
               (lValue->fId              == rValue->fId)                               &&
               (lValue->fExternalElement == rValue->fExternalElement)                  &&
               isEquivalent(lValue->getElementName(), rValue->getElementName())              
             );
  }
  
  bool XObjectComparator::isEquivalent(SchemaElementDecl* const lValue
                                     , SchemaElementDecl* const rValue)
  {
       IS_EQUIVALENT(lValue, rValue)
  
      if (!isBaseEquivalent((XMLElementDecl*)lValue, (XMLElementDecl*)rValue))
          return false;
  
  #ifndef _DEBUG
      return (            
              (lValue->fModelType        == rValue->fModelType)             &&
              (lValue->fEnclosingScope   == rValue->fEnclosingScope)        &&
              (lValue->fFinalSet         == rValue->fFinalSet)              &&
              (lValue->fBlockSet         == rValue->fBlockSet)              &&
              (lValue->fMiscFlags        == rValue->fMiscFlags)             &&
              (lValue->fValidity         == rValue->fValidity)              &&
              (lValue->fValidation       == rValue->fValidation)            &&
              (lValue->fSeenValidation   == rValue->fSeenValidation)        &&
              (lValue->fSeenNoValidation == rValue->fSeenNoValidation)      &&
              (lValue->fHadContent       == rValue->fHadContent)            &&
              XMLString::equals(lValue->fDefaultValue
                               , rValue->fDefaultValue)                     &&
              isEquivalent(lValue->fDatatypeValidator
                         , rValue->fDatatypeValidator)                      &&
              isEquivalent((DatatypeValidator*) lValue->fXsiSimpleTypeInfo
                         , (DatatypeValidator*) rValue->fXsiSimpleTypeInfo) &&
              isEquivalent(lValue->fComplexTypeInfo
                         , rValue->fComplexTypeInfo)                        &&
              isEquivalent(lValue->fXsiComplexTypeInfo
                         , rValue->fXsiComplexTypeInfo)                     &&
              isEquivalent(lValue->fAttWildCard
                         , rValue->fAttWildCard)                            &&
              isEquivalent(lValue->fSubstitutionGroupElem
                         , rValue->fSubstitutionGroupElem)                  &&
              XTemplateComparator::isEquivalent(lValue->fAttDefs
                                              , rValue->fAttDefs)           &&
              XTemplateComparator::isEquivalent(lValue->fIdentityConstraints
                                              , rValue->fIdentityConstraints) 
            );                                            
  #else
  
      bool v1 = lValue->fModelType         == rValue->fModelType;
      bool v2 = lValue->fEnclosingScope    == rValue->fEnclosingScope;
      bool v3 = lValue->fFinalSet          == rValue->fFinalSet;
      bool v4 = lValue->fBlockSet          == rValue->fBlockSet;
      bool v5 = lValue->fMiscFlags         == rValue->fMiscFlags;
      bool v6 =  lValue->fValidity         == rValue->fValidity;
      bool v7 =  lValue->fValidation       == rValue->fValidation;
      bool v8 =  lValue->fSeenValidation   == rValue->fSeenValidation;
      bool v9 =  lValue->fSeenNoValidation == rValue->fSeenNoValidation;
      bool v10 = lValue->fHadContent       == rValue->fHadContent;      
      bool v11 = XMLString::equals(lValue->fDefaultValue
                                 , rValue->fDefaultValue);
      bool v12 = isEquivalent(lValue->fDatatypeValidator
                            , rValue->fDatatypeValidator);
      bool v13 = isEquivalent((DatatypeValidator*) lValue->fXsiSimpleTypeInfo
                            , (DatatypeValidator*) rValue->fXsiSimpleTypeInfo);
      bool v14 = isEquivalent(lValue->fComplexTypeInfo
                            , rValue->fComplexTypeInfo);
      bool v15 = isEquivalent(lValue->fXsiComplexTypeInfo
                            , rValue->fXsiComplexTypeInfo);
      bool v16 = isEquivalent(lValue->fAttWildCard
                            , rValue->fAttWildCard);
      bool v17 = isEquivalent(lValue->fSubstitutionGroupElem
                            , rValue->fSubstitutionGroupElem);
      bool v18 = XTemplateComparator::isEquivalent(lValue->fAttDefs
                                                 , rValue->fAttDefs);
      bool v19 = XTemplateComparator::isEquivalent(lValue->fIdentityConstraints
                                                 , rValue->fIdentityConstraints);
  
      return v1&&v2&&v3&&v4&&v5&&v6&&v7&&v8&&v9&&v10&&v11&&v12&&v13&&v14&&v15&&v16&&v17&&v18&&v19;
  
  #endif
  
  }
  
  bool XObjectComparator::isEquivalent(DTDElementDecl* const lValue
                                     , DTDElementDecl* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      if (!isBaseEquivalent((XMLElementDecl*)lValue, (XMLElementDecl*)rValue))
          return false;
  
      //don't compare
      //XMLContentModel*            fContentModel;
      //XMLCh*                      fFormattedModel;
  
      return (            
              (lValue->fModelType == rValue->fModelType)         &&
              isEquivalent(lValue->fContentSpec
                         , rValue->fContentSpec)                 &&
              isEquivalent(lValue->fAttList
                         , rValue->fAttList)                     &&
              XTemplateComparator::isEquivalent(lValue->fAttDefs
                                              , rValue->fAttDefs) 
            );                                            
  
  }
  
  /**********************************************************
   * XMLAttDef
   *   SchemaAttDef
   *   DTDAttDef
   *
  ***********************************************************/   
  bool XObjectComparator::isBaseEquivalent(XMLAttDef* const lValue
                                         , XMLAttDef* const rValue)
  {
      return (
               (lValue->fDefaultType       == rValue->fDefaultType)         &&
               (lValue->fType              == rValue->fType)                &&
               (lValue->fCreateReason      == rValue->fCreateReason)        &&
               (lValue->fProvided          == rValue->fProvided)            &&
               (lValue->fExternalAttribute == rValue->fExternalAttribute)   &&
               (lValue->fId                == rValue->fId)                  &&
               XMLString::equals(lValue->fValue,       rValue->fValue)      &&
               XMLString::equals(lValue->fEnumeration, rValue->fEnumeration)     
              );
  }
  
  bool XObjectComparator::isEquivalent(SchemaAttDef* const lValue
                                     , SchemaAttDef* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      if (!isBaseEquivalent((XMLAttDef*)lValue, (XMLAttDef*)rValue))
          return false;
  
      return (
              (lValue->fValidity   == rValue->fValidity)                       &&
              (lValue->fValidation == rValue->fValidation)                     &&
              (lValue->fElemId     == rValue->fElemId)                         &&
              isEquivalent(lValue->fAttName, rValue->fAttName)                 &&
              isEquivalent(lValue->fDatatypeValidator
                                            , rValue->fDatatypeValidator)      &&
              isEquivalent(lValue->fAnyDatatypeValidator
                         , rValue->fAnyDatatypeValidator)                      &&
              isEquivalent((DatatypeValidator*) lValue->fAnyDatatypeValidator
                         , (DatatypeValidator*) rValue->fAnyDatatypeValidator) &&
              XTemplateComparator::isEquivalent(lValue->fNamespaceList
                                              , rValue->fNamespaceList)
             );
  
  }
  
  bool XObjectComparator::isEquivalent(DTDAttDef* const lValue
                                     , DTDAttDef* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      if (!isBaseEquivalent((XMLAttDef*)lValue, (XMLAttDef*)rValue))
          return false;
  
      return (
              (lValue->fElemId   == rValue->fElemId)          &&
              XMLString::equals(lValue->fName, rValue->fName)
             );
  
  }
  
  /**********************************************************
   * XMLAttDefList
   *   SchemaAttDefList
   *   DTDAttDefList
   *
  ***********************************************************/   
  bool XObjectComparator::isBaseEquivalent(XMLAttDefList* const lValue
                                         , XMLAttDefList* const rValue)
  {
       IS_EQUIVALENT(lValue, rValue)
  
       return true;
  }
     
  bool XObjectComparator::isEquivalent(SchemaAttDefList* const lValue
                                     , SchemaAttDefList* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      //no base comparision needed
  
      return XTemplateComparator::isEquivalent(lValue->fList, rValue->fList);    
  }
  
  bool XObjectComparator::isEquivalent(DTDAttDefList* const lValue
                                     , DTDAttDefList* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      //no base comparision needed
  
      return XTemplateComparator::isEquivalent(lValue->fList, rValue->fList);    
  }
  
  /**********************************************************
   * XMLEntityDecl
   *    DTDEntityDecl 
   *
   ***********************************************************/   
  bool XObjectComparator::isBaseEquivalent(XMLEntityDecl* const lValue
                                         , XMLEntityDecl* const rValue )
  {
  
      return (
               (lValue->fId       == rValue->fId)         &&
               (lValue->fValueLen == rValue->fValueLen)   &&
               XMLString::equals(lValue->fValue
                               , rValue->fValue)          &&
               XMLString::equals(lValue->fName
                               , rValue->fName)           &&
               XMLString::equals(lValue->fNotationName
                               , rValue->fNotationName)   &&
               XMLString::equals(lValue->fPublicId
                               , rValue->fPublicId)       &&
               XMLString::equals(lValue->fSystemId
                               , rValue->fSystemId)       &&
               XMLString::equals(lValue->fBaseURI
                               , rValue->fBaseURI)   
              );
  
  }
  
  bool XObjectComparator::isEquivalent(DTDEntityDecl* const lValue
                                     , DTDEntityDecl* const rValue )
  {
  
      IS_EQUIVALENT(lValue, rValue)
  
      if (!isBaseEquivalent((XMLEntityDecl*)lValue, (XMLEntityDecl*)rValue))
          return false;
  
      return (
               (lValue->fDeclaredInIntSubset == rValue->fDeclaredInIntSubset) &&
               (lValue->fIsParameter         == rValue->fIsParameter)         &&
               (lValue->fIsSpecialChar       == rValue->fIsSpecialChar)
             );
  
  }
  
  /**********************************************************
   * XMLNotationDecl
   *
   * XMLEntityDecl
   *
   * ComplexTypeInfo
   * XercesGroupInfo
   * XercesAttGroupInfo
   ***********************************************************/   
  bool XObjectComparator::isEquivalent(XMLNotationDecl* const lValue
                                     , XMLNotationDecl* const rValue )
  {
  
      IS_EQUIVALENT(lValue, rValue)
  
      return (
              (lValue->fId == rValue->fId)                             &&
              XMLString::equals(lValue->fName    , rValue->fName)      &&
              XMLString::equals(lValue->fPublicId, rValue->fPublicId)  &&
              XMLString::equals(lValue->fSystemId, rValue->fSystemId)  &&
              XMLString::equals(lValue->fBaseURI,  rValue->fBaseURI)  
             );
  
  }
  
  bool XObjectComparator::isEquivalent(ComplexTypeInfo* const lValue
                                     , ComplexTypeInfo* const rValue )
  {
    /***
      don't compare
      XMLContentModel*                   fContentModel;
      XMLCh*                             fFormattedModel;
      RefVectorOf<ContentSpecNode>*      fSpecNodesToDelete;
      XSDLocator*                        fLocator;
      * 
      * fContentSpecOrgURI:     start of the array
      * fContentSpecOrgURISize: size of the array
      * fUniqueURI:             the current last element in the array
      ***/
  
      IS_EQUIVALENT(lValue, rValue)
  
  #ifndef _DEBUG
  return (
              (lValue->fAnonymous        == rValue->fAnonymous)        &&
              (lValue->fAbstract         == rValue->fAbstract)         &&
              (lValue->fAdoptContentSpec == rValue->fAdoptContentSpec) &&
              (lValue->fAttWithTypeId    == rValue->fAttWithTypeId)    &&
              (lValue->fPreprocessed     == rValue->fPreprocessed)     &&
              (lValue->fDerivedBy        == rValue->fDerivedBy)        &&
              (lValue->fBlockSet         == rValue->fBlockSet)         &&
              (lValue->fFinalSet         == rValue->fFinalSet)         &&
              (lValue->fScopeDefined     == rValue->fScopeDefined)     &&
              (lValue->fElementId        == rValue->fElementId)        &&
              (lValue->fContentType      == rValue->fContentType)      &&
              XMLString::equals(lValue->fTypeName,      rValue->fTypeName)      &&
              XMLString::equals(lValue->fTypeLocalName, rValue->fTypeLocalName) &&
              XMLString::equals(lValue->fTypeUri,       rValue->fTypeUri)       &&
              isEquivalent(lValue->fBaseDatatypeValidator
                         , rValue->fBaseDatatypeValidator)                      &&
              isEquivalent(lValue->fDatatypeValidator
                         , rValue->fDatatypeValidator)                          &&
              isEquivalent(lValue->fBaseComplexTypeInfo
                         , rValue->fBaseComplexTypeInfo)                        &&
              isEquivalent(lValue->fContentSpec
                         , rValue->fContentSpec)                                &&
              isEquivalent(lValue->fAttWildCard
                         , rValue->fAttWildCard)                                &&
              isEquivalent(lValue->fAttList
                         , rValue->fAttList)                                    &&
              XTemplateComparator::isEquivalent(lValue->fElements
                                              , rValue->fElements)              &&
              XTemplateComparator::isEquivalent(lValue->fAttDefs
                                              , rValue->fAttDefs)              
          );
  
  #else
  
      bool v1 =  lValue->fAnonymous        == rValue->fAnonymous;
      bool v2 =  lValue->fAbstract         == rValue->fAbstract;         
      bool v3 =  lValue->fAdoptContentSpec == rValue->fAdoptContentSpec;
      bool v4 =  lValue->fAttWithTypeId    == rValue->fAttWithTypeId;  
      bool v5 =  lValue->fPreprocessed     == rValue->fPreprocessed;     
      bool v6 =  lValue->fDerivedBy        == rValue->fDerivedBy;      
      bool v7 =  lValue->fBlockSet         == rValue->fBlockSet;         
      bool v8 =  lValue->fFinalSet         == rValue->fFinalSet;          
      bool v9 =  lValue->fScopeDefined     == rValue->fScopeDefined;
      bool v10 = lValue->fElementId        == rValue->fElementId;      
      bool v11 = lValue->fContentType      == rValue->fContentType;
      bool v12 = XMLString::equals(lValue->fTypeName
                                 , rValue->fTypeName);
      bool v13 = XMLString::equals(lValue->fTypeLocalName
                                 , rValue->fTypeLocalName);
      bool v14 = XMLString::equals(lValue->fTypeUri
                                 , rValue->fTypeUri);
      bool v15 = isEquivalent(lValue->fBaseDatatypeValidator
                            , rValue->fBaseDatatypeValidator);
      bool v16 = isEquivalent(lValue->fDatatypeValidator
                            , rValue->fDatatypeValidator);
      bool v17 = isEquivalent(lValue->fBaseComplexTypeInfo
                            , rValue->fBaseComplexTypeInfo);
      bool v18 = isEquivalent(lValue->fContentSpec
                            , rValue->fContentSpec);
      bool v19 = isEquivalent(lValue->fAttWildCard
                            , rValue->fAttWildCard);
      bool v20 = isEquivalent(lValue->fAttList
                            , rValue->fAttList);
      bool v21 = XTemplateComparator::isEquivalent(lValue->fElements
                                                 , rValue->fElements);
      bool v22 = XTemplateComparator::isEquivalent(lValue->fAttDefs
                                                 , rValue->fAttDefs);
                                                         
      return v1&&v2&&v3&&v4&&v5&&v6&&v7&&v8&&v9&&v10&&v11&&v12&&v13&&v14&&v15&&v16&&v17&&v18&&v19&&v20&&v21&&v22;
  
  #endif
  
  }
  
  bool XObjectComparator::isEquivalent(XercesGroupInfo* const lValue
                                     , XercesGroupInfo* const rValue )
  {
  
      IS_EQUIVALENT(lValue, rValue)
  
      //    don't compare
      //    XSDLocator*                     fLocator;
  
      return (
              (lValue->fCheckElementConsistency == rValue->fCheckElementConsistency)  &&
              (lValue->fScope                   == rValue->fScope)                    &&
              isEquivalent(lValue->fContentSpec
                         , rValue->fContentSpec)                                      &&
              isEquivalent(lValue->fBaseGroup
                         , rValue->fBaseGroup)                                        &&
              XTemplateComparator::isEquivalent(lValue->fElements
                                              , rValue->fElements)              
             );
  
  }
  
  bool XObjectComparator::isEquivalent(XercesAttGroupInfo* const lValue
                                     , XercesAttGroupInfo* const rValue )
  {
  
      IS_EQUIVALENT(lValue, rValue)
  
      return (
              (lValue->fTypeWithId == rValue->fTypeWithId)              &&
              isEquivalent(lValue->fCompleteWildCard
                         , rValue->fCompleteWildCard)                   &&
              XTemplateComparator::isEquivalent(lValue->fAttributes
                                              , rValue->fAttributes)    &&
              XTemplateComparator::isEquivalent(lValue->fAnyAttributes
                                              , rValue->fAnyAttributes)
             );
  
  }
  
  /**********************************************************
   *
   * DatatypeValidator
   *
   *
   * DatatypeValidatorFactory
   *
   ***********************************************************/   
  bool XObjectComparator::isEquivalent(DatatypeValidator* const lValue
                                     , DatatypeValidator* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      if (lValue->getType() != rValue->getType())
      {
          return false;
      }
  
      //todo
      //to call individual isEquivalent according to the actual type
      //
      return true;
  }
  
  bool XObjectComparator::isBaseEquivalent(DatatypeValidator* const lValue
                                         , DatatypeValidator* const rValue)
  {
      //todo
      return true;
  }
  
  bool XObjectComparator::isEquivalent(DatatypeValidatorFactory* const lValue
                                     , DatatypeValidatorFactory* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      return XTemplateComparator::isEquivalent(lValue->fUserDefinedRegistry
                                             , rValue->fUserDefinedRegistry);
  
  }
  
  /**********************************************************
   *
   * ContentSpecNode
   * QName
   * KVStringPair
   * XMLRefInfo
   * StringPool
   *
   ***********************************************************/   
  bool XObjectComparator::isEquivalent(ContentSpecNode* const lValue
                                     , ContentSpecNode* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      return (
              (lValue->fType        == rValue->fType)                        &&
              (lValue->fAdoptFirst  == rValue->fAdoptFirst)                  &&
              (lValue->fAdoptSecond == rValue->fAdoptSecond)                 &&
              (lValue->fMinOccurs   == rValue->fMinOccurs)                   &&
              (lValue->fMaxOccurs   == rValue->fMaxOccurs)                   &&
              isEquivalent(lValue->fElement, rValue->fElement)        &&
              isEquivalent(lValue->fFirst,  rValue->fFirst) &&
              isEquivalent(lValue->fSecond, rValue->fSecond) 
              );
  
  }
  
  bool XObjectComparator::isEquivalent(QName* const lValue
                                     , QName* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      return (XMLString::equals(lValue->fPrefix, rValue->fPrefix)       &&
              XMLString::equals(lValue->fLocalPart, rValue->fLocalPart) &&
              (lValue->fURIId == rValue->fURIId)
             );
  }
  
  bool XObjectComparator::isEquivalent(KVStringPair* const lValue
                                     , KVStringPair* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      return (XMLString::equals(lValue->fKey, rValue->fKey)     &&
              XMLString::equals(lValue->fValue, rValue->fValue)
             );
  }
  
  bool XObjectComparator::isEquivalent(XMLRefInfo* const lValue
                                     , XMLRefInfo* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      return (
              (lValue->fDeclared == rValue->fDeclared)              &&
              (lValue->fUsed     == rValue->fUsed)                  &&
              XMLString::equals(lValue->fRefName, rValue->fRefName) 
             );
  }
  
  bool XObjectComparator::isEquivalent(XMLStringPool* const lValue
                                     , XMLStringPool* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      if (lValue->getStringCount() != rValue->getStringCount())
          return false;
  
      for (unsigned int i = 1; i < lValue->getStringCount(); i++)
      {
          if (!XMLString::equals(lValue->getValueForId(i), rValue->getValueForId(i)))
              return false;
      }
  
      return true;
  }
  
  /**********************************************************
   *
   * XercesNodeTest
   * XercesStep
   * XercesLocationPath
   * XercesXPath
   *
   ***********************************************************/ 
  bool XObjectComparator::isEquivalent(XercesNodeTest* const lValue
                                     , XercesNodeTest* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      return (
               (lValue->fType == rValue->fType)           &&
               isEquivalent(lValue->fName, rValue->fName) 
             );
     
  }
    
  bool XObjectComparator::isEquivalent(XercesStep* const lValue
                                     , XercesStep* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      return (
               (lValue->fAxisType == rValue->fAxisType)  &&
               isEquivalent(lValue->fNodeTest, rValue->fNodeTest) 
             );
     
  }
  
  bool XObjectComparator::isEquivalent(XercesLocationPath* const lValue
                                     , XercesLocationPath* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      return (
               XTemplateComparator::isEquivalent(lValue->fSteps, rValue->fSteps) 
             );
     
  }
  
  bool XObjectComparator::isEquivalent(XercesXPath* const lValue
                                     , XercesXPath* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      return (
               (lValue->fEmptyNamespaceId == rValue->fEmptyNamespaceId)  &&
               XMLString::equals(lValue->fExpression
                               , rValue->fExpression)                    &&
               XTemplateComparator::isEquivalent(lValue->fLocationPaths
                                               , rValue->fLocationPaths) 
              );
     
  }
  
  /**********************************************************
   *
   * IC_Field
   * IC_Select
   *
   * IdentityConstraint
   *   IC_Key
   *   IC_KeyRef
   *   IC_Unique
   *
   *
   ***********************************************************/   
  bool XObjectComparator::isEquivalent(IC_Field* const lValue
                                     , IC_Field* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      return (
               (lValue->fMayMatch == rValue->fMayMatch)  &&
               isEquivalent(lValue->fXPath
                          , rValue->fXPath)              &&
               isEquivalent(lValue->fIdentityConstraint
                          , rValue->fIdentityConstraint) 
              );
     
  }
  
  bool XObjectComparator::isEquivalent(IC_Selector* const lValue
                                     , IC_Selector* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      return (
               isEquivalent(lValue->fXPath
                          , rValue->fXPath)              &&
               isEquivalent(lValue->fIdentityConstraint
                          , rValue->fIdentityConstraint) 
              );
     
  }
  
  bool XObjectComparator::isEquivalent(IdentityConstraint* const lValue
                                     , IdentityConstraint* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      if (lValue->getType() != rValue->getType())
      {
          //throw exception here
          return false;
      }
  
      switch(lValue->getType())
      {
      case IdentityConstraint::UNIQUE: 
          return isEquivalent((IC_Unique*)lValue, (IC_Unique*)rValue);
          break;
      case IdentityConstraint::KEY:
          return isEquivalent((IC_Key*)lValue, (IC_Key*)rValue);
          break;
      case IdentityConstraint::KEYREF: 
          return isEquivalent((IC_KeyRef*)lValue, (IC_KeyRef*)rValue);
          break;
      default: 
          //throw exception here
          return false;
          break;
      }
    
  }
  
  bool XObjectComparator::isBaseEquivalent(IdentityConstraint* const lValue
                                         , IdentityConstraint* const rValue)
  {
  
      return (
               XMLString::equals(lValue->fIdentityConstraintName
                               , rValue->fIdentityConstraintName)    &&
               XMLString::equals(lValue->fElemName
                               , rValue->fElemName)                  &&
               isEquivalent(lValue->fSelector, rValue->fSelector)    &&
               XTemplateComparator::isEquivalent(lValue->fFields
                                               , rValue->fFields)
              );         
                       
  }
  
  bool XObjectComparator::isEquivalent(IC_Key* const lValue
                                     , IC_Key* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      if (!isBaseEquivalent(lValue, rValue))
          return false;
  
      // no data
      return true;
  }
  
  bool XObjectComparator::isEquivalent(IC_KeyRef* const lValue
                                     , IC_KeyRef* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      if (!isBaseEquivalent(lValue, rValue))
          return false;
  
      return isEquivalent(lValue->fKey, rValue->fKey);
  
  }
  
  bool XObjectComparator::isEquivalent(IC_Unique* const lValue
                                     , IC_Unique* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      if (!isBaseEquivalent(lValue, rValue))
          return false;
  
      // no data
      return true;
  }
  
  /**********************************************************
   * XMLNumber
   *   XMLDouble
   *   XMLFloat
   *   XMLBigDecimal
   *   XMLDateTime
   *
   ***********************************************************/   
  bool XObjectComparator::isEquivalent(XMLNumber* const lValue
                                     , XMLNumber* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      //to do, to introduce numberType later
      return true;
  }
  
  XERCES_CPP_NAMESPACE_END
  
  
  
  
  1.1                  xml-xerces/c/src/xercesc/internal/XObjectComparator.hpp
  
  Index: XObjectComparator.hpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xerces" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache\@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation, and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com .  For more information
   * on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   * $Log: XObjectComparator.hpp,v $
   * Revision 1.1  2003/10/29 16:14:15  peiyongz
   * XObjectComparator/XTemplateComparator
   *
   * $Id: XObjectComparator.hpp,v 1.1 2003/10/29 16:14:15 peiyongz Exp $
   *
   */
  
  #if !defined(XOBJECT_COMPARATOR_HPP)
  #define XOBJECT_COMPARATOR_HPP
  
  #include <xercesc/framework/XMLNotationDecl.hpp>
  #include <xercesc/framework/XMLRefInfo.hpp>
  #include <xercesc/framework/XMLDTDDescription.hpp>
  #include <xercesc/framework/XMLSchemaDescription.hpp>
  
  #include <xercesc/internal/XMLGrammarPoolImpl.hpp>
  
  #include <xercesc/util/XMLNumber.hpp>
  #include <xercesc/util/KVStringPair.hpp>
  
  #include <xercesc/validators/common/ContentSpecNode.hpp>
  
  #include <xercesc/validators/DTD/DTDAttDef.hpp>
  #include <xercesc/validators/DTD/DTDAttDefList.hpp>
  #include <xercesc/validators/DTD/DTDElementDecl.hpp>
  #include <xercesc/validators/DTD/DTDEntityDecl.hpp>
  #include <xercesc/validators/DTD/DTDGrammar.hpp>
  
  #include <xercesc/validators/schema/SchemaAttDef.hpp>
  #include <xercesc/validators/schema/SchemaAttDefList.hpp>
  #include <xercesc/validators/schema/SchemaElementDecl.hpp>
  #include <xercesc/validators/schema/XercesGroupInfo.hpp>
  #include <xercesc/validators/schema/XercesAttGroupInfo.hpp>
  #include <xercesc/validators/schema/SchemaGrammar.hpp>
  
  #include <xercesc/validators/schema/identity/IC_Field.hpp>
  #include <xercesc/validators/schema/identity/IC_Selector.hpp>
  #include <xercesc/validators/schema/identity/IC_Key.hpp>
  #include <xercesc/validators/schema/identity/IC_KeyRef.hpp>
  #include <xercesc/validators/schema/identity/IC_Unique.hpp>
  #include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
  #include <xercesc/validators/schema/identity/XercesXPath.hpp>
  
  XERCES_CPP_NAMESPACE_BEGIN
  
  class XMLUTIL_EXPORT XObjectComparator
  {
  public:
  
  /**********************************************************
   *
   * XMLGrammarPoolImpl
   *
   * Grammar
   *
   *   SchemaGrammar
   *   DTDGrammar
   *
   ***********************************************************/   
      static bool isEquivalent
                  (
                      XMLGrammarPoolImpl* const
                    , XMLGrammarPoolImpl* const
                  );
  
      static bool isEquivalent
                  (
                      Grammar* const
                    , Grammar* const
                  );
  
      static bool isBaseEquivalent
                  (
                      Grammar* const
                    , Grammar* const
                  );
  
      static bool isEquivalent
                  (
                     SchemaGrammar* const
                   , SchemaGrammar* const
                  );
  
  /**********************************************************
   *
   * XMLGrammarDescription
   *
   *   XMLSchemaDescription
   *   XMLDTDDescription
   *
   ***********************************************************/   
      static bool isEquivalent
                  (
                      XMLSchemaDescription* const
                    , XMLSchemaDescription* const
                  );
  
      static bool isEquivalent
                  (
                     XMLDTDDescription* const
                   , XMLDTDDescription* const
                  );
  
  /**********************************************************
   *
   * XMLElementDecl
   *   SchemaElementDecl
   *   DTDElementDecl
   *
   ***********************************************************/    
      static bool isBaseEquivalent
                  (
                      XMLElementDecl* const
                    , XMLElementDecl* const
                  );
  
      static bool isEquivalent
                  (
                     SchemaElementDecl* const
                   , SchemaElementDecl* const
                  );
  
      static bool isEquivalent
                  (
                     DTDElementDecl* const
                   , DTDElementDecl* const
                  );
  
  /**********************************************************
   * XMLAttDef
   *   SchemaAttDef
   *   DTDAttDef
   *
  ***********************************************************/    
      static bool isBaseEquivalent
                  (
                     XMLAttDef* const
                   , XMLAttDef* const
                  );
  
      static bool isEquivalent
                  (
                      SchemaAttDef* const
                    , SchemaAttDef* const
                  );
  
      static bool isEquivalent
                  (
                      DTDAttDef* const
                    , DTDAttDef* const
                  );
  
  /**********************************************************
   * XMLAttDefList
   *   SchemaAttDefList
   *   DTDAttDefList
   *
  ***********************************************************/   
      static bool isBaseEquivalent
                  (
                     XMLAttDefList* const
                   , XMLAttDefList* const
                  );
      
      static bool isEquivalent
                  (
                      SchemaAttDefList* const
                    , SchemaAttDefList* const
                  );
  
      static bool isEquivalent
                  (
                      DTDAttDefList* const
                    , DTDAttDefList* const
                  );
  
  /**********************************************************
   * XMLEntityDecl
   *    DTDEntityDecl
   *
   ***********************************************************/   
      static bool isBaseEquivalent
                  (
                      XMLEntityDecl* const
                    , XMLEntityDecl* const
                  );
  
      static bool isEquivalent
                  (
                      DTDEntityDecl* const
                    , DTDEntityDecl* const
                  );
  
  /**********************************************************
   * XMLNotationDecl
   *
   * DTDEntityDecl
   *
   * ComplexTypeInfo
   * XercesGroupInfo
   * XercesAttGroupInfo
   ***********************************************************/   
      static bool isEquivalent
                  (
                      XMLNotationDecl* const
                    , XMLNotationDecl* const
                  );
     
      static bool isEquivalent
                  (
                      ComplexTypeInfo* const
                    , ComplexTypeInfo* const
                  );
  
      static bool isEquivalent
                  (
                      XercesGroupInfo* const
                    , XercesGroupInfo* const
                  );
  
      static bool isEquivalent
                  (
                      XercesAttGroupInfo* const
                    , XercesAttGroupInfo* const
                  );
  
  /**********************************************************
   *
   * DatatypeValidator
   *
   *
   * DatatypeValidatorFactory
   *
   ***********************************************************/   
  
      static bool isEquivalent
                  (
                     DatatypeValidator* const
                   , DatatypeValidator* const
                  );
  
      static bool isBaseEquivalent
                  (
                     DatatypeValidator* const
                   , DatatypeValidator* const
                  );
  
      static bool isEquivalent
                  (
                     DatatypeValidatorFactory* const
                   , DatatypeValidatorFactory* const
                  );
  
  /**********************************************************
   *
   * ContentSpecNode
   * QName
   * KVStringPair
   * XMLRefInfo
   * XMLStringPool
   *
   ***********************************************************/   
      static bool isEquivalent
                  (
                     ContentSpecNode* const
                   , ContentSpecNode* const
                  );
  
      static bool isEquivalent
                  (
                     QName* const
                   , QName* const
                  );
  
      static bool isEquivalent
                  (
                     KVStringPair* const
                   , KVStringPair* const
                  );
  
      static bool isEquivalent
                  (
                     XMLRefInfo* const
                   , XMLRefInfo* const
                  );
  
      static bool isEquivalent
                  (
                     XMLStringPool* const
                   , XMLStringPool* const
                  );
  
  /**********************************************************
   *
   * XercesNodeTest
   * XercesStep
   * XercesLocationPath
   * XercesXPath
   *
  ***********************************************************/   
      static bool isEquivalent
                  (
                     XercesNodeTest* const
                   , XercesNodeTest* const
                  );
  
      static bool isEquivalent
                  (
                     XercesStep* const
                   , XercesStep* const
                  );
  
      static bool isEquivalent
                  (
                     XercesLocationPath* const
                   , XercesLocationPath* const
                  );
  
      static bool isEquivalent
                  (
                     XercesXPath* const
                   , XercesXPath* const
                  );
  
  /**********************************************************
   *
   * IC_Field
   * IC_Selector
   *
   * IdentityConstraint
   *   IC_Key
   *   IC_KeyRef
   *   IC_Unique
   *
   ***********************************************************/   
      static bool isEquivalent
                  (
                     IC_Field* const
                   , IC_Field* const
                  );
  
      static bool isEquivalent
                  (
                     IC_Selector* const
                   , IC_Selector* const
                  );
  
      static bool isEquivalent
                  (
                     IdentityConstraint* const
                   , IdentityConstraint* const
                  );
  
      static bool isBaseEquivalent
                  (
                     IdentityConstraint* const
                   , IdentityConstraint* const
                  );
  
      static bool isEquivalent
                  (
                     IC_Key* const
                   , IC_Key* const
                  );
  
      static bool isEquivalent
                  (
                     IC_KeyRef* const
                   , IC_KeyRef* const
                  );
  
      static bool isEquivalent
                  (
                     IC_Unique* const
                   , IC_Unique* const
                  );
  
  /**********************************************************
   * XMLNumber
   *   XMLDouble
   *   XMLFloat
   *   XMLBigDecimal
   *   XMLDateTime
   *
   ***********************************************************/   
      static bool isEquivalent
                  (
                     XMLNumber* const
                   , XMLNumber* const
                  );
  
  private:
      // -----------------------------------------------------------------------
      //  Unimplemented constructors and operators
      // -----------------------------------------------------------------------
  	~XObjectComparator();
      XObjectComparator();
      XObjectComparator(const XObjectComparator&);
  	XObjectComparator& operator=(const XObjectComparator&);
  
  };
  
  XERCES_CPP_NAMESPACE_END
  
  #endif
  
  
  
  1.1                  xml-xerces/c/src/xercesc/internal/XTemplateComparator.cpp
  
  Index: XTemplateComparator.cpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xerces" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache\@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation, and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com .  For more information
   * on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
  /*
   * $Log: XTemplateComparator.cpp,v $
   * Revision 1.1  2003/10/29 16:14:15  peiyongz
   * XObjectComparator/XTemplateComparator
   *
   * $Id: XTemplateComparator.cpp,v 1.1 2003/10/29 16:14:15 peiyongz Exp $
   *
   */
  
  // ---------------------------------------------------------------------------
  //  Includes
  // ---------------------------------------------------------------------------
  #include <xercesc/internal/XTemplateComparator.hpp>
  #include <xercesc/internal/XObjectComparator.hpp>
  
  XERCES_CPP_NAMESPACE_BEGIN
  
      /**********************************************************
       *
       * ValueVectorOf
       *
       *   SchemaElementDecl*
       *   unsigned int
       *
       ***********************************************************/   
  bool XTemplateComparator::isEquivalent(ValueVectorOf<SchemaElementDecl*>* const lValue
                                       , ValueVectorOf<SchemaElementDecl*>* const rValue)
  {
  
      IS_EQUIVALENT(lValue, rValue);
  
      int size1 = lValue->size();
      int size2 = rValue->size();
  
      if (size1 != size2)
          return false;
  
      for ( int i = 0; i < size1; i++)
      {            
          SchemaElementDecl*& data1 = lValue->elementAt(i);
          SchemaElementDecl*& data2 = rValue->elementAt(i);
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
      }
  
      return true;
  }
  
  bool XTemplateComparator::isEquivalent(ValueVectorOf<unsigned int>* const lValue
                                       , ValueVectorOf<unsigned int>* const rValue)
                                       
  {
  
      IS_EQUIVALENT(lValue, rValue);
  
      int size1 = lValue->size();
      int size2 = rValue->size();
  
      if (size1 != size2)
          return false;
  
      for ( int i = 0; i < size1; i++)
      {            
          unsigned int& data1 = lValue->elementAt(i);
          unsigned int& data2 = rValue->elementAt(i);
          if (data1!=data2)
              return false;
      }
  
      return true;
  
  }
  
      /**********************************************************
       *
       * RefArrayVectorOf
       *
       *   XMLCh
       *
       ***********************************************************/   
  bool XTemplateComparator::isEquivalent(RefArrayVectorOf<XMLCh>* const lValue
                                       , RefArrayVectorOf<XMLCh>* const rValue)
  {
  
      IS_EQUIVALENT(lValue, rValue);
  
      int size1 = lValue->size();
      int size2 = rValue->size();
  
      if (size1 != size2)
          return false;
  
      for ( int i = 0; i < size1; i++)
      {            
          XMLCh* data1 = lValue->elementAt(i);
          XMLCh* data2 = rValue->elementAt(i);
  
          if (!XMLString::equals(data1, data2))
          {            
              return false;
          }
      }
  
      return true;
  
  }
  
      /**********************************************************
       *
       * RefVectorOf
       *
       *   SchemaAttDef
       *   SchemaElementDecl
       *   ContentSpecNode
       *   IC_Field
       *   DatatypeValidator
       *   IdentityConstraint
       *   XMLNumber
       *   XercesLocationPath
       *   XercesStep
       *
       ***********************************************************/
  bool XTemplateComparator::isEquivalent(RefVectorOf<SchemaAttDef>* const lValue
                                       , RefVectorOf<SchemaAttDef>* const rValue)
  {
  
      IS_EQUIVALENT(lValue, rValue);
  
      int size1 = lValue->size();
      int size2 = rValue->size();
  
      if (size1 != size2)
          return false;
  
      for ( int i = 0; i < size1; i++)
      {            
          SchemaAttDef* data1 = lValue->elementAt(i);
          SchemaAttDef* data2 = rValue->elementAt(i);
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
      }
  
      return true;
  }
  
  bool XTemplateComparator::isEquivalent(RefVectorOf<SchemaElementDecl>* const lValue
                                       , RefVectorOf<SchemaElementDecl>* const rValue)
  {
  
      IS_EQUIVALENT(lValue, rValue);
  
      int size1 = lValue->size();
      int size2 = rValue->size();
  
      if (size1 != size2)
          return false;
  
      for ( int i = 0; i < size1; i++)
      {            
          SchemaElementDecl* data1 = lValue->elementAt(i);
          SchemaElementDecl* data2 = rValue->elementAt(i);
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
      }
  
      return true;
  }
  
  bool XTemplateComparator::isEquivalent(RefVectorOf<ContentSpecNode>* const lValue
                                       , RefVectorOf<ContentSpecNode>* const rValue)
  {
  
      IS_EQUIVALENT(lValue, rValue);
  
      int size1 = lValue->size();
      int size2 = rValue->size();
  
      if (size1 != size2)
          return false;
  
      for ( int i = 0; i < size1; i++)
      {            
          ContentSpecNode* data1 = lValue->elementAt(i);
          ContentSpecNode* data2 = rValue->elementAt(i);
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
      }
  
      return true;
  
  }
  
  bool XTemplateComparator::isEquivalent(RefVectorOf<IC_Field>* const lValue
                                       , RefVectorOf<IC_Field>* const rValue)
  {
  
      IS_EQUIVALENT(lValue, rValue);
  
      int size1 = lValue->size();
      int size2 = rValue->size();
  
      if (size1 != size2)
          return false;
  
      for ( int i = 0; i < size1; i++)
      {            
          IC_Field* data1 = lValue->elementAt(i);
          IC_Field* data2 = rValue->elementAt(i);
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
      }
  
      return true;
  
  }
  
  bool XTemplateComparator::isEquivalent(RefVectorOf<DatatypeValidator>* const lValue
                                       , RefVectorOf<DatatypeValidator>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      int size1 = lValue->size();
      int size2 = rValue->size();
  
      if (size1 != size2)
          return false;
  
      for ( int i = 0; i < size1; i++)
      {            
          DatatypeValidator* data1 = lValue->elementAt(i);
          DatatypeValidator* data2 = rValue->elementAt(i);
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
      }
  
      return true;
  }
  
  bool XTemplateComparator::isEquivalent(RefVectorOf<IdentityConstraint>* const lValue
                                       , RefVectorOf<IdentityConstraint>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      int size1 = lValue->size();
      int size2 = rValue->size();
  
      if (size1 != size2)
          return false;
  
      for ( int i = 0; i < size1; i++)
      {            
          IdentityConstraint* data1 = lValue->elementAt(i);
          IdentityConstraint* data2 = rValue->elementAt(i);
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
      }
  
      return true;
  }
  
  bool XTemplateComparator::isEquivalent(RefVectorOf<XMLNumber>* const lValue
                                       , RefVectorOf<XMLNumber>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      int size1 = lValue->size();
      int size2 = rValue->size();
  
      if (size1 != size2)
          return false;
  
      for ( int i = 0; i < size1; i++)
      {            
          XMLNumber* data1 = lValue->elementAt(i);
          XMLNumber* data2 = rValue->elementAt(i);
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
      }
  
      return true;
  }
  
  bool XTemplateComparator::isEquivalent(RefVectorOf<XercesLocationPath>* const lValue
                                       , RefVectorOf<XercesLocationPath>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      int size1 = lValue->size();
      int size2 = rValue->size();
  
      if (size1 != size2)
          return false;
  
      for ( int i = 0; i < size1; i++)
      {            
          XercesLocationPath* data1 = lValue->elementAt(i);
          XercesLocationPath* data2 = rValue->elementAt(i);
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
      }
  
      return true;
  }
  
  bool XTemplateComparator::isEquivalent(RefVectorOf<XercesStep>* const lValue
                                       , RefVectorOf<XercesStep>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      int size1 = lValue->size();
      int size2 = rValue->size();
  
      if (size1 != size2)
          return false;
  
      for ( int i = 0; i < size1; i++)
      {            
          XercesStep* data1 = lValue->elementAt(i);
          XercesStep* data2 = rValue->elementAt(i);
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
      }
  
      return true;
  }
  
      /**********************************************************
       *
       * RefHashTableOf
       *
       *   KVStringPair
       *   XMLAttDef
       *   DTDAttDef
       *   ComplexTypeInfo
       *   XercesGroupInfo
       *   XercesAttGroupInfo
       *   XMLRefInfo
       *   DatatypeValidator
       *   Grammar
       *
       ***********************************************************/
  bool XTemplateComparator::isEquivalent(RefHashTableOf<KVStringPair>* const lValue
                                       , RefHashTableOf<KVStringPair>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      RefHashTableOfEnumerator<KVStringPair> lEnum(lValue);
      int lItemNumber = 0;        
      while (lEnum.hasMoreElements())
      {
          lEnum.nextElement();
          lItemNumber++;
      }
  
      RefHashTableOfEnumerator<KVStringPair> rEnum(lValue);
      int rItemNumber = 0;        
      while (rEnum.hasMoreElements())
      {
          rEnum.nextElement();
          rItemNumber++;
      }
  
      //both shall have the number of item in it
      if (lItemNumber != rItemNumber)
          return false;
  
      //Any thing in the lValue shall be found in the rValue
      lEnum.Reset();
      while (lEnum.hasMoreElements())
      {
          XMLCh*        key   = (XMLCh*) lEnum.nextElementKey();
          KVStringPair* data1 = lValue->get(key);
          KVStringPair* data2 = rValue->get(key);
  
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
  
      }  
  
      return true;
  }
  
  bool XTemplateComparator::isEquivalent(RefHashTableOf<XMLAttDef>* const lValue
                                       , RefHashTableOf<XMLAttDef>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      RefHashTableOfEnumerator<XMLAttDef> lEnum(lValue);
      int lItemNumber = 0;        
      while (lEnum.hasMoreElements())
      {
          lEnum.nextElement();
          lItemNumber++;
      }
  
      RefHashTableOfEnumerator<XMLAttDef> rEnum(lValue);
      int rItemNumber = 0;        
      while (rEnum.hasMoreElements())
      {
          rEnum.nextElement();
          rItemNumber++;
      }
  
      //both shall have the number of item in it
      if (lItemNumber != rItemNumber)
          return false;
  
      //Any thing in the lValue shall be found in the rValue
      lEnum.Reset();
      while (lEnum.hasMoreElements())
      {
          XMLCh*     key   = (XMLCh*) lEnum.nextElementKey();
          //we know they are SchemaAttDef
          SchemaAttDef* data1 = (SchemaAttDef*) lValue->get(key);
          SchemaAttDef* data2 = (SchemaAttDef*) rValue->get(key);
  
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
  
      }  
  
      return true;
  
  }
  
  bool XTemplateComparator::isEquivalent(RefHashTableOf<DTDAttDef>* const lValue
                                       , RefHashTableOf<DTDAttDef>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      RefHashTableOfEnumerator<DTDAttDef> lEnum(lValue);
      int lItemNumber = 0;        
      while (lEnum.hasMoreElements())
      {
          lEnum.nextElement();
          lItemNumber++;
      }
  
      RefHashTableOfEnumerator<DTDAttDef> rEnum(lValue);
      int rItemNumber = 0;        
      while (rEnum.hasMoreElements())
      {
          rEnum.nextElement();
          rItemNumber++;
      }
  
      //both shall have the number of item in it
      if (lItemNumber != rItemNumber)
          return false;
  
      //Any thing in the lValue shall be found in the rValue
      lEnum.Reset();
      while (lEnum.hasMoreElements())
      {
          XMLCh*     key   = (XMLCh*) lEnum.nextElementKey();
          DTDAttDef* data1 = (DTDAttDef*) lValue->get(key);
          DTDAttDef* data2 = (DTDAttDef*) rValue->get(key);
  
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
  
      }  
  
      return true;
  
  }
  
  bool XTemplateComparator::isEquivalent(RefHashTableOf<ComplexTypeInfo>* const lValue
                                       , RefHashTableOf<ComplexTypeInfo>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      RefHashTableOfEnumerator<ComplexTypeInfo> lEnum(lValue);
      int lItemNumber = 0;        
      while (lEnum.hasMoreElements())
      {
          lEnum.nextElement();
          lItemNumber++;
      }
  
      RefHashTableOfEnumerator<ComplexTypeInfo> rEnum(lValue);
      int rItemNumber = 0;        
      while (rEnum.hasMoreElements())
      {
          rEnum.nextElement();
          rItemNumber++;
      }
  
      //both shall have the number of item in it
      if (lItemNumber != rItemNumber)
          return false;
  
      //Any thing in the lValue shall be found in the rValue
      lEnum.Reset();
      while (lEnum.hasMoreElements())
      {
          XMLCh*           key   = (XMLCh*) lEnum.nextElementKey();
          ComplexTypeInfo* data1 = (ComplexTypeInfo*) lValue->get(key);
          ComplexTypeInfo* data2 = (ComplexTypeInfo*) rValue->get(key);
  
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
  
      }  
  
      return true;
  }
  
  bool XTemplateComparator::isEquivalent(RefHashTableOf<XercesGroupInfo>* const lValue
                                       , RefHashTableOf<XercesGroupInfo>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      RefHashTableOfEnumerator<XercesGroupInfo> lEnum(lValue);
      int lItemNumber = 0;        
      while (lEnum.hasMoreElements())
      {
          lEnum.nextElement();
          lItemNumber++;
      }
  
      RefHashTableOfEnumerator<XercesGroupInfo> rEnum(lValue);
      int rItemNumber = 0;        
      while (rEnum.hasMoreElements())
      {
          rEnum.nextElement();
          rItemNumber++;
      }
  
      //both shall have the number of item in it
      if (lItemNumber != rItemNumber)
          return false;
  
      //Any thing in the lValue shall be found in the rValue
      lEnum.Reset();
      while (lEnum.hasMoreElements())
      {
          XMLCh*           key   = (XMLCh*) lEnum.nextElementKey();
          XercesGroupInfo* data1 = (XercesGroupInfo*) lValue->get(key);
          XercesGroupInfo* data2 = (XercesGroupInfo*) rValue->get(key);
  
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
  
      }  
  
      return true;
  }
  
  bool XTemplateComparator::isEquivalent(RefHashTableOf<XercesAttGroupInfo>* const lValue
                                       , RefHashTableOf<XercesAttGroupInfo>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      RefHashTableOfEnumerator<XercesAttGroupInfo> lEnum(lValue);
      int lItemNumber = 0;        
      while (lEnum.hasMoreElements())
      {
          lEnum.nextElement();
          lItemNumber++;
      }
  
      RefHashTableOfEnumerator<XercesAttGroupInfo> rEnum(lValue);
      int rItemNumber = 0;        
      while (rEnum.hasMoreElements())
      {
          rEnum.nextElement();
          rItemNumber++;
      }
  
      //both shall have the number of item in it
      if (lItemNumber != rItemNumber)
          return false;
  
      //Any thing in the lValue shall be found in the rValue
      lEnum.Reset();
      while (lEnum.hasMoreElements())
      {
          XMLCh*              key   = (XMLCh*) lEnum.nextElementKey();
          XercesAttGroupInfo* data1 = (XercesAttGroupInfo*) lValue->get(key);
          XercesAttGroupInfo* data2 = (XercesAttGroupInfo*) rValue->get(key);
  
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
  
      }  
  
      return true;
  }
  
  bool XTemplateComparator::isEquivalent(RefHashTableOf<XMLRefInfo>* const lValue
                                       , RefHashTableOf<XMLRefInfo>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      RefHashTableOfEnumerator<XMLRefInfo> lEnum(lValue);
      int lItemNumber = 0;        
      while (lEnum.hasMoreElements())
      {
          lEnum.nextElement();
          lItemNumber++;
      }
  
      RefHashTableOfEnumerator<XMLRefInfo> rEnum(lValue);
      int rItemNumber = 0;        
      while (rEnum.hasMoreElements())
      {
          rEnum.nextElement();
          rItemNumber++;
      }
  
      //both shall have the number of item in it
      if (lItemNumber != rItemNumber)
          return false;
  
      //Any thing in the lValue shall be found in the rValue
      lEnum.Reset();
      while (lEnum.hasMoreElements())
      {
          XMLCh*      key   = (XMLCh*) lEnum.nextElementKey();
          XMLRefInfo* data1 = (XMLRefInfo*) lValue->get(key);
          XMLRefInfo* data2 = (XMLRefInfo*) rValue->get(key);
  
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
  
      }  
  
      return true;
  }
  
  bool XTemplateComparator::isEquivalent(RefHashTableOf<DatatypeValidator>* const lValue
                                       , RefHashTableOf<DatatypeValidator>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      RefHashTableOfEnumerator<DatatypeValidator> lEnum(lValue);
      int lItemNumber = 0;        
      while (lEnum.hasMoreElements())
      {
          lEnum.nextElement();
          lItemNumber++;
      }
  
      RefHashTableOfEnumerator<DatatypeValidator> rEnum(lValue);
      int rItemNumber = 0;        
      while (rEnum.hasMoreElements())
      {
          rEnum.nextElement();
          rItemNumber++;
      }
  
      //both shall have the number of item in it
      if (lItemNumber != rItemNumber)
          return false;
  
      //Any thing in the lValue shall be found in the rValue
      lEnum.Reset();
      while (lEnum.hasMoreElements())
      {
          XMLCh*             key   = (XMLCh*) lEnum.nextElementKey();
          DatatypeValidator* data1 = (DatatypeValidator*) lValue->get(key);
          DatatypeValidator* data2 = (DatatypeValidator*) rValue->get(key);
  
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
  
      }  
  
      return true;
  }
  
  bool XTemplateComparator::isEquivalent(RefHashTableOf<Grammar>* const lValue
                                       , RefHashTableOf<Grammar>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      RefHashTableOfEnumerator<Grammar> lEnum(lValue);
      int lItemNumber = 0;        
      while (lEnum.hasMoreElements())
      {
          lEnum.nextElement();
          lItemNumber++;
      }
  
      RefHashTableOfEnumerator<Grammar> rEnum(lValue);
      int rItemNumber = 0;        
      while (rEnum.hasMoreElements())
      {
          rEnum.nextElement();
          rItemNumber++;
      }
  
      //both shall have the number of item in it
      if (lItemNumber != rItemNumber)
          return false;
  
      //Any thing in the lValue shall be found in the rValue
      lEnum.Reset();
      while (lEnum.hasMoreElements())
      {
          XMLCh*   key   = (XMLCh*) lEnum.nextElementKey();
          Grammar* data1 = (Grammar*) lValue->get(key);
          Grammar* data2 = (Grammar*) rValue->get(key);
  
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
  
      }  
  
      return true;
  }
  
      /**********************************************************
       *
       * RefHash2KeysTableOf
       *
       *   SchemaAttDef
       *   ElemVector
       *
       ***********************************************************/
  bool XTemplateComparator::isEquivalent(RefHash2KeysTableOf<SchemaAttDef>* const lValue
                                       , RefHash2KeysTableOf<SchemaAttDef>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue);
  
      RefHash2KeysTableOfEnumerator<SchemaAttDef> lEnum(lValue);
      int lItemNumber = 0;        
      while (lEnum.hasMoreElements())
      {
          lEnum.nextElement();
          lItemNumber++;
      }
  
      RefHash2KeysTableOfEnumerator<SchemaAttDef> rEnum(lValue);
      int rItemNumber = 0;        
      while (rEnum.hasMoreElements())
      {
          rEnum.nextElement();
          rItemNumber++;
      }
  
      //both shall have the number of item in it
      if (lItemNumber != rItemNumber)
          return false;
  
      //Any thing in the lValue shall be found in the rValue
      lEnum.Reset();
      while (lEnum.hasMoreElements())
      {
          XMLCh*     key1;
          int        key2;
              
          lEnum.nextElementKey((void*&)key1, key2);
  
          SchemaAttDef* data1 = (SchemaAttDef*) lValue->get(key1, key2);
          SchemaAttDef* data2 = (SchemaAttDef*) rValue->get(key1, key2);
  
          if (!XObjectComparator::isEquivalent(data1, data2))
              return false;
  
      }  
  
      return true;
  }
  
  bool XTemplateComparator::isEquivalent(RefHash2KeysTableOf<ElemVector>* const lValue
                                       , RefHash2KeysTableOf<ElemVector>* const rValue)
  {
  
      IS_EQUIVALENT(lValue, rValue);
  
      RefHash2KeysTableOfEnumerator<ElemVector> lEnum(lValue);
      int lItemNumber = 0;        
      while (lEnum.hasMoreElements())
      {
          lEnum.nextElement();
          lItemNumber++;
      }
  
      RefHash2KeysTableOfEnumerator<ElemVector> rEnum(lValue);
      int rItemNumber = 0;        
      while (rEnum.hasMoreElements())
      {
          rEnum.nextElement();
          rItemNumber++;
      }
  
      //both shall have the number of item in it
      if (lItemNumber != rItemNumber)
          return false;
  
      //Any thing in the lValue shall be found in the rValue
      lEnum.Reset();
      while (lEnum.hasMoreElements())
      {
          XMLCh*     key1;
          int        key2;
              
          lEnum.nextElementKey((void*&)key1, key2);
  
          ElemVector* data1 = (ElemVector*) lValue->get(key1, key2);
          ElemVector* data2 = (ElemVector*) rValue->get(key1, key2);
  
          if (!isEquivalent(data1, data2))
              return false;
  
      }  
  
      return true;
  }
  
      /**********************************************************
       *
       * RefHash3KeysIdPool
       *
       *   SchemaElementDecl
       *
       ***********************************************************/
  bool XTemplateComparator::isEquivalent(RefHash3KeysIdPool<SchemaElementDecl>* const lValue
                                       , RefHash3KeysIdPool<SchemaElementDecl>* const rValue)
  {
  
      IS_EQUIVALENT(lValue, rValue)
  
      RefHash3KeysIdPoolEnumerator<SchemaElementDecl> lEnum(lValue);
      RefHash3KeysIdPoolEnumerator<SchemaElementDecl> rEnum(rValue);
  
      if (lEnum.size() != rEnum.size())
          return false;
  
      for (int i = 0; i < lEnum.size(); i++)
      {
          SchemaElementDecl&  lData = lEnum.nextElement();
          SchemaElementDecl&  rData = rEnum.nextElement();
  
          if (!XObjectComparator::isEquivalent(&lData, &rData))
              return false;
      }
  
      return true;
  
  }
  
      /**********************************************************
       *
       * NameIdPool
       *
       *   DTDElementDecl
       *   DTDEntityDecl
       *   XMLNotationDecl
       *
       ***********************************************************/
  bool XTemplateComparator::isEquivalent(NameIdPool<DTDElementDecl>* const lValue
                                       , NameIdPool<DTDElementDecl>* const rValue)
  {
  
      IS_EQUIVALENT(lValue, rValue)
  
      NameIdPoolEnumerator<DTDElementDecl> lEnum(lValue);
      NameIdPoolEnumerator<DTDElementDecl> rEnum(lValue);
  
      if (lEnum.size() != rEnum.size())
          return false;
  
      for (int i = 0; i < lEnum.size(); i++)
      {
          DTDElementDecl& lData = lEnum.nextElement();
          DTDElementDecl& rData = rEnum.nextElement();
  
          if (!XObjectComparator::isEquivalent(&lData, &rData))
              return false;
  
      }
  
      return true;
  
  }
  
  bool XTemplateComparator::isEquivalent(NameIdPool<DTDEntityDecl>* const lValue
                                       , NameIdPool<DTDEntityDecl>* const rValue)
  {
  
      IS_EQUIVALENT(lValue, rValue)
  
      NameIdPoolEnumerator<DTDEntityDecl> lEnum(lValue);
      NameIdPoolEnumerator<DTDEntityDecl> rEnum(lValue);
  
      if (lEnum.size() != rEnum.size())
          return false;
  
      for (int i = 0; i < lEnum.size(); i++)
      {
          DTDEntityDecl& lData = lEnum.nextElement();
          DTDEntityDecl& rData = rEnum.nextElement();
  
          if (!XObjectComparator::isEquivalent(&lData, &rData))
              return false;
  
      }
  
      return true;
  
  }
  
  bool XTemplateComparator::isEquivalent(NameIdPool<XMLNotationDecl>* const lValue
                                       , NameIdPool<XMLNotationDecl>* const rValue)
  {
      IS_EQUIVALENT(lValue, rValue)
  
      NameIdPoolEnumerator<XMLNotationDecl> lEnum(lValue);
      NameIdPoolEnumerator<XMLNotationDecl> rEnum(lValue);
  
      if (lEnum.size() != rEnum.size())
          return false;
  
      for (int i = 0; i < lEnum.size(); i++)
      {
          XMLNotationDecl& lData = lEnum.nextElement();
          XMLNotationDecl& rData = rEnum.nextElement();
  
          if (!XObjectComparator::isEquivalent(&lData, &rData))
              return false;
  
      }
  
      return true;
  
  }
  
  XERCES_CPP_NAMESPACE_END
  
  
  
  
  1.1                  xml-xerces/c/src/xercesc/internal/XTemplateComparator.hpp
  
  Index: XTemplateComparator.hpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xerces" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache\@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation, and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com .  For more information
   * on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   * $Log: XTemplateComparator.hpp,v $
   * Revision 1.1  2003/10/29 16:14:15  peiyongz
   * XObjectComparator/XTemplateComparator
   *
   * $Id: XTemplateComparator.hpp,v 1.1 2003/10/29 16:14:15 peiyongz Exp $
   *
   */
  
  #if !defined(XTEMPLATE_COMPARATOR_HPP)
  #define XTEMPLATE_COMPARATOR_HPP
  
  #include <xercesc/util/ValueVectorOf.hpp>
  #include <xercesc/util/RefArrayVectorOf.hpp>
  #include <xercesc/util/RefVectorOf.hpp>
  #include <xercesc/util/RefHashTableOf.hpp>
  #include <xercesc/util/RefHash2KeysTableOf.hpp>
  #include <xercesc/util/RefHash3KeysIdPool.hpp>
  #include <xercesc/util/NameIdPool.hpp>
  
  #include <xercesc/framework/XMLNotationDecl.hpp>
  #include <xercesc/framework/XMLRefInfo.hpp>
  #include <xercesc/util/XMLNumber.hpp>
  #include <xercesc/validators/common/ContentSpecNode.hpp>
  #include <xercesc/validators/DTD/DTDAttDef.hpp>
  #include <xercesc/validators/DTD/DTDElementDecl.hpp>
  #include <xercesc/validators/DTD/DTDEntityDecl.hpp>
  #include <xercesc/validators/schema/SchemaAttDef.hpp>
  #include <xercesc/validators/schema/SchemaElementDecl.hpp>
  #include <xercesc/validators/schema/XercesGroupInfo.hpp>
  #include <xercesc/validators/schema/XercesAttGroupInfo.hpp>
  #include <xercesc/validators/schema/SchemaGrammar.hpp>
  #include <xercesc/validators/schema/identity/IC_Field.hpp>
  #include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
  #include <xercesc/validators/schema/identity/XercesXPath.hpp>
  
  XERCES_CPP_NAMESPACE_BEGIN
  
  class XMLUTIL_EXPORT XTemplateComparator
  {
  public:
  
      /**********************************************************
       *
       * ValueVectorOf
       *
       *   SchemaElementDecl*
       *   unsigned int
       *
       ***********************************************************/   
      static bool           isEquivalent(
                                            ValueVectorOf<SchemaElementDecl*>* const lValue
                                          , ValueVectorOf<SchemaElementDecl*>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            ValueVectorOf<unsigned int>* const lValue
                                          , ValueVectorOf<unsigned int>* const rValue
                                         );
  
      /**********************************************************
       *
       * RefArrayVectorOf
       *
       *   XMLCh
       *
       ***********************************************************/   
      static bool           isEquivalent(
                                            RefArrayVectorOf<XMLCh>* const lValue
                                          , RefArrayVectorOf<XMLCh>* const rValue
                                         );
  
      /**********************************************************
       *
       * RefVectorOf
       *
       *   SchemaAttDef
       *   SchemaElementDecl
       *   ContentSpecNode
       *   IC_Field
       *   DatatypeValidator
       *   IdentityConstraint
       *   XMLNumber
       *   XercesLocationPath
       *   XercesStep
       *
       ***********************************************************/
      static bool           isEquivalent(
                                            RefVectorOf<SchemaAttDef>* const lValue
                                          , RefVectorOf<SchemaAttDef>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefVectorOf<SchemaElementDecl>* const lValue
                                          , RefVectorOf<SchemaElementDecl>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefVectorOf<ContentSpecNode>* const lValue
                                          , RefVectorOf<ContentSpecNode>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefVectorOf<IC_Field>* const lValue
                                          , RefVectorOf<IC_Field>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefVectorOf<DatatypeValidator>* const lValue
                                          , RefVectorOf<DatatypeValidator>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefVectorOf<IdentityConstraint>* const lValue
                                          , RefVectorOf<IdentityConstraint>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefVectorOf<XMLNumber>* const lValue
                                          , RefVectorOf<XMLNumber>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefVectorOf<XercesLocationPath>* const lValue
                                          , RefVectorOf<XercesLocationPath>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefVectorOf<XercesStep>* const lValue
                                          , RefVectorOf<XercesStep>* const rValue
                                         );
  
      /**********************************************************
       *
       * RefHashTableOf
       *
       *   KVStringPair
       *   XMLAttDef
       *   DTDAttDef
       *   ComplexTypeInfo
       *   XercesGroupInfo
       *   XercesAttGroupInfo
       *   XMLRefInfo
       *   DatatypeValidator
       *   Grammar
       *
       ***********************************************************/
      static bool           isEquivalent(
                                            RefHashTableOf<KVStringPair>* const lValue
                                          , RefHashTableOf<KVStringPair>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefHashTableOf<XMLAttDef>* const lValue
                                          , RefHashTableOf<XMLAttDef>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefHashTableOf<DTDAttDef>* const lValue
                                          , RefHashTableOf<DTDAttDef>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefHashTableOf<ComplexTypeInfo>* const lValue
                                          , RefHashTableOf<ComplexTypeInfo>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefHashTableOf<XercesGroupInfo>* const lValue
                                          , RefHashTableOf<XercesGroupInfo>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefHashTableOf<XercesAttGroupInfo>* const lValue
                                          , RefHashTableOf<XercesAttGroupInfo>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefHashTableOf<XMLRefInfo>* const lValue
                                          , RefHashTableOf<XMLRefInfo>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefHashTableOf<DatatypeValidator>* const lValue
                                          , RefHashTableOf<DatatypeValidator>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefHashTableOf<Grammar>* const lValue
                                          , RefHashTableOf<Grammar>* const rValue
                                         );
  
      /**********************************************************
       *
       * RefHash2KeysTableOf
       *
       *   SchemaAttDef
       *   ElemVector
       *
       ***********************************************************/
      static bool           isEquivalent(
                                            RefHash2KeysTableOf<SchemaAttDef>* const lValue
                                          , RefHash2KeysTableOf<SchemaAttDef>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            RefHash2KeysTableOf<ElemVector>* const lValue
                                          , RefHash2KeysTableOf<ElemVector>* const rValue
                                         );
  
      /**********************************************************
       *
       * RefHash3KeysIdPool
       *
       *   SchemaElementDecl
       *
       ***********************************************************/
      static bool           isEquivalent(
                                           RefHash3KeysIdPool<SchemaElementDecl>* const lop
                                         , RefHash3KeysIdPool<SchemaElementDecl>* const rop
                                        );
  
  
      /**********************************************************
       *
       * NameIdPool
       *
       *   DTDElementDecl
       *   DTDEntityDecl
       *   XMLNotationDecl
       *
       ***********************************************************/
      static bool           isEquivalent(
                                            NameIdPool<DTDElementDecl>* const lValue
                                          , NameIdPool<DTDElementDecl>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            NameIdPool<DTDEntityDecl>* const lValue
                                          , NameIdPool<DTDEntityDecl>* const rValue
                                         );
  
      static bool           isEquivalent(
                                            NameIdPool<XMLNotationDecl>* const lValue
                                          , NameIdPool<XMLNotationDecl>* const rValue
                                         );
  
  private:
      // -----------------------------------------------------------------------
      //  Unimplemented constructors and operators
      // -----------------------------------------------------------------------
  	~XTemplateComparator();
      XTemplateComparator();
      XTemplateComparator(const XTemplateComparator&);
  	XTemplateComparator& operator=(const XTemplateComparator&);
  
  };
  
  XERCES_CPP_NAMESPACE_END
  
  #endif
  
  
  

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