diff --git a/src/xercesc/internal/XMLScanner2.cpp b/src/xercesc/internal/XMLScanner2.cpp
index 2c7033df15a4396ee718ae4686e95cc34c55b21e..87e5211ce291161ac4023a3fde3ff71299c64f5e 100644
--- a/src/xercesc/internal/XMLScanner2.cpp
+++ b/src/xercesc/internal/XMLScanner2.cpp
@@ -88,7 +88,7 @@
 #include <xercesc/internal/XMLScanner.hpp>
 #include <xercesc/internal/EndOfEntityException.hpp>
 #include <xercesc/internal/XMLInternalErrorHandler.hpp>
-#include <xercesc/parsers/DOMParser.hpp>
+#include <xercesc/parsers/IDOMParser.hpp>
 #include <xercesc/dom/DOM_DOMException.hpp>
 #include <xercesc/sax/EntityResolver.hpp>
 #include <xercesc/validators/common/ContentLeafNameTypeVector.hpp>
@@ -229,19 +229,16 @@ XMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
             XMLAttDef*  attDef = 0;
             if (fGrammarType == Grammar::SchemaGrammarType) {
 
-                ComplexTypeInfo* typeInfo = ((SchemaElementDecl*)elemDecl)->getComplexTypeInfo();
-                if (typeInfo) {
-                    SchemaAttDef* attWildCard = typeInfo->getAttWildCard();
-
-                    if (attWildCard) {
-                        //if schema, see if we should lax or skip the validation of this attribute
-                        if (anyAttributeValidation(attWildCard, uriId, skipThisOne, laxThisOne)) {
-                            SchemaGrammar* sGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(getURIText(uriId));
-                            if (sGrammar && sGrammar->getGrammarType() == Grammar::SchemaGrammarType) {
-                                RefHashTableOf<XMLAttDef>* attRegistry = sGrammar->getAttributeDeclRegistry();
-                                if (attRegistry) {
-                                    attDefForWildCard = attRegistry->get(suffPtr);
-                                }
+                SchemaAttDef* attWildCard = ((SchemaElementDecl*)elemDecl)->getAttWildCard();
+
+                if (attWildCard) {
+                    //if schema, see if we should lax or skip the validation of this attribute
+                    if (anyAttributeValidation(attWildCard, uriId, skipThisOne, laxThisOne)) {
+                        SchemaGrammar* sGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(getURIText(uriId));
+                        if (sGrammar && sGrammar->getGrammarType() == Grammar::SchemaGrammarType) {
+                            RefHashTableOf<XMLAttDef>* attRegistry = sGrammar->getAttributeDeclRegistry();
+                            if (attRegistry) {
+                                attDefForWildCard = attRegistry->get(suffPtr);
                             }
                         }
                     }
@@ -1457,9 +1454,9 @@ void XMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* const
     Grammar* grammar = fGrammarResolver->getGrammar(uri);
 
     if (!grammar || grammar->getGrammarType() == Grammar::DTDGrammarType) {
-        DOMParser parser;
+        IDOMParser parser;
         XMLInternalErrorHandler internalErrorHandler(fErrorHandler);
-        parser.setValidationScheme(DOMParser::Val_Never);
+        parser.setValidationScheme(IDOMParser::Val_Never);
         parser.setDoNamespaces(true);
         parser.setErrorHandler((ErrorHandler*) &internalErrorHandler);
         parser.setEntityResolver(fEntityResolver);
@@ -1542,14 +1539,14 @@ void XMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* const
         if (internalErrorHandler.getSawFatal() && fExitOnFirstFatal)
             emitError(XMLErrs::SchemaScanFatalError);
 
-        DOM_Document  document = parser.getDocument(); //Our Grammar
+        IDOM_Document* document = parser.getDocument(); //Our Grammar
 
-        if (!document.isNull()) {
+        if (document != 0) {
 
-            DOM_Element root = document.getDocumentElement();// This is what we pass to TraverserSchema
-            if (!root.isNull())
+            IDOM_Element* root = document->getDocumentElement();// This is what we pass to TraverserSchema
+            if (root != 0)
             {
-                const XMLCh* newUri = root.getAttribute(SchemaSymbols::fgATT_TARGETNAMESPACE).rawBuffer();
+                const XMLCh* newUri = root->getAttribute(SchemaSymbols::fgATT_TARGETNAMESPACE);
                 if (XMLString::compareString(newUri, uri)) {
                     if (fValidate)
                         fValidator->emitError(XMLValid::WrongTargetNamespace, loc, uri);
diff --git a/src/xercesc/validators/schema/GeneralAttributeCheck.cpp b/src/xercesc/validators/schema/GeneralAttributeCheck.cpp
index eddf36c0da03f69d1691f3acefbcf4156d1e0e92..a5ee213bfac8875c318ec2353b4bf908d0d482a3 100644
--- a/src/xercesc/validators/schema/GeneralAttributeCheck.cpp
+++ b/src/xercesc/validators/schema/GeneralAttributeCheck.cpp
@@ -56,8 +56,11 @@
 
 /*
  * $Log$
- * Revision 1.1  2002/02/01 22:22:45  peiyongz
- * Initial revision
+ * Revision 1.2  2002/02/06 22:21:49  knoaman
+ * Use IDOM for schema processing.
+ *
+ * Revision 1.1.1.1  2002/02/01 22:22:45  peiyongz
+ * sane_include
  *
  * Revision 1.16  2002/01/02 19:50:34  knoaman
  * Fix for error message when checking for attributes with a namespace prefix.
@@ -119,7 +122,7 @@
 #include <xercesc/util/XMLString.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xercesc/util/Janitor.hpp>
-#include <xercesc/dom/DOM_NamedNodeMap.hpp>
+#include <xercesc/idom/IDOM_NamedNodeMap.hpp>
 #include <xercesc/framework/XMLErrorCodes.hpp>
 #include <xercesc/validators/schema/TraverseSchema.hpp>
 #include <xercesc/util/PlatformUtils.hpp>
@@ -855,7 +858,7 @@ GeneralAttributeCheck::reinitGeneralAttCheck() {
 //  GeneralAttributeCheck: Validation methods
 // ---------------------------------------------------------------------------
 void
-GeneralAttributeCheck::checkAttributes(const DOM_Element& elem,
+GeneralAttributeCheck::checkAttributes(const IDOM_Element* const elem,
                                        const unsigned short elemContext,
                                        TraverseSchema* const schema) {
 
@@ -863,26 +866,16 @@ GeneralAttributeCheck::checkAttributes(const DOM_Element& elem,
         return;
     }
 
-    DOMString                   name = elem.getLocalName();
     int                         prefixContext = globalPrefix;
-    unsigned int                nameLen = name.length();
-    XMLCh*                      elemName = 0;
+    const XMLCh*                elemName = elem->getLocalName();
     const XMLCh*                contextStr = fgGlobal;
     RefVectorOf<AttributeInfo>* elemAttrs = 0;
 
-    if (nameLen) {
-        elemName = new XMLCh[nameLen + 1];
-        XMLString::copyNString(elemName, name.rawBuffer(), nameLen);
-        elemName[nameLen] = chNull;
-    }
-
-    ArrayJanitor<XMLCh> janName(elemName);
-
     if (elemContext == LocalContext) {
 
         contextStr = fgLocal;
 
-        if (elem.getAttribute(SchemaSymbols::fgATT_REF) == 0) {
+        if (elem->getAttributeNode(SchemaSymbols::fgATT_REF) == 0) {
             prefixContext = localNamePrefix;
         }
         else {
@@ -912,7 +905,6 @@ GeneralAttributeCheck::checkAttributes(const DOM_Element& elem,
 
     unsigned int           size = elemAttrs->size();
     RefHashTableOf<XMLCh>  attNameList(5);
-    XMLBuffer              aBuffer(128);
 
     for (unsigned int i=0; i< size; i++) {
 
@@ -921,17 +913,14 @@ GeneralAttributeCheck::checkAttributes(const DOM_Element& elem,
         if (attInfo) {
 
             XMLCh* attName = attInfo->getName();
-            DOMString attValue = elem.getAttribute(attName);
-            DOM_Attr attNode = elem.getAttributeNode(attName);
-            unsigned int attValueLen = attValue.length();
+            const XMLCh* attValue = elem->getAttribute(attName);
+            IDOM_Attr* attNode = elem->getAttributeNode(attName);
+            unsigned int attValueLen = XMLString::stringLen(attValue);
 
             attNameList.put((void*) attName, 0);
 
             if (attValueLen > 0) {
-
-                aBuffer.set(attValue.rawBuffer(), attValueLen);
-                validate(attName, aBuffer.getRawBuffer(),
-                         attInfo->getValidatorIndex(), schema);
+                validate(attName, attValue, attInfo->getValidatorIndex(), schema);
             }
             else if (attNode == 0) {
                 if (attInfo->getDefaultOption() == Att_Required) {
@@ -945,65 +934,56 @@ GeneralAttributeCheck::checkAttributes(const DOM_Element& elem,
     // ------------------------------------------------------------------
     // Check for disallowed attributes
     // ------------------------------------------------------------------
-    DOM_NamedNodeMap eltAttrs = elem.getAttributes();
-    int attrCount = eltAttrs.getLength();
+    IDOM_NamedNodeMap* eltAttrs = elem->getAttributes();
+    int attrCount = eltAttrs->getLength();
 
     for (int j = 0; j < attrCount; j++) {
 
-        DOM_Node  attribute = eltAttrs.item(j);
+        IDOM_Node*  attribute = eltAttrs->item(j);
 
-        if (attribute.isNull()) {
+        if (!attribute) {
             break;
         }
 
         // Bypass attributes that start with xml
-        DOMString attName = attribute.getNodeName();
-        aBuffer.set(attName.rawBuffer(), attName.length());
-        XMLCh* tmpName = aBuffer.getRawBuffer();
+        const XMLCh* attName = attribute->getNodeName();
 
-        if ((*tmpName == chLatin_X || *tmpName == chLatin_x)
-           && (*(tmpName+1) == chLatin_M || *(tmpName+1) == chLatin_m)
-           && (*(tmpName+2) == chLatin_L || *(tmpName+2) == chLatin_l)) {
+        if ((*attName == chLatin_X || *attName == chLatin_x)
+           && (*(attName+1) == chLatin_M || *(attName+1) == chLatin_m)
+           && (*(attName+2) == chLatin_L || *(attName+2) == chLatin_l)) {
             continue;
         }
 
         // for attributes with namespace prefix
-        DOMString attrURI = attribute.getNamespaceURI();
+        const XMLCh* attrURI = attribute->getNamespaceURI();
 
-        if (attrURI != 0 && attrURI.length() != 0) {
+        if (attrURI != 0 && XMLString::stringLen(attrURI) != 0) {
 
             // attributes with schema namespace are not allowed
             // and not allowed on "documentation" and "appInfo"
-            if (attrURI.equals(SchemaSymbols::fgURI_SCHEMAFORSCHEMA) ||
+            if (!XMLString::compareString(attrURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) ||
                 !XMLString::compareString(elemName, SchemaSymbols::fgELT_APPINFO) ||
                 !XMLString::compareString(elemName, SchemaSymbols::fgELT_DOCUMENTATION)) {
 
                 schema->reportSchemaError(XMLUni::fgXMLErrDomain,
-                    XMLErrs::AttributeDisallowed, tmpName, contextStr, elemName);
+                    XMLErrs::AttributeDisallowed, attName, contextStr, elemName);
             } else {
 
                 // Try for a "lax" validation
-                XMLBuffer tmpBuf(128);
-
-                tmpBuf.set(attrURI.rawBuffer(), attrURI.length());
-                attName = attribute.getLocalName();
-                aBuffer.set(attName.rawBuffer(), attName.length());
-                tmpName = aBuffer.getRawBuffer();
-                DatatypeValidator* dv = schema->getDatatypeValidator(tmpBuf.getRawBuffer(), tmpName);
+                DatatypeValidator* dv = schema->getDatatypeValidator(attrURI, attribute->getLocalName());
 
                 if (dv) {
 
-                    DOMString attrVal = attribute.getNodeValue();
-                    tmpBuf.set(attrVal.rawBuffer(), attrVal.length());
+                    const XMLCh* attrVal = attribute->getNodeValue();
 
                     try {
-                        dv->validate(tmpBuf.getRawBuffer());
+                        dv->validate(attrVal);
                     }
                     catch(const XMLException& excep) {
                         schema->reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage());
                     }
                     catch(...) {
-                        schema->reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidAttValue, tmpBuf.getRawBuffer(), tmpName);
+                        schema->reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidAttValue, attrVal, attName);
                     }
                 }
                 // REVISIT:
@@ -1014,14 +994,12 @@ GeneralAttributeCheck::checkAttributes(const DOM_Element& elem,
             continue;
         }
 
-        attName = attribute.getLocalName();
-        aBuffer.set(attName.rawBuffer(), attName.length());
-        tmpName = aBuffer.getRawBuffer();
+        attName = attribute->getLocalName();
 
         // check whether this attribute is allowed
-        if (!attNameList.containsKey(tmpName)) {
+        if (!attNameList.containsKey(attName)) {
             schema->reportSchemaError(XMLUni::fgXMLErrDomain,
-                XMLErrs::AttributeDisallowed, tmpName, contextStr, elemName);
+                XMLErrs::AttributeDisallowed, attName, contextStr, elemName);
         }
     }
 }
diff --git a/src/xercesc/validators/schema/GeneralAttributeCheck.hpp b/src/xercesc/validators/schema/GeneralAttributeCheck.hpp
index 4e4825f427888dc47692f635cf362cbdb22a5857..4b237251d446addf5c2cb6d9d506ccfce30c6da8 100644
--- a/src/xercesc/validators/schema/GeneralAttributeCheck.hpp
+++ b/src/xercesc/validators/schema/GeneralAttributeCheck.hpp
@@ -73,13 +73,13 @@
 #include <xercesc/util/RefVectorOf.hpp>
 #include <xercesc/util/RefHashTableOf.hpp>
 #include <xercesc/util/RefHash2KeysTableOf.hpp>
-#include <xercesc/dom/DOM_Element.hpp>
 #include <xercesc/validators/datatype/IDDatatypeValidator.hpp>
 
 // ---------------------------------------------------------------------------
 //  Forward declaration
 // ---------------------------------------------------------------------------
 class TraverseSchema;
+class IDOM_Element;
 
 
 class AttributeInfo {
@@ -145,7 +145,7 @@ public:
     // -----------------------------------------------------------------------
     //  Validation methods
     // -----------------------------------------------------------------------
-    void checkAttributes(const DOM_Element& elem,
+    void checkAttributes(const IDOM_Element* const elem,
                          const unsigned short elemContext,
                          TraverseSchema* const schema);
 
diff --git a/src/xercesc/validators/schema/SchemaInfo.cpp b/src/xercesc/validators/schema/SchemaInfo.cpp
index 37a0a931bc4efbcfd7816ce2dd12a2c06e5a496a..02ca32323417193e586e0e4d200e957dab6a841b 100644
--- a/src/xercesc/validators/schema/SchemaInfo.cpp
+++ b/src/xercesc/validators/schema/SchemaInfo.cpp
@@ -56,8 +56,11 @@
 
 /*
  * $Log$
- * Revision 1.1  2002/02/01 22:22:46  peiyongz
- * Initial revision
+ * Revision 1.2  2002/02/06 22:24:59  knoaman
+ * Use IDOM for schema processing.
+ *
+ * Revision 1.1.1.1  2002/02/01 22:22:46  peiyongz
+ * sane_include
  *
  * Revision 1.6  2001/12/12 20:52:19  peiyongz
  * memory leak: fRedefineList
@@ -100,8 +103,9 @@ SchemaInfo::SchemaInfo(const unsigned short elemAttrDefaultQualified,
                        XMLCh* const schemaURL,
                        const XMLCh* const targetNSURIString,
                        XMLStringPool* const stringPool,
-                       const DOM_Element& root)
-    : fElemAttrDefaultQualified(elemAttrDefaultQualified)
+                       const IDOM_Element* const root)
+    : fAdoptInclude(false)
+    , fElemAttrDefaultQualified(elemAttrDefaultQualified)
     , fBlockDefault(blockDefault)
     , fFinalDefault(finalDefault)
     , fTargetNSURI(targetNSURI)
@@ -112,46 +116,56 @@ SchemaInfo::SchemaInfo(const unsigned short elemAttrDefaultQualified,
     , fTargetNSURIString(targetNSURIString)
     , fStringPool(stringPool)
     , fSchemaRootElement(root)
-    , fIncludeList(0)
-    , fImportList(0)
-    , fImportingList(0)
-    , fRedefineList(0)
+    , fIncludeInfoList(0)
+    , fImportedInfoList(0)
+    , fImportingInfoList(0)
+    , fFailedRedefineList(0)
+    , fImportedNSList(0)
 {
-    fImportingList = new RefVectorOf<SchemaInfo>(4, false);
+    fImportingInfoList = new RefVectorOf<SchemaInfo>(4, false);
 }
 
 
 SchemaInfo::~SchemaInfo()
 {
     delete [] fCurrentSchemaURL;
-    delete fImportList;
-    delete fIncludeList;
-    delete fImportingList;
+    delete fImportedInfoList;
+
+    if (fAdoptInclude)
+        delete fIncludeInfoList;
+
+    delete fImportingInfoList;
+
+    fImportedInfoList = fIncludeInfoList = fImportingInfoList = 0;
 
-    fImportList = fIncludeList = fImportingList = 0;
+    delete fImportedNSList;
+    fImportedNSList = 0;
 
-    delete fRedefineList;
-    fRedefineList = 0;
+    delete fFailedRedefineList;
+    fFailedRedefineList = 0;    
 }
 
 // ---------------------------------------------------------------------------
 //  SchemaInfo:
 // ---------------------------------------------------------------------------
-DOM_Element
+IDOM_Element*
 SchemaInfo::getTopLevelComponent(const XMLCh* const compCategory,
                                  const XMLCh* const name,
                                  SchemaInfo** enclosingSchema) {
 
     SchemaInfo* currentInfo = this;
-    DOM_Element child = getTopLevelComponent(compCategory, name);
+    IDOM_Element* child = getTopLevelComponent(compCategory, name);
 
     if (child == 0) {
 
-        unsigned int listSize = (fIncludeList) ? fIncludeList->size() : 0;
+        unsigned int listSize = (fIncludeInfoList) ? fIncludeInfoList->size() : 0;
 
         for (unsigned int i=0; i < listSize; i++) {
 
-            currentInfo = fIncludeList->elementAt(i);
+            currentInfo = fIncludeInfoList->elementAt(i);
+
+            if (currentInfo == this)
+                continue;
 
             child = currentInfo->getTopLevelComponent(compCategory, name);
 
@@ -161,50 +175,36 @@ SchemaInfo::getTopLevelComponent(const XMLCh* const compCategory,
                 break;
             }
         }
-
-        if (child == 0 && fRedefineList) { // try redefine list
-
-			currentInfo = fRedefineList->get(compCategory, fStringPool->addOrFind(name));
-
-            if (currentInfo) {
-                child = currentInfo->getTopLevelComponent(compCategory, name);
-
-                if (child != 0) {
-                    *enclosingSchema = currentInfo;
-                }
-            }
-        }
     }
 
     return child;
 }
 
 
-DOM_Element
+IDOM_Element*
 SchemaInfo::getTopLevelComponent(const XMLCh* const compCategory,
-                                 const XMLCh* const name) {
+                                  const XMLCh* const name) {
 
-    DOM_Element child = XUtil::getFirstChildElement(fSchemaRootElement);
+    IDOM_Element* child = XUtil::getFirstChildElement(fSchemaRootElement);
 
     while (child != 0) {
 
-        if (child.getLocalName().equals(compCategory)) {
+        if (!XMLString::compareString(child->getLocalName(), compCategory)) {
 
-            if (child.getAttribute(SchemaSymbols::fgATT_NAME).equals(name)) {
+            if (!XMLString::compareString(child->getAttribute(SchemaSymbols::fgATT_NAME), name))
                 break;
-            }
         }
-        else if (child.getLocalName().equals(SchemaSymbols::fgELT_REDEFINE)) { // if redefine
+        else if (!XMLString::compareString(child->getLocalName(),SchemaSymbols::fgELT_REDEFINE)
+                 && (!fFailedRedefineList || !fFailedRedefineList->containsElement(child))) { // if redefine
 
-            DOM_Element redefineChild = XUtil::getFirstChildElement(child);
+            IDOM_Element* redefineChild = XUtil::getFirstChildElement(child);
 
             while (redefineChild != 0) {
 
-                if (redefineChild.getLocalName().equals(compCategory)) {
-
-                    if (redefineChild.getAttribute(SchemaSymbols::fgATT_NAME).equals(name)) {
+                if ((!fFailedRedefineList || !fFailedRedefineList->containsElement(redefineChild))
+                    && !XMLString::compareString(redefineChild->getLocalName(), compCategory)
+                    && !XMLString::compareString(redefineChild->getAttribute(SchemaSymbols::fgATT_NAME), name)) {
                         break;
-                    }
                 }
 
                 redefineChild = XUtil::getNextSiblingElement(redefineChild);
@@ -225,18 +225,18 @@ SchemaInfo::getTopLevelComponent(const XMLCh* const compCategory,
 
 void SchemaInfo::updateImportingInfo(SchemaInfo* const importingInfo) {
 
-    if (!fImportingList->containsElement(importingInfo)) {
-        fImportingList->addElement(importingInfo);
+    if (!fImportingInfoList->containsElement(importingInfo)) {
+        fImportingInfoList->addElement(importingInfo);
     }
 
-    unsigned int listSize = importingInfo->fImportingList->size();
+    unsigned int listSize = importingInfo->fImportingInfoList->size();
 
     for (unsigned int i=0; i < listSize; i++) {
 
-        SchemaInfo* tmpInfo = importingInfo->fImportingList->elementAt(i);
+        SchemaInfo* tmpInfo = importingInfo->fImportingInfoList->elementAt(i);
 
-        if (tmpInfo != this && !fImportingList->containsElement(tmpInfo)) {
-            fImportingList->addElement(tmpInfo);
+        if (tmpInfo != this && !fImportingInfoList->containsElement(tmpInfo)) {
+            fImportingInfoList->addElement(tmpInfo);
         }
     }
 }
diff --git a/src/xercesc/validators/schema/SchemaInfo.hpp b/src/xercesc/validators/schema/SchemaInfo.hpp
index f02137bf268298f4b8a29d70c4e0f4eaea07927b..4d0218ffcba830405b2d5a48a6020b07982122bd 100644
--- a/src/xercesc/validators/schema/SchemaInfo.hpp
+++ b/src/xercesc/validators/schema/SchemaInfo.hpp
@@ -77,9 +77,9 @@
 // ---------------------------------------------------------------------------
 //  Includes
 // ---------------------------------------------------------------------------
-#include <xercesc/dom/DOM_Element.hpp>
+#include <xercesc/idom/IDOM_Element.hpp>
 #include <xercesc/util/RefVectorOf.hpp>
-#include <xercesc/util/RefHash2KeysTableOf.hpp>
+#include <xercesc/util/ValueVectorOf.hpp>
 #include <xercesc/util/StringPool.hpp>
 
 class SchemaInfo
@@ -105,7 +105,7 @@ public:
                XMLCh* const schemaURL,
                const XMLCh* const targetNSURIString,
                XMLStringPool* const stringPool,
-               const DOM_Element& root);
+               const IDOM_Element* const root);
     ~SchemaInfo();
 
 
@@ -114,7 +114,7 @@ public:
     // -----------------------------------------------------------------------
     XMLCh*                   getCurrentSchemaURL() const;
     const XMLCh* const       getTargetNSURIString() const;
-    DOM_Element              getRoot() const;
+    const IDOM_Element*      getRoot() const;
     int                      getBlockDefault() const;
     int                      getFinalDefault() const;
     int                      getTargetNSURI() const;
@@ -134,39 +134,41 @@ public:
     //  Access methods
     // -----------------------------------------------------------------------
     void addSchemaInfo(SchemaInfo* const toAdd, const ListType aListType);
-    void addRedefineInfo(const XMLCh* const categName, const XMLCh* const typeName,
-                         SchemaInfo* const toAdd);
     bool containsInfo(const SchemaInfo* const toCheck, const ListType aListType) const;
     SchemaInfo* getImportInfo(const unsigned int namespaceURI) const;
-    SchemaInfo* getRedefInfo(const XMLCh* const categName,
-                             const XMLCh* const typeName);
-    DOM_Element getTopLevelComponent(const XMLCh* const compCategory,
-                                     const XMLCh* const name);
-    DOM_Element getTopLevelComponent(const XMLCh* const compCategory,
-                                     const XMLCh* const name,
-                                     SchemaInfo** enclosingSchema);
+    IDOM_Element* getTopLevelComponent(const XMLCh* const compCategory,
+                                       const XMLCh* const name);
+    IDOM_Element* getTopLevelComponent(const XMLCh* const compCategory,
+                                       const XMLCh* const name,
+                                       SchemaInfo** enclosingSchema);
     void updateImportingInfo(SchemaInfo* const importingInfo);
     bool circularImportExist(const unsigned int nameSpaceURI);
+    bool isFailedRedefine(const IDOM_Element* const anElem);
+    void addFailedRedefine(const IDOM_Element* const anElem);
+    bool isImportingNS(const int namespaceURI);
+    void addImportedNS(const int namespaceURI);
 
 private:
     // -----------------------------------------------------------------------
     //  Private data members
     // -----------------------------------------------------------------------
-    unsigned short     fElemAttrDefaultQualified;
-    int                fBlockDefault;
-    int                fFinalDefault;
-    int                fTargetNSURI;
-    int                fCurrentScope;
-    int                fScopeCount;
-    unsigned int       fNamespaceScopeLevel;
-    XMLCh*             fCurrentSchemaURL;
-    const XMLCh*       fTargetNSURIString;
-    XMLStringPool*     fStringPool;
-    DOM_Element        fSchemaRootElement;
-    RefVectorOf<SchemaInfo>* fIncludeList;
-    RefVectorOf<SchemaInfo>* fImportList;
-    RefVectorOf<SchemaInfo>* fImportingList;
-    RefHash2KeysTableOf<SchemaInfo>* fRedefineList;
+    bool                                fAdoptInclude;
+    unsigned short                      fElemAttrDefaultQualified;
+    int                                 fBlockDefault;
+    int                                 fFinalDefault;
+    int                                 fTargetNSURI;
+    int                                 fCurrentScope;
+    int                                 fScopeCount;
+    unsigned int                        fNamespaceScopeLevel;
+    XMLCh*                              fCurrentSchemaURL;
+    const XMLCh*                        fTargetNSURIString;
+    XMLStringPool*                      fStringPool;
+    const IDOM_Element*                 fSchemaRootElement;
+    RefVectorOf<SchemaInfo>*            fIncludeInfoList;
+    RefVectorOf<SchemaInfo>*            fImportedInfoList;
+    RefVectorOf<SchemaInfo>*            fImportingInfoList;
+    ValueVectorOf<const IDOM_Element*>* fFailedRedefineList;
+    ValueVectorOf<int>*                 fImportedNSList;
 };
 
 // ---------------------------------------------------------------------------
@@ -201,7 +203,7 @@ inline const XMLCh* const SchemaInfo::getTargetNSURIString() const {
     return fTargetNSURIString;
 }
 
-inline DOM_Element SchemaInfo::getRoot() const {
+inline const IDOM_Element* SchemaInfo::getRoot() const {
 
     return fSchemaRootElement;
 }
@@ -224,7 +226,7 @@ inline int SchemaInfo::getScopeCount() const {
 inline RefVectorEnumerator<SchemaInfo>
 SchemaInfo::getImportingListEnumerator() const {
 
-    return RefVectorEnumerator<SchemaInfo>(fImportingList);
+    return RefVectorEnumerator<SchemaInfo>(fImportingInfoList);
 }
 
 // ---------------------------------------------------------------------------
@@ -240,6 +242,7 @@ inline void SchemaInfo::setScopeCount(const int aValue) {
     fScopeCount = aValue;
 }
 
+
 // ---------------------------------------------------------------------------
 //  SchemaInfo: Access methods
 // ---------------------------------------------------------------------------
@@ -248,43 +251,40 @@ inline void SchemaInfo::addSchemaInfo(SchemaInfo* const toAdd,
 
     if (aListType == IMPORT) {
 
-        if (!fImportList)
-            fImportList = new RefVectorOf<SchemaInfo>(8, false);
+        if (!fImportedInfoList)
+            fImportedInfoList = new RefVectorOf<SchemaInfo>(4, false);
+
+        if (!fImportedInfoList->containsElement(toAdd)) {
 
-        if (!fImportList->containsElement(toAdd)) {
-		    fImportList->addElement(toAdd);
+            fImportedInfoList->addElement(toAdd);
+            addImportedNS(toAdd->getTargetNSURI());
             toAdd->updateImportingInfo(this);
         }
     }
     else {
 
-        if (!fIncludeList)
-            fIncludeList = new RefVectorOf<SchemaInfo>(8, false);
+        if (!fIncludeInfoList) {
 
-        if (!fIncludeList->containsElement(toAdd))
-		    fIncludeList->addElement(toAdd);
-    }
-}
+            fIncludeInfoList = new RefVectorOf<SchemaInfo>(8, false);
+            fAdoptInclude = true;
+        }
 
-inline void SchemaInfo::addRedefineInfo(const XMLCh* const categName,
-                                        const XMLCh* const typeName,
-                                        SchemaInfo* const toAdd) {
+        if (!fIncludeInfoList->containsElement(toAdd)) {
 
-    if (!fRedefineList) {
-        fRedefineList = new RefHash2KeysTableOf<SchemaInfo>(8, false);
+		    fIncludeInfoList->addElement(toAdd);
+            toAdd->fIncludeInfoList = fIncludeInfoList;
+        }
     }
-
-    fRedefineList->put((void*) categName, fStringPool->addOrFind(typeName), toAdd);
 }
 
 inline SchemaInfo* SchemaInfo::getImportInfo(const unsigned int namespaceURI) const {
 
-    unsigned int importSize = (fImportList) ? fImportList->size() : 0;
+    unsigned int importSize = (fImportedInfoList) ? fImportedInfoList->size() : 0;
     SchemaInfo* currInfo = 0;
 
     for (unsigned int i=0; i < importSize; i++) {
 
-        currInfo = fImportList->elementAt(i);
+        currInfo = fImportedInfoList->elementAt(i);
 
         if (currInfo->getTargetNSURI() == (int) namespaceURI)
             break;
@@ -293,24 +293,14 @@ inline SchemaInfo* SchemaInfo::getImportInfo(const unsigned int namespaceURI) co
     return currInfo;
 }
 
-inline SchemaInfo* SchemaInfo::getRedefInfo(const XMLCh* const categName,
-                                            const XMLCh* const typeName) {
-
-    if (fRedefineList) {
-        return fRedefineList->get(categName, fStringPool->addOrFind(typeName));
-    }
-
-    return 0;
-}
-
 inline bool SchemaInfo::containsInfo(const SchemaInfo* const toCheck,
                                      const ListType aListType) const {
 
-    if ((aListType == INCLUDE) && fIncludeList) {
-        return fIncludeList->containsElement(toCheck);        
+    if ((aListType == INCLUDE) && fIncludeInfoList) {
+        return fIncludeInfoList->containsElement(toCheck);        
     }
-    else if ((aListType == IMPORT) && fImportList) {
-        return fImportList->containsElement(toCheck);
+    else if ((aListType == IMPORT) && fImportedInfoList) {
+        return fImportedInfoList->containsElement(toCheck);
     }
 
     return false;
@@ -318,10 +308,10 @@ inline bool SchemaInfo::containsInfo(const SchemaInfo* const toCheck,
 
 inline bool SchemaInfo::circularImportExist(const unsigned int namespaceURI) {
 
-    unsigned int importSize = fImportingList->size();
+    unsigned int importSize = fImportingInfoList->size();
 
     for (unsigned int i=0; i < importSize; i++) {
-        if (fImportingList->elementAt(i)->getTargetNSURI() == (int) namespaceURI) {
+        if (fImportingInfoList->elementAt(i)->getTargetNSURI() == (int) namespaceURI) {
             return true;
         }
     }
@@ -329,6 +319,42 @@ inline bool SchemaInfo::circularImportExist(const unsigned int namespaceURI) {
     return false;
 }
 
+inline bool SchemaInfo::isFailedRedefine(const IDOM_Element* const anElem) {
+
+    if (fFailedRedefineList)
+        return (fFailedRedefineList->containsElement(anElem));
+
+    return false;
+}
+
+inline void SchemaInfo::addFailedRedefine(const IDOM_Element* const anElem) {
+
+    if (!fFailedRedefineList) {
+        fFailedRedefineList = new ValueVectorOf<const IDOM_Element*>(4);
+    }
+
+    fFailedRedefineList->addElement(anElem);
+}
+
+inline void SchemaInfo::addImportedNS(const int namespaceURI) {
+
+    if (!fImportedNSList) {
+        fImportedNSList = new ValueVectorOf<int>(4);
+    }
+
+    if (!fImportedNSList->containsElement(namespaceURI))
+        fImportedNSList->addElement(namespaceURI);
+}
+
+inline bool SchemaInfo::isImportingNS(const int namespaceURI) {
+
+    if (!fImportedNSList)
+        return false;
+
+    return (fImportedNSList->containsElement(namespaceURI));
+}
+
+
 #endif
 
 /**
diff --git a/src/xercesc/validators/schema/XUtil.cpp b/src/xercesc/validators/schema/XUtil.cpp
index 4e31445cc11717e7c25b4034fe26959e87acfccf..c11f8df959364017206d258dcd3abaa4ab4d0625 100644
--- a/src/xercesc/validators/schema/XUtil.cpp
+++ b/src/xercesc/validators/schema/XUtil.cpp
@@ -56,8 +56,11 @@
 
 /*
  * $Log$
- * Revision 1.1  2002/02/01 22:22:50  peiyongz
- * Initial revision
+ * Revision 1.2  2002/02/06 22:21:49  knoaman
+ * Use IDOM for schema processing.
+ *
+ * Revision 1.1.1.1  2002/02/01 22:22:50  peiyongz
+ * sane_include
  *
  * Revision 1.6  2001/12/05 20:12:30  knoaman
  * Use getLocalName instead of getNodeName.
@@ -90,6 +93,10 @@
 #include <xercesc/dom/ElementImpl.hpp>
 #include <xercesc/dom/DocumentImpl.hpp>
 #include <xercesc/util/IllegalArgumentException.hpp>
+#include <xercesc/idom/IDOM_Element.hpp>
+#include <xercesc/idom/IDOM_Document.hpp>
+#include <xercesc/idom/IDOM_NamedNodeMap.hpp>
+#include <xercesc/idom/IDOM_Node.hpp>
 
 void XUtil::copyInto(const DOM_Node &src, DOM_Node &dest)
 {
@@ -238,6 +245,24 @@ DOM_Element XUtil::getFirstChildElement(const DOM_Node &parent)
     return DOM_Element();
 }
 
+// Finds and returns the first child element node.
+IDOM_Element* XUtil::getFirstChildElement(const IDOM_Node* const parent)
+{
+    // search for node
+    IDOM_Node* child = parent->getFirstChild();
+
+    while (child != 0)
+	{
+        if (child->getNodeType() == IDOM_Node::ELEMENT_NODE)
+            return (IDOM_Element*)child;
+
+        child = child->getNextSibling();
+    }
+
+    // not found
+    return 0;
+}
+
 // Finds and returns the first child node with the given name.
 DOM_Element XUtil::getFirstChildElement(const DOM_Node    &parent
                                       , const XMLCh* const elemName)
@@ -333,6 +358,31 @@ DOM_Element XUtil::getFirstChildElementNS(const DOM_Node     &parent
     return DOM_Element();
 }
 
+IDOM_Element* XUtil::getFirstChildElementNS(const IDOM_Node* const parent
+                                          , const XMLCh** const elemNames
+                                          , const XMLCh* const uriStr
+                                          , unsigned int        length)
+{
+    // search for node
+    IDOM_Node* child = parent->getFirstChild();
+    while (child != 0)
+	{
+        if (child->getNodeType() == IDOM_Node::ELEMENT_NODE)
+		{
+            for (unsigned int i = 0; i < length; i++)
+			{
+                if (!XMLString::compareString(child->getNamespaceURI(), uriStr) &&
+                    !XMLString::compareString(child->getLocalName(), elemNames[i]))
+                    return (IDOM_Element*)child;
+			}
+		}
+        child = child->getNextSibling();
+    }
+
+    // not found
+    return 0;
+}
+
 // Finds and returns the last child element node.
 DOM_Element XUtil::getLastChildElement(const DOM_Node &parent) {
 
@@ -436,6 +486,23 @@ DOM_Element XUtil::getNextSiblingElement(const DOM_Node &node)
     return DOM_Element();
 }
 
+IDOM_Element* XUtil::getNextSiblingElement(const IDOM_Node* const node)
+{
+    // search for node
+    IDOM_Node* sibling = node->getNextSibling();
+
+    while (sibling != 0)
+	{
+        if (sibling->getNodeType() == IDOM_Node::ELEMENT_NODE)
+            return (IDOM_Element*)sibling;
+
+        sibling = sibling->getNextSibling();
+    }
+
+    // not found
+    return 0;
+}
+
 // Finds and returns the next sibling element node with the give name.
 DOM_Element XUtil::getNextSiblingElement(const DOM_Node    &node
                                        , const XMLCh* const elemName)
@@ -530,3 +597,28 @@ DOM_Element XUtil::getNextSiblingElementNS(const DOM_Node     &node
     return DOM_Element();
 }
 
+IDOM_Element* XUtil::getNextSiblingElementNS(const IDOM_Node* const node
+                                           , const XMLCh** const elemNames
+                                           , const XMLCh* const uriStr
+									       , unsigned int        length)
+{
+    // search for node
+    IDOM_Node* sibling = node->getNextSibling();
+    while (sibling != 0)
+	{
+        if (sibling->getNodeType() == IDOM_Node::ELEMENT_NODE)
+		{
+            for (unsigned int i = 0; i < length; i++)
+			{
+                if (!XMLString::compareString(sibling->getNamespaceURI(), uriStr) &&
+                    !XMLString::compareString(sibling->getLocalName(), elemNames[i]))
+                    return (IDOM_Element*)sibling;
+			}
+		}
+        sibling = sibling->getNextSibling();
+    }
+
+    // not found
+    return 0;
+}
+
diff --git a/src/xercesc/validators/schema/XUtil.hpp b/src/xercesc/validators/schema/XUtil.hpp
index 62acadb8ebb9c4cc1694734c3f597e76226fedf6..4b5db0aaa77a5bba2d4d98c2aab629af400db548 100644
--- a/src/xercesc/validators/schema/XUtil.hpp
+++ b/src/xercesc/validators/schema/XUtil.hpp
@@ -56,8 +56,11 @@
 
 /*
  * $Log$
- * Revision 1.1  2002/02/01 22:22:50  peiyongz
- * Initial revision
+ * Revision 1.2  2002/02/06 22:21:49  knoaman
+ * Use IDOM for schema processing.
+ *
+ * Revision 1.1.1.1  2002/02/01 22:22:50  peiyongz
+ * sane_include
  *
  * Revision 1.3  2001/11/02 14:13:45  knoaman
  * Add support for identity constraints.
@@ -78,6 +81,9 @@
 #include <xercesc/dom/DOM_NamedNodeMap.hpp>
 #include <xercesc/dom/DOM_Node.hpp>
 
+class IDOM_Node;
+class IDOM_Element;
+
 /**
  * Some useful utility methods.
  */
@@ -107,6 +113,8 @@ public:
 
     // Finds and returns the first child element node.
     static DOM_Element getFirstChildElement(const DOM_Node &parent);
+    static IDOM_Element* getFirstChildElement(const IDOM_Node* const parent);
+
     // Finds and returns the first child element node with the given name.
     static DOM_Element getFirstChildElement(const DOM_Node    &parent
 		                                  , const XMLCh* const elemName);
@@ -126,6 +134,10 @@ public:
                                             , const XMLCh** const elemNames
                                             , const XMLCh* const uriStr
                                             , unsigned int        length);
+    static IDOM_Element* getFirstChildElementNS(const IDOM_Node* const parent
+                                              , const XMLCh** const elemNames
+                                              , const XMLCh* const uriStr
+                                              , unsigned int       length);
 
     // Finds and returns the last child element node.
     static DOM_Element getLastChildElement(const DOM_Node &parent);
@@ -145,6 +157,8 @@ public:
 
     // Finds and returns the next sibling element node.
     static DOM_Element getNextSiblingElement(const DOM_Node &node);
+    static IDOM_Element* getNextSiblingElement(const IDOM_Node* const node);
+
     // Finds and returns the next sibling element node with the given name.
     static DOM_Element getNextSiblingElement(const DOM_Node    &node
 		                                   , const XMLCh* const elemName);
@@ -165,6 +179,10 @@ public:
                                              , const XMLCh** const elemNames
                                              , const XMLCh* const uriStr
                                              , unsigned int        length);
+    static IDOM_Element* getNextSiblingElementNS(const IDOM_Node* const node
+                                               , const XMLCh** const elemNames
+                                               , const XMLCh* const uriStr
+                                               , unsigned int        length);
 
 protected:
     // -----------------------------------------------------------------------