diff --git a/src/xercesc/util/RefHashTableOf.c b/src/xercesc/util/RefHashTableOf.c
index dd3b99f9913a3d4d8a645cbf2762339eaccf2f73..9b0f3103427f4a2b2c186826ea4a4b674712ab66 100644
--- a/src/xercesc/util/RefHashTableOf.c
+++ b/src/xercesc/util/RefHashTableOf.c
@@ -56,6 +56,10 @@
 
 /**
  * $Log$
+ * Revision 1.5  2002/07/11 18:49:53  knoaman
+ * Add setAdoptElements method.
+ * Rename removeBucketElemSafe to orphanKey.
+ *
  * Revision 1.4  2002/07/05 11:31:04  tng
  * Fix typo.
  *
@@ -226,6 +230,60 @@ template <class TVal> void RefHashTableOf<TVal>::removeAll()
     }
 }
 
+// This method returns the data associated with a key. The key entry is deleted. The caller
+// now owns the returned data (case of hashtable adopting the data).
+// This function is called by transferElement so that the undeleted data can be transferred
+// to a new key which will own that data.
+template <class TVal> TVal* RefHashTableOf<TVal>::
+orphanKey(const void* const key)
+{
+    // Hash the key
+    TVal* retVal = 0;
+    unsigned int hashVal = fHash->getHashVal(key, fHashModulus);
+    if (hashVal > fHashModulus)
+        ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey);
+
+    //
+    //  Search the given bucket for this key. Keep up with the previous
+    //  element so we can patch around it.
+    //
+    RefHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
+    RefHashTableBucketElem<TVal>* lastElem = 0;
+
+    while (curElem)
+    {
+        if (fHash->equals(key, curElem->fKey))
+        {
+            if (!lastElem)
+            {
+                // It was the first in the bucket
+                fBucketList[hashVal] = curElem->fNext;
+            }
+             else
+            {
+                // Patch around the current element
+                lastElem->fNext = curElem->fNext;
+            }
+
+            retVal = curElem->fData;
+
+            // Delete the current element
+            delete curElem;
+            break;
+        }
+
+        // Move both pointers upwards
+        lastElem = curElem;
+        curElem = curElem->fNext;
+    }
+
+    // We never found that key
+    if (!retVal)
+        ThrowXML(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists);
+
+    return retVal;
+}
+
 //
 // cleanup():
 //   similar to destructor
@@ -270,12 +328,7 @@ template <class TElem> void RefHashTableOf<TElem>::reinitialize(HashBase* hashBa
 // whatever key2 has originally will be purged (if adopted)
 template <class TElem> void RefHashTableOf<TElem>::transferElement(const void* const key1, void* key2)
 {
-    TElem* data = get(key1);
-
-    unsigned int hashVal;
-    removeBucketElemSafe(key1, hashVal);
-
-    put(key2, data);
+    put(key2, orphanKey(key1));
 }
 
 
@@ -302,6 +355,15 @@ get(const void* const key) const
 }
 
 
+// ---------------------------------------------------------------------------
+//  RefHashTableOf: Getters
+// ---------------------------------------------------------------------------
+template <class TVal>
+void RefHashTableOf<TVal>::setAdoptElements(const bool aValue)
+{
+    fAdoptedElems = aValue;
+}
+
 // ---------------------------------------------------------------------------
 //  RefHashTableOf: Putters
 // ---------------------------------------------------------------------------
@@ -425,59 +487,6 @@ removeBucketElem(const void* const key, unsigned int& hashVal)
 }
 
 
-// This is same as removeBucketElem except that it does not delete the data
-//   even it is adopted
-// This function is called by transferElement so that the undeleted data can be transferred
-//   the key2 will own this data.
-template <class TVal> void RefHashTableOf<TVal>::
-removeBucketElemSafe(const void* const key, unsigned int& hashVal)
-{
-    // Hash the key
-    hashVal = fHash->getHashVal(key, fHashModulus);
-    if (hashVal > fHashModulus)
-        ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey);
-
-    //
-    //  Search the given bucket for this key. Keep up with the previous
-    //  element so we can patch around it.
-    //
-    RefHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
-    RefHashTableBucketElem<TVal>* lastElem = 0;
-
-    while (curElem)
-    {
-        if (fHash->equals(key, curElem->fKey))
-        {
-            if (!lastElem)
-            {
-                // It was the first in the bucket
-                fBucketList[hashVal] = curElem->fNext;
-            }
-             else
-            {
-                // Patch around the current element
-                lastElem->fNext = curElem->fNext;
-            }
-
-            // even if we adopted the elements, do not delete the data
-            // if (fAdoptedElems)
-            //    delete curElem->fData;
-
-            // Delete the current element
-            delete curElem;
-
-            return;
-        }
-
-        // Move both pointers upwards
-        lastElem = curElem;
-        curElem = curElem->fNext;
-    }
-
-    // We never found that key
-    ThrowXML(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists);
-}
-
 
 // ---------------------------------------------------------------------------
 //  RefHashTableOfEnumerator: Constructors and Destructor
diff --git a/src/xercesc/util/RefHashTableOf.hpp b/src/xercesc/util/RefHashTableOf.hpp
index 34c7653c3b0c446a9248f3980d36326348dfeb8a..fea6a03fa89e837d768d66956b9135f885f25677 100644
--- a/src/xercesc/util/RefHashTableOf.hpp
+++ b/src/xercesc/util/RefHashTableOf.hpp
@@ -56,6 +56,10 @@
 
 /*
  * $Log$
+ * Revision 1.4  2002/07/11 18:49:53  knoaman
+ * Add setAdoptElements method.
+ * Rename removeBucketElemSafe to orphanKey.
+ *
  * Revision 1.3  2002/07/04 15:24:57  tng
  * DOM L3: add transferElement and removeBucketElemSafe for use in DOMDocument::renameNode.
  *
@@ -143,7 +147,7 @@ template <class TVal> struct RefHashTableBucketElem
 
     TVal*                           fData;
     RefHashTableBucketElem<TVal>*   fNext;
-    void*                           fKey;
+	void*							fKey;
 };
 
 
@@ -153,13 +157,13 @@ public:
     // -----------------------------------------------------------------------
     //  Constructors and Destructor
     // -----------------------------------------------------------------------
-    // backwards compatability - default hasher is HashXMLCh
+	// backwards compatability - default hasher is HashXMLCh
     RefHashTableOf(const unsigned int modulus);
-    // backwards compatability - default hasher is HashXMLCh
+	// backwards compatability - default hasher is HashXMLCh
     RefHashTableOf(const unsigned int modulus, const bool adoptElems);
-    // if a hash function is passed in, it will be deleted when the hashtable is deleted.
-    // use a new instance of the hasher class for each hashtable, otherwise one hashtable
-    // may delete the hasher of a different hashtable if both use the same hasher.
+	// if a hash function is passed in, it will be deleted when the hashtable is deleted.
+	// use a new instance of the hasher class for each hashtable, otherwise one hashtable
+	// may delete the hasher of a different hashtable if both use the same hasher.
     RefHashTableOf(const unsigned int modulus, const bool adoptElems, HashBase* hashBase);
     ~RefHashTableOf();
 
@@ -174,6 +178,7 @@ public:
     void cleanup();
     void reinitialize(HashBase* hashBase);
     void transferElement(const void* const key1, void* key2);
+    TVal* orphanKey(const void* const key);
 
     // -----------------------------------------------------------------------
     //  Getters
@@ -181,11 +186,16 @@ public:
     TVal* get(const void* const key);
     const TVal* get(const void* const key) const;
 
+    // -----------------------------------------------------------------------
+    //  Setters
+    // -----------------------------------------------------------------------
+    void setAdoptElements(const bool aValue);
+
 
     // -----------------------------------------------------------------------
     //  Putters
     // -----------------------------------------------------------------------
-    void put(void* key, TVal* const valueToAdopt);
+	void put(void* key, TVal* const valueToAdopt);
 
 
 private :
@@ -202,7 +212,6 @@ private:
     RefHashTableBucketElem<TVal>* findBucketElem(const void* const key, unsigned int& hashVal);
     const RefHashTableBucketElem<TVal>* findBucketElem(const void* const key, unsigned int& hashVal) const;
     void removeBucketElem(const void* const key, unsigned int& hashVal);
-    void removeBucketElemSafe(const void* const key, unsigned int& hashVal);
     void initialize(const unsigned int modulus);
 
 
@@ -221,14 +230,14 @@ private:
     //  fHashModulus
     //      The modulus used for this hash table, to hash the keys. This is
     //      also the number of elements in the bucket list.
-    //
-    //  fHash
-    //      The hasher for the key data type.
+	//
+	//  fHash
+	//      The hasher for the key data type.
     // -----------------------------------------------------------------------
     bool                                fAdoptedElems;
     RefHashTableBucketElem<TVal>**      fBucketList;
     unsigned int                        fHashModulus;
-    HashBase*                           fHash;
+	HashBase*							fHash;
 };