diff --git a/src/xercesc/dom/impl/DOMWriterImpl.cpp b/src/xercesc/dom/impl/DOMWriterImpl.cpp
index 1d587dde65997f82336247f271102d369f9807c5..ff00d208d3e8950155fb58752656034dd665deb0 100644
--- a/src/xercesc/dom/impl/DOMWriterImpl.cpp
+++ b/src/xercesc/dom/impl/DOMWriterImpl.cpp
@@ -57,6 +57,9 @@
 /*
  * $Id$
  * $Log$
+ * Revision 1.31  2003/03/16 05:42:04  peiyongz
+ * Bug#17983 Formatter does not escape control characters
+ *
  * Revision 1.30  2003/02/25 16:07:37  tng
  * [Bug 13493] Use const on static data in DOMWriterImpl.cpp.
  *
@@ -427,6 +430,7 @@ DOMWriterImpl::DOMWriterImpl()
 ,fNewLine(0)
 ,fErrorHandler(0)
 ,fFilter(0)
+,fDocumentVersion(XMLUni::fgVersion1_0)
 ,fEncodingUsed(0)
 ,fNewLineUsed(0)
 ,fFormatter(0)
@@ -548,6 +552,7 @@ bool DOMWriterImpl::writeNode(XMLFormatTarget* const destination
     try
     {
         fFormatter = new XMLFormatter(fEncodingUsed
+                                     ,fDocumentVersion
                                      ,destination
                                      ,XMLFormatter::NoEscapes
                                      ,XMLFormatter::UnRep_CharRef);
@@ -700,6 +705,16 @@ void DOMWriterImpl::initSession(const DOMNode* const nodeToWrite)
      */
     fNewLineUsed = (fNewLine && *fNewLine)? fNewLine : gEOLSeq;
 
+    /**
+     *  get Document Version
+     */
+    const DOMDocument *docu = (nodeToWrite->getNodeType() == DOMNode::DOCUMENT_NODE)?
+                              (const DOMDocument*)nodeToWrite : nodeToWrite->getOwnerDocument();
+    if (docu)
+    {
+        fDocumentVersion = docu->getVersion();
+    }
+
     fErrorCount = 0;
 }
 
diff --git a/src/xercesc/dom/impl/DOMWriterImpl.hpp b/src/xercesc/dom/impl/DOMWriterImpl.hpp
index 2b91d72d5efdb8194c40b88f8955db168cc93ec5..d22db0f39830d24d2ff37ad4b20b8104bfc20356 100644
--- a/src/xercesc/dom/impl/DOMWriterImpl.hpp
+++ b/src/xercesc/dom/impl/DOMWriterImpl.hpp
@@ -57,6 +57,9 @@
 /*
  * $Id$
  * $Log$
+ * Revision 1.13  2003/03/16 05:42:04  peiyongz
+ * Bug#17983 Formatter does not escape control characters
+ *
  * Revision 1.12  2003/01/28 18:31:47  peiyongz
  * Bug#13694: Allow Xerces to write the BOM to XML files
  *
@@ -438,6 +441,9 @@ private:
     //  fFilter
     //      don't own it
     //
+    //  fDocumentVersion
+    //      The XML Version of the document to be serialized.
+    // 
     //  fEncodingUsed (session var)
     //      the actual encoding used in WriteNode(),
     //      it does not own any data(memory).
@@ -466,6 +472,7 @@ private:
     XMLCh                        *fNewLine;
     DOMErrorHandler              *fErrorHandler;
     DOMWriterFilter              *fFilter;
+    const XMLCh                  *fDocumentVersion;
 
     //session vars
     const XMLCh                  *fEncodingUsed;
@@ -473,6 +480,8 @@ private:
     XMLFormatter                 *fFormatter;
     int                           fErrorCount;
     int                           fCurrentLine;
+
+
 };
 
 inline void DOMWriterImpl::setFeature(const int featureId