diff --git a/src/xercesc/dom/impl/DOMWriterImpl.cpp b/src/xercesc/dom/impl/DOMWriterImpl.cpp
index 08810c024b1e6b1535516046c927131270e3a2e8..934a21bb7225e573d43f902ceb3a80c935c24bd4 100644
--- a/src/xercesc/dom/impl/DOMWriterImpl.cpp
+++ b/src/xercesc/dom/impl/DOMWriterImpl.cpp
@@ -57,6 +57,9 @@
 /*
  * $Id$
  * $Log$
+ * Revision 1.45  2003/11/24 12:27:57  gareth
+ * added in support for xml-declaration feature.
+ *
  * Revision 1.44  2003/11/24 11:10:58  gareth
  * Fix for bug 22917. Patch by Adam Heinz .
  *
@@ -232,6 +235,7 @@ static const int SPLIT_CDATA_SECTIONS_ID          = 0x5;
 static const int VALIDATION_ID                    = 0x6;
 static const int WHITESPACE_IN_ELEMENT_CONTENT_ID = 0x7;
 static const int BYTE_ORDER_MARK_ID               = 0x8;
+static const int XML_DECLARATIION                 = 0x9;
 
 //    feature                      true                       false
 // ================================================================================
@@ -259,7 +263,8 @@ static const bool  featuresSupported[] = {
     true,  true,  // split-cdata-sections
     false, true,  // validation
     true,  false, // whitespace-in-element-content
-    true,  true   // byte-order-mark
+    true,  true,   // byte-order-mark
+    true,  true   // xml-declaration
 };
 
 // default end-of-line sequence
@@ -509,6 +514,8 @@ DOMWriterImpl::DOMWriterImpl(MemoryManager* const manager)
     setFeature(VALIDATION_ID,                    false);
     setFeature(WHITESPACE_IN_ELEMENT_CONTENT_ID, true );
     setFeature(BYTE_ORDER_MARK_ID,               false);
+    setFeature(XML_DECLARATIION,                 true );
+
 }
 
 bool DOMWriterImpl::canSetFeature(const XMLCh* const featName
@@ -886,19 +893,19 @@ void DOMWriterImpl::processNode(const DOMNode* const nodeToWrite, int level)
             //[80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName
             //[32] SDDecl       ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
             //
-            // We always print out the xmldecl no matter whether it is
-            // present in the original XML instance document or not.
-            //
-            const XMLCh* versionNo = (docu->getVersion()) ? docu->getVersion() : gXMLDecl_ver10;
-            *fFormatter << gXMLDecl_VersionInfo << versionNo << gXMLDecl_separator;
 
-            // use the encoding resolved in initSession()
-            *fFormatter << gXMLDecl_EncodingDecl << fEncodingUsed << gXMLDecl_separator;
+            if (getFeature(XML_DECLARATIION)) {
+                const XMLCh* versionNo = (docu->getVersion()) ? docu->getVersion() : gXMLDecl_ver10;
+                *fFormatter << gXMLDecl_VersionInfo << versionNo << gXMLDecl_separator;
 
-            const XMLCh* st = (docu->getStandalone())? XMLUni::fgYesString : XMLUni::fgNoString;
-            *fFormatter << gXMLDecl_SDDecl << st << gXMLDecl_separator;
+                // use the encoding resolved in initSession()
+                *fFormatter << gXMLDecl_EncodingDecl << fEncodingUsed << gXMLDecl_separator;
 
-            *fFormatter << gXMLDecl_endtag;
+                const XMLCh* st = (docu->getStandalone())? XMLUni::fgYesString : XMLUni::fgNoString;
+                *fFormatter << gXMLDecl_SDDecl << st << gXMLDecl_separator;
+                
+                *fFormatter << gXMLDecl_endtag;
+            }
 
             DOMNodeSPtr child = nodeToWrite->getFirstChild();
             while( child != 0)
@@ -1455,6 +1462,9 @@ bool DOMWriterImpl::checkFeature(const XMLCh* const featName
         featureId = WHITESPACE_IN_ELEMENT_CONTENT_ID;
     else if (XMLString::equals(featName, XMLUni::fgDOMWRTBOM))
         featureId = BYTE_ORDER_MARK_ID;
+    else if (XMLString::equals(featName, XMLUni::fgDOMXMLDeclaration))
+        featureId = XML_DECLARATIION;
+
 
     //feature name not resolvable
     if (featureId == INVALID_FEATURE_ID)
diff --git a/src/xercesc/util/XMLUni.cpp b/src/xercesc/util/XMLUni.cpp
index 5d1a34b6f3477c879b5587cd6e355923796b48af..527daea14716b3aa0c695cb09d45f6b5890c0cb8 100644
--- a/src/xercesc/util/XMLUni.cpp
+++ b/src/xercesc/util/XMLUni.cpp
@@ -1388,6 +1388,14 @@ const XMLCh XMLUni::fgDOMWRTBOM[] =
     chLatin_m, chLatin_a, chLatin_r, chLatin_k, chNull
 };
 
+//xml-declaration
+const XMLCh XMLUni::fgDOMXMLDeclaration[] =
+{ 
+    chLatin_x, chLatin_m, chLatin_l, chDash, chLatin_d, chLatin_e, chLatin_c,
+    chLatin_l, chLatin_a, chLatin_r, chLatin_a, chLatin_t, chLatin_i, chLatin_o,
+    chLatin_n, chNull 
+};
+
 // en_US
 const char XMLUni::fgXercescDefaultLocale[] = "en_US";
 
diff --git a/src/xercesc/util/XMLUni.hpp b/src/xercesc/util/XMLUni.hpp
index fe3b7d07c4aa019ba1d012b3157fe7d5e3bf1dda..7b038c90afeeb8b0b897b149244f346f93babed5 100644
--- a/src/xercesc/util/XMLUni.hpp
+++ b/src/xercesc/util/XMLUni.hpp
@@ -288,6 +288,8 @@ public :
     static const XMLCh fgDOMWRTValidation[];
     static const XMLCh fgDOMWRTWhitespaceInElementContent[];
     static const XMLCh fgDOMWRTBOM[];
+    static const XMLCh fgDOMXMLDeclaration[];
+
 
     // Locale
     static const char  fgXercescDefaultLocale[];