diff --git a/src/xercesc/dom/impl/DOMCDATASectionImpl.cpp b/src/xercesc/dom/impl/DOMCDATASectionImpl.cpp
index 6b9871770d7ce57cbdde875044a430703b7d42cb..74055522ef5ecec06e771e8f28e3c22cb65b7dc0 100644
--- a/src/xercesc/dom/impl/DOMCDATASectionImpl.cpp
+++ b/src/xercesc/dom/impl/DOMCDATASectionImpl.cpp
@@ -135,7 +135,12 @@ bool DOMCDATASectionImpl::getIsElementContentWhitespace() const
 const XMLCh* DOMCDATASectionImpl::getWholeText() const
 {
     DOMDocument *doc = getOwnerDocument();
-    DOMTreeWalker* pWalker=doc->createTreeWalker(doc->getDocumentElement(), DOMNodeFilter::SHOW_ALL, NULL, true);
+    if (!doc) {
+        throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0, GetDOMNodeMemoryManager);
+        return 0;
+    }
+    DOMNode* root=doc->getDocumentElement();
+    DOMTreeWalker* pWalker=doc->createTreeWalker(root!=NULL?root:(DOMNode*)this, DOMNodeFilter::SHOW_ALL, NULL, true);
     pWalker->setCurrentNode((DOMNode*)this);
     // Logically-adjacent text nodes are Text or CDATASection nodes that can be visited sequentially in document order or in
     // reversed document order without entering, exiting, or passing over Element, Comment, or ProcessingInstruction nodes.
@@ -156,7 +161,7 @@ const XMLCh* DOMCDATASectionImpl::getWholeText() const
     }
     pWalker->release();
 
-    XMLCh* wholeString = (XMLCh*) (GetDOMNodeMemoryManager->allocate((buff.getLen()+1)*sizeof(XMLCh)));
+	XMLCh* wholeString = (XMLCh*)((DOMDocumentImpl*)doc)->allocate((buff.getLen()+1) * sizeof(XMLCh));
 	XMLString::copyString(wholeString, buff.getRawBuffer());
 	return wholeString;
 }
diff --git a/src/xercesc/dom/impl/DOMTextImpl.cpp b/src/xercesc/dom/impl/DOMTextImpl.cpp
index 7b87b6f0d9a43d93f6cfb9c73e190508eaac3c58..7150022473b2e8cc5ffbcd17ceff46d000351163 100644
--- a/src/xercesc/dom/impl/DOMTextImpl.cpp
+++ b/src/xercesc/dom/impl/DOMTextImpl.cpp
@@ -145,7 +145,12 @@ bool DOMTextImpl::getIsElementContentWhitespace() const
 const XMLCh* DOMTextImpl::getWholeText() const
 {
     DOMDocument *doc = getOwnerDocument();
-    DOMTreeWalker* pWalker=doc->createTreeWalker(doc->getDocumentElement(), DOMNodeFilter::SHOW_ALL, NULL, true);
+    if (!doc) {
+        throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0, GetDOMNodeMemoryManager);
+        return 0;
+    }
+    DOMNode* root=doc->getDocumentElement();
+    DOMTreeWalker* pWalker=doc->createTreeWalker(root!=NULL?root:(DOMNode*)this, DOMNodeFilter::SHOW_ALL, NULL, true);
     pWalker->setCurrentNode((DOMNode*)this);
     // Logically-adjacent text nodes are Text or CDATASection nodes that can be visited sequentially in document order or in
     // reversed document order without entering, exiting, or passing over Element, Comment, or ProcessingInstruction nodes.
@@ -166,7 +171,7 @@ const XMLCh* DOMTextImpl::getWholeText() const
     }
     pWalker->release();
 
-    XMLCh* wholeString = (XMLCh*) (GetDOMNodeMemoryManager->allocate((buff.getLen()+1)*sizeof(XMLCh)));
+	XMLCh* wholeString = (XMLCh*)((DOMDocumentImpl*)doc)->allocate((buff.getLen()+1) * sizeof(XMLCh));
 	XMLString::copyString(wholeString, buff.getRawBuffer());
 	return wholeString;
 }
diff --git a/tests/src/MemHandlerTest/MemoryMonitor.cpp b/tests/src/MemHandlerTest/MemoryMonitor.cpp
index d81583d278c77739563f6cc7b8b6289aa93dbdda..7ccda7f6e838e1b22bfb494d5b21fe02ba0f6083 100644
--- a/tests/src/MemHandlerTest/MemoryMonitor.cpp
+++ b/tests/src/MemHandlerTest/MemoryMonitor.cpp
@@ -378,6 +378,11 @@ int main (int argC,  char *argV[])
                         XERCES_STD_QUALIFIER cout << "getElementsByTagName didn't return a valid DOMNodeList." << XERCES_STD_QUALIFIER endl;
                     else if(list->item(0)!=doc->getDocumentElement())
                         XERCES_STD_QUALIFIER cout << "getElementsByTagName didn't find the root element." << XERCES_STD_QUALIFIER endl;
+
+                    DOMTreeWalker* pWalker=doc->createTreeWalker(doc->getDocumentElement(), DOMNodeFilter::SHOW_TEXT, NULL, true);
+	                DOMText* textNode=(DOMText*)pWalker->nextNode();
+                    pWalker->release();
+                    const XMLCh* txt=(textNode!=NULL?textNode->getWholeText():NULL);
                 }
                 sax2parser->parse(xmlFile);
                 saxParser->parse(xmlFile);