diff --git a/src/NLS/EN_US/XMLErrList_EN_US.Xml b/src/NLS/EN_US/XMLErrList_EN_US.Xml
index e7e0a0c5266dc14f1984cd6e92900ba6259f5879..e375ef7bfd2b7aea917978c349fd82a1291e1133 100644
--- a/src/NLS/EN_US/XMLErrList_EN_US.Xml
+++ b/src/NLS/EN_US/XMLErrList_EN_US.Xml
@@ -226,6 +226,7 @@
             <Message Id="XMLDeclMustBeFirst" Text="The XML or Text declaration must start at line/column 1/1"/>
             <Message Id="XMLVersionRequired" Text="The 'version=' string is required in an XMLDecl"/>
             <Message Id="StandaloneNotLegal" Text="The 'standalone=' string is only allowed in the main XML entity"/>
+            <Message Id="EncodingRequired" Text="The 'encoding=' string is required in an Text Decl"/>
             <Message Id="TooManyColonsInName" Text="When namespaces are enabled, a name can have only one colon character"/>
             <Message Id="InvalidColonPos" Text="When namespaces are enabled, the colon cannot be the first or last character"/>
             <Message Id="ColonNotLegalWithNS" Text="Colons are not allowed in this name when namespaces are enabled"/>
diff --git a/src/framework/XMLErrorCodes.hpp b/src/framework/XMLErrorCodes.hpp
index add68b5eb1e586d6d7b568fbcaa3a479985fb835..50abaecab195add788adb151e9445b40c1bf58cb 100644
--- a/src/framework/XMLErrorCodes.hpp
+++ b/src/framework/XMLErrorCodes.hpp
@@ -230,16 +230,17 @@ public :
       , XMLDeclMustBeFirst                 = 217
       , XMLVersionRequired                 = 218
       , StandaloneNotLegal                 = 219
-      , TooManyColonsInName                = 220
-      , InvalidColonPos                    = 221
-      , ColonNotLegalWithNS                = 222
-      , SysException                       = 223
-      , XMLException                       = 224
-      , UnexpectedEOF                      = 225
-      , UnexpectedError                    = 226
-      , BadSchemaLocation                  = 227
-      , NoGrammarResolver                  = 228
-      , F_HighBounds                       = 229
+      , EncodingRequired                   = 220
+      , TooManyColonsInName                = 221
+      , InvalidColonPos                    = 222
+      , ColonNotLegalWithNS                = 223
+      , SysException                       = 224
+      , XMLException                       = 225
+      , UnexpectedEOF                      = 226
+      , UnexpectedError                    = 227
+      , BadSchemaLocation                  = 228
+      , NoGrammarResolver                  = 229
+      , F_HighBounds                       = 230
     };
 
     static bool isFatal(const XMLErrs::Codes toCheck)
diff --git a/src/internal/XMLScanner.cpp b/src/internal/XMLScanner.cpp
index 10e4bddfdab29ef74c1da0c708f2d7f16a7499c3..8bcbe35e27f301c1384707a580996e7c7149c32b 100644
--- a/src/internal/XMLScanner.cpp
+++ b/src/internal/XMLScanner.cpp
@@ -3122,6 +3122,8 @@ bool XMLScanner::scanStartTagNS(bool& gotData)
 //  though we'll issue errors.
 //
 //  The parameter tells us which type of decl we should expect, Text or XML.
+//    [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
+//    [77] TextDecl::= '<?xml' VersionInfo? EncodingDecl S? '?>'
 //
 void XMLScanner::scanXMLDecl(const DeclTypes type)
 {
@@ -3269,13 +3271,17 @@ void XMLScanner::scanXMLDecl(const DeclTypes type)
     }
 
     //
-    //  If its an XML decl, the version must be present. If its a Text decl
-    //  then standalone must not be present.
+    //  If its an XML decl, the version must be present.
+    //  If its a Text decl, then encoding must be present AND standalone must not be present.
     //
     if ((type == Decl_XML) && (flags[VersionString] == -1))
         emitError(XMLErrs::XMLVersionRequired);
-    else if ((type == Decl_Text) && (flags[StandaloneString] != -1))
-        emitError(XMLErrs::StandaloneNotLegal);
+    else if (type == Decl_Text) {
+        if (flags[StandaloneString] != -1)
+            emitError(XMLErrs::StandaloneNotLegal);
+        if (flags[EncodingString] == -1)
+            emitError(XMLErrs::EncodingRequired);
+    }
 
     if (!fReaderMgr.skippedChar(chQuestion))
     {
diff --git a/src/internal/XMLScanner2.cpp b/src/internal/XMLScanner2.cpp
index c01b35332b14101cfad8b1e86517620a71f33ea1..c5a533099999291f65f1b9b61b9a045f61d9f170 100644
--- a/src/internal/XMLScanner2.cpp
+++ b/src/internal/XMLScanner2.cpp
@@ -2562,6 +2562,11 @@ XMLScanner::scanEntityRef(  const   bool    inAttVal
         if (fDocHandler && !inAttVal)
             fDocHandler->startEntityReference(*decl);
 
+        // If it starts with the XML string, then it's an error
+        if (checkXMLDecl(true)) {
+            emitError(XMLErrs::TextDeclNotLegalHere);
+            fReaderMgr.skipPastChar(chCloseAngle);
+        }
     }
     return EntityExp_Pushed;
 }
diff --git a/src/util/MsgLoaders/InMemory/CppErrMsgs_EN_US.hpp b/src/util/MsgLoaders/InMemory/CppErrMsgs_EN_US.hpp
index 7527671d3eabfe0366d8a58a0d26e7879d3d2426..b843195c9573c53793923081eed4fce62bfb3571 100644
--- a/src/util/MsgLoaders/InMemory/CppErrMsgs_EN_US.hpp
+++ b/src/util/MsgLoaders/InMemory/CppErrMsgs_EN_US.hpp
@@ -224,6 +224,7 @@ const XMLCh gXMLErrArray[][128] =
   , { 0x0054,0x0068,0x0065,0x0020,0x0058,0x004D,0x004C,0x0020,0x006F,0x0072,0x0020,0x0054,0x0065,0x0078,0x0074,0x0020,0x0064,0x0065,0x0063,0x006C,0x0061,0x0072,0x0061,0x0074,0x0069,0x006F,0x006E,0x0020,0x006D,0x0075,0x0073,0x0074,0x0020,0x0073,0x0074,0x0061,0x0072,0x0074,0x0020,0x0061,0x0074,0x0020,0x006C,0x0069,0x006E,0x0065,0x002F,0x0063,0x006F,0x006C,0x0075,0x006D,0x006E,0x0020,0x0031,0x002F,0x0031,0x00 }
   , { 0x0054,0x0068,0x0065,0x0020,0x0027,0x0076,0x0065,0x0072,0x0073,0x0069,0x006F,0x006E,0x003D,0x0027,0x0020,0x0073,0x0074,0x0072,0x0069,0x006E,0x0067,0x0020,0x0069,0x0073,0x0020,0x0072,0x0065,0x0071,0x0075,0x0069,0x0072,0x0065,0x0064,0x0020,0x0069,0x006E,0x0020,0x0061,0x006E,0x0020,0x0058,0x004D,0x004C,0x0044,0x0065,0x0063,0x006C,0x00 }
   , { 0x0054,0x0068,0x0065,0x0020,0x0027,0x0073,0x0074,0x0061,0x006E,0x0064,0x0061,0x006C,0x006F,0x006E,0x0065,0x003D,0x0027,0x0020,0x0073,0x0074,0x0072,0x0069,0x006E,0x0067,0x0020,0x0069,0x0073,0x0020,0x006F,0x006E,0x006C,0x0079,0x0020,0x0061,0x006C,0x006C,0x006F,0x0077,0x0065,0x0064,0x0020,0x0069,0x006E,0x0020,0x0074,0x0068,0x0065,0x0020,0x006D,0x0061,0x0069,0x006E,0x0020,0x0058,0x004D,0x004C,0x0020,0x0065,0x006E,0x0074,0x0069,0x0074,0x0079,0x00 }
+  , { 0x0054,0x0068,0x0065,0x0020,0x0027,0x0065,0x006E,0x0063,0x006F,0x0064,0x0069,0x006E,0x0067,0x003D,0x0027,0x0020,0x0073,0x0074,0x0072,0x0069,0x006E,0x0067,0x0020,0x0069,0x0073,0x0020,0x0072,0x0065,0x0071,0x0075,0x0069,0x0072,0x0065,0x0064,0x0020,0x0069,0x006E,0x0020,0x0061,0x006E,0x0020,0x0054,0x0065,0x0078,0x0074,0x0020,0x0044,0x0065,0x0063,0x006C,0x00 }
   , { 0x0057,0x0068,0x0065,0x006E,0x0020,0x006E,0x0061,0x006D,0x0065,0x0073,0x0070,0x0061,0x0063,0x0065,0x0073,0x0020,0x0061,0x0072,0x0065,0x0020,0x0065,0x006E,0x0061,0x0062,0x006C,0x0065,0x0064,0x002C,0x0020,0x0061,0x0020,0x006E,0x0061,0x006D,0x0065,0x0020,0x0063,0x0061,0x006E,0x0020,0x0068,0x0061,0x0076,0x0065,0x0020,0x006F,0x006E,0x006C,0x0079,0x0020,0x006F,0x006E,0x0065,0x0020,0x0063,0x006F,0x006C,0x006F,0x006E,0x0020,0x0063,0x0068,0x0061,0x0072,0x0061,0x0063,0x0074,0x0065,0x0072,0x00 }
   , { 0x0057,0x0068,0x0065,0x006E,0x0020,0x006E,0x0061,0x006D,0x0065,0x0073,0x0070,0x0061,0x0063,0x0065,0x0073,0x0020,0x0061,0x0072,0x0065,0x0020,0x0065,0x006E,0x0061,0x0062,0x006C,0x0065,0x0064,0x002C,0x0020,0x0074,0x0068,0x0065,0x0020,0x0063,0x006F,0x006C,0x006F,0x006E,0x0020,0x0063,0x0061,0x006E,0x006E,0x006F,0x0074,0x0020,0x0062,0x0065,0x0020,0x0074,0x0068,0x0065,0x0020,0x0066,0x0069,0x0072,0x0073,0x0074,0x0020,0x006F,0x0072,0x0020,0x006C,0x0061,0x0073,0x0074,0x0020,0x0063,0x0068,0x0061,0x0072,0x0061,0x0063,0x0074,0x0065,0x0072,0x00 }
   , { 0x0043,0x006F,0x006C,0x006F,0x006E,0x0073,0x0020,0x0061,0x0072,0x0065,0x0020,0x006E,0x006F,0x0074,0x0020,0x0061,0x006C,0x006C,0x006F,0x0077,0x0065,0x0064,0x0020,0x0069,0x006E,0x0020,0x0074,0x0068,0x0069,0x0073,0x0020,0x006E,0x0061,0x006D,0x0065,0x0020,0x0077,0x0068,0x0065,0x006E,0x0020,0x006E,0x0061,0x006D,0x0065,0x0073,0x0070,0x0061,0x0063,0x0065,0x0073,0x0020,0x0061,0x0072,0x0065,0x0020,0x0065,0x006E,0x0061,0x0062,0x006C,0x0065,0x0064,0x00 }
@@ -236,7 +237,7 @@ const XMLCh gXMLErrArray[][128] =
   , { 0x0046,0x005F,0x0045,0x006E,0x0064,0x00 }
 
 };
-const unsigned int gXMLErrArraySize = 230;
+const unsigned int gXMLErrArraySize = 231;
 
 const XMLCh gXMLValidityArray[][128] = 
 {
diff --git a/src/util/MsgLoaders/MsgCatalog/XMLMsgCat_EN_US.Msg b/src/util/MsgLoaders/MsgCatalog/XMLMsgCat_EN_US.Msg
index 187765dee38e230f1dc6ec5f9710b954e6c3a488..777b207227853036740a33be8b83b90c67388a35 100644
--- a/src/util/MsgLoaders/MsgCatalog/XMLMsgCat_EN_US.Msg
+++ b/src/util/MsgLoaders/MsgCatalog/XMLMsgCat_EN_US.Msg
@@ -214,15 +214,16 @@ $set 1
 217  The XML or Text declaration must start at line/column 1/1
 218  The 'version=' string is required in an XMLDecl
 219  The 'standalone=' string is only allowed in the main XML entity
-220  When namespaces are enabled, a name can have only one colon character
-221  When namespaces are enabled, the colon cannot be the first or last character
-222  Colons are not allowed in this name when namespaces are enabled
-223  A system exception occured during processing
-224  An exception occured! Type:{0}, Message:{1}
-225  Unexpected end of file exception. Message: {0}
-226  UnexpectedError
-227  The schemaLocation attribute does not contain pairs of values.
-228  Internal error: don't have a GrammarResolver for TraverseSchema
+220  The 'encoding=' string is required in an Text Decl
+221  When namespaces are enabled, a name can have only one colon character
+222  When namespaces are enabled, the colon cannot be the first or last character
+223  Colons are not allowed in this name when namespaces are enabled
+224  A system exception occured during processing
+225  An exception occured! Type:{0}, Message:{1}
+226  Unexpected end of file exception. Message: {0}
+227  UnexpectedError
+228  The schemaLocation attribute does not contain pairs of values.
+229  Internal error: don't have a GrammarResolver for TraverseSchema
 
 
 $set 2
diff --git a/src/util/Platforms/Win32/Version.rc b/src/util/Platforms/Win32/Version.rc
index 534306fc704a22259fe4f97bca2703f727c56721..01ba63c9e81dcc4c487ea4508ac7de62b443a9d4 100644
--- a/src/util/Platforms/Win32/Version.rc
+++ b/src/util/Platforms/Win32/Version.rc
@@ -101,6 +101,7 @@ END
 
 
 
+
 // ----------------------------------------------------------------
 //  This file was generated from the XML error message source.
 //  so do not edit this file directly!!
@@ -322,15 +323,16 @@ BEGIN
     217               L"\x0054\x0068\x0065\x0020\x0058\x004D\x004C\x0020\x006F\x0072\x0020\x0054\x0065\x0078\x0074\x0020\x0064\x0065\x0063\x006C\x0061\x0072\x0061\x0074\x0069\x006F\x006E\x0020\x006D\x0075\x0073\x0074\x0020\x0073\x0074\x0061\x0072\x0074\x0020\x0061\x0074\x0020\x006C\x0069\x006E\x0065\x002F\x0063\x006F\x006C\x0075\x006D\x006E\x0020\x0031\x002F\x0031\x00"
     218               L"\x0054\x0068\x0065\x0020\x0027\x0076\x0065\x0072\x0073\x0069\x006F\x006E\x003D\x0027\x0020\x0073\x0074\x0072\x0069\x006E\x0067\x0020\x0069\x0073\x0020\x0072\x0065\x0071\x0075\x0069\x0072\x0065\x0064\x0020\x0069\x006E\x0020\x0061\x006E\x0020\x0058\x004D\x004C\x0044\x0065\x0063\x006C\x00"
     219               L"\x0054\x0068\x0065\x0020\x0027\x0073\x0074\x0061\x006E\x0064\x0061\x006C\x006F\x006E\x0065\x003D\x0027\x0020\x0073\x0074\x0072\x0069\x006E\x0067\x0020\x0069\x0073\x0020\x006F\x006E\x006C\x0079\x0020\x0061\x006C\x006C\x006F\x0077\x0065\x0064\x0020\x0069\x006E\x0020\x0074\x0068\x0065\x0020\x006D\x0061\x0069\x006E\x0020\x0058\x004D\x004C\x0020\x0065\x006E\x0074\x0069\x0074\x0079\x00"
-    220               L"\x0057\x0068\x0065\x006E\x0020\x006E\x0061\x006D\x0065\x0073\x0070\x0061\x0063\x0065\x0073\x0020\x0061\x0072\x0065\x0020\x0065\x006E\x0061\x0062\x006C\x0065\x0064\x002C\x0020\x0061\x0020\x006E\x0061\x006D\x0065\x0020\x0063\x0061\x006E\x0020\x0068\x0061\x0076\x0065\x0020\x006F\x006E\x006C\x0079\x0020\x006F\x006E\x0065\x0020\x0063\x006F\x006C\x006F\x006E\x0020\x0063\x0068\x0061\x0072\x0061\x0063\x0074\x0065\x0072\x00"
-    221               L"\x0057\x0068\x0065\x006E\x0020\x006E\x0061\x006D\x0065\x0073\x0070\x0061\x0063\x0065\x0073\x0020\x0061\x0072\x0065\x0020\x0065\x006E\x0061\x0062\x006C\x0065\x0064\x002C\x0020\x0074\x0068\x0065\x0020\x0063\x006F\x006C\x006F\x006E\x0020\x0063\x0061\x006E\x006E\x006F\x0074\x0020\x0062\x0065\x0020\x0074\x0068\x0065\x0020\x0066\x0069\x0072\x0073\x0074\x0020\x006F\x0072\x0020\x006C\x0061\x0073\x0074\x0020\x0063\x0068\x0061\x0072\x0061\x0063\x0074\x0065\x0072\x00"
-    222               L"\x0043\x006F\x006C\x006F\x006E\x0073\x0020\x0061\x0072\x0065\x0020\x006E\x006F\x0074\x0020\x0061\x006C\x006C\x006F\x0077\x0065\x0064\x0020\x0069\x006E\x0020\x0074\x0068\x0069\x0073\x0020\x006E\x0061\x006D\x0065\x0020\x0077\x0068\x0065\x006E\x0020\x006E\x0061\x006D\x0065\x0073\x0070\x0061\x0063\x0065\x0073\x0020\x0061\x0072\x0065\x0020\x0065\x006E\x0061\x0062\x006C\x0065\x0064\x00"
-    223               L"\x0041\x0020\x0073\x0079\x0073\x0074\x0065\x006D\x0020\x0065\x0078\x0063\x0065\x0070\x0074\x0069\x006F\x006E\x0020\x006F\x0063\x0063\x0075\x0072\x0065\x0064\x0020\x0064\x0075\x0072\x0069\x006E\x0067\x0020\x0070\x0072\x006F\x0063\x0065\x0073\x0073\x0069\x006E\x0067\x00"
-    224               L"\x0041\x006E\x0020\x0065\x0078\x0063\x0065\x0070\x0074\x0069\x006F\x006E\x0020\x006F\x0063\x0063\x0075\x0072\x0065\x0064\x0021\x0020\x0054\x0079\x0070\x0065\x003A\x007B\x0030\x007D\x002C\x0020\x004D\x0065\x0073\x0073\x0061\x0067\x0065\x003A\x007B\x0031\x007D\x00"
-    225               L"\x0055\x006E\x0065\x0078\x0070\x0065\x0063\x0074\x0065\x0064\x0020\x0065\x006E\x0064\x0020\x006F\x0066\x0020\x0066\x0069\x006C\x0065\x0020\x0065\x0078\x0063\x0065\x0070\x0074\x0069\x006F\x006E\x002E\x0020\x004D\x0065\x0073\x0073\x0061\x0067\x0065\x003A\x0020\x007B\x0030\x007D\x00"
-    226               L"\x0055\x006E\x0065\x0078\x0070\x0065\x0063\x0074\x0065\x0064\x0045\x0072\x0072\x006F\x0072\x00"
-    227               L"\x0054\x0068\x0065\x0020\x0073\x0063\x0068\x0065\x006D\x0061\x004C\x006F\x0063\x0061\x0074\x0069\x006F\x006E\x0020\x0061\x0074\x0074\x0072\x0069\x0062\x0075\x0074\x0065\x0020\x0064\x006F\x0065\x0073\x0020\x006E\x006F\x0074\x0020\x0063\x006F\x006E\x0074\x0061\x0069\x006E\x0020\x0070\x0061\x0069\x0072\x0073\x0020\x006F\x0066\x0020\x0076\x0061\x006C\x0075\x0065\x0073\x002E\x00"
-    228               L"\x0049\x006E\x0074\x0065\x0072\x006E\x0061\x006C\x0020\x0065\x0072\x0072\x006F\x0072\x003A\x0020\x0064\x006F\x006E\x0027\x0074\x0020\x0068\x0061\x0076\x0065\x0020\x0061\x0020\x0047\x0072\x0061\x006D\x006D\x0061\x0072\x0052\x0065\x0073\x006F\x006C\x0076\x0065\x0072\x0020\x0066\x006F\x0072\x0020\x0054\x0072\x0061\x0076\x0065\x0072\x0073\x0065\x0053\x0063\x0068\x0065\x006D\x0061\x00"
+    220               L"\x0054\x0068\x0065\x0020\x0027\x0065\x006E\x0063\x006F\x0064\x0069\x006E\x0067\x003D\x0027\x0020\x0073\x0074\x0072\x0069\x006E\x0067\x0020\x0069\x0073\x0020\x0072\x0065\x0071\x0075\x0069\x0072\x0065\x0064\x0020\x0069\x006E\x0020\x0061\x006E\x0020\x0054\x0065\x0078\x0074\x0020\x0044\x0065\x0063\x006C\x00"
+    221               L"\x0057\x0068\x0065\x006E\x0020\x006E\x0061\x006D\x0065\x0073\x0070\x0061\x0063\x0065\x0073\x0020\x0061\x0072\x0065\x0020\x0065\x006E\x0061\x0062\x006C\x0065\x0064\x002C\x0020\x0061\x0020\x006E\x0061\x006D\x0065\x0020\x0063\x0061\x006E\x0020\x0068\x0061\x0076\x0065\x0020\x006F\x006E\x006C\x0079\x0020\x006F\x006E\x0065\x0020\x0063\x006F\x006C\x006F\x006E\x0020\x0063\x0068\x0061\x0072\x0061\x0063\x0074\x0065\x0072\x00"
+    222               L"\x0057\x0068\x0065\x006E\x0020\x006E\x0061\x006D\x0065\x0073\x0070\x0061\x0063\x0065\x0073\x0020\x0061\x0072\x0065\x0020\x0065\x006E\x0061\x0062\x006C\x0065\x0064\x002C\x0020\x0074\x0068\x0065\x0020\x0063\x006F\x006C\x006F\x006E\x0020\x0063\x0061\x006E\x006E\x006F\x0074\x0020\x0062\x0065\x0020\x0074\x0068\x0065\x0020\x0066\x0069\x0072\x0073\x0074\x0020\x006F\x0072\x0020\x006C\x0061\x0073\x0074\x0020\x0063\x0068\x0061\x0072\x0061\x0063\x0074\x0065\x0072\x00"
+    223               L"\x0043\x006F\x006C\x006F\x006E\x0073\x0020\x0061\x0072\x0065\x0020\x006E\x006F\x0074\x0020\x0061\x006C\x006C\x006F\x0077\x0065\x0064\x0020\x0069\x006E\x0020\x0074\x0068\x0069\x0073\x0020\x006E\x0061\x006D\x0065\x0020\x0077\x0068\x0065\x006E\x0020\x006E\x0061\x006D\x0065\x0073\x0070\x0061\x0063\x0065\x0073\x0020\x0061\x0072\x0065\x0020\x0065\x006E\x0061\x0062\x006C\x0065\x0064\x00"
+    224               L"\x0041\x0020\x0073\x0079\x0073\x0074\x0065\x006D\x0020\x0065\x0078\x0063\x0065\x0070\x0074\x0069\x006F\x006E\x0020\x006F\x0063\x0063\x0075\x0072\x0065\x0064\x0020\x0064\x0075\x0072\x0069\x006E\x0067\x0020\x0070\x0072\x006F\x0063\x0065\x0073\x0073\x0069\x006E\x0067\x00"
+    225               L"\x0041\x006E\x0020\x0065\x0078\x0063\x0065\x0070\x0074\x0069\x006F\x006E\x0020\x006F\x0063\x0063\x0075\x0072\x0065\x0064\x0021\x0020\x0054\x0079\x0070\x0065\x003A\x007B\x0030\x007D\x002C\x0020\x004D\x0065\x0073\x0073\x0061\x0067\x0065\x003A\x007B\x0031\x007D\x00"
+    226               L"\x0055\x006E\x0065\x0078\x0070\x0065\x0063\x0074\x0065\x0064\x0020\x0065\x006E\x0064\x0020\x006F\x0066\x0020\x0066\x0069\x006C\x0065\x0020\x0065\x0078\x0063\x0065\x0070\x0074\x0069\x006F\x006E\x002E\x0020\x004D\x0065\x0073\x0073\x0061\x0067\x0065\x003A\x0020\x007B\x0030\x007D\x00"
+    227               L"\x0055\x006E\x0065\x0078\x0070\x0065\x0063\x0074\x0065\x0064\x0045\x0072\x0072\x006F\x0072\x00"
+    228               L"\x0054\x0068\x0065\x0020\x0073\x0063\x0068\x0065\x006D\x0061\x004C\x006F\x0063\x0061\x0074\x0069\x006F\x006E\x0020\x0061\x0074\x0074\x0072\x0069\x0062\x0075\x0074\x0065\x0020\x0064\x006F\x0065\x0073\x0020\x006E\x006F\x0074\x0020\x0063\x006F\x006E\x0074\x0061\x0069\x006E\x0020\x0070\x0061\x0069\x0072\x0073\x0020\x006F\x0066\x0020\x0076\x0061\x006C\x0075\x0065\x0073\x002E\x00"
+    229               L"\x0049\x006E\x0074\x0065\x0072\x006E\x0061\x006C\x0020\x0065\x0072\x0072\x006F\x0072\x003A\x0020\x0064\x006F\x006E\x0027\x0074\x0020\x0068\x0061\x0076\x0065\x0020\x0061\x0020\x0047\x0072\x0061\x006D\x006D\x0061\x0072\x0052\x0065\x0073\x006F\x006C\x0076\x0065\x0072\x0020\x0066\x006F\x0072\x0020\x0054\x0072\x0061\x0076\x0065\x0072\x0073\x0065\x0053\x0063\x0068\x0065\x006D\x0061\x00"
 END
 STRINGTABLE DISCARDABLE
 BEGIN
diff --git a/src/validators/DTD/DTDScanner.cpp b/src/validators/DTD/DTDScanner.cpp
index 34c3c32007455bede32bb1a743165335fabff68e..17c46d5341309c5952fe0b028919747f09a425fc 100644
--- a/src/validators/DTD/DTDScanner.cpp
+++ b/src/validators/DTD/DTDScanner.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.13  2001/07/05 14:05:29  tng
+ * Encoding String must present for external entity text decl.
+ *
  * Revision 1.12  2001/07/05 13:12:19  tng
  * Standalone checking is validity constraint and thus should be just error, not fatal error:
  *
@@ -3700,6 +3703,7 @@ bool DTDScanner::scanSystemLiteral(XMLBuffer& toFill)
 //
 //  On entry the <? has been scanned, and next should be 'xml' followed by
 //  some whitespace, version string, etc...
+//    [77] TextDecl::= '<?xml' VersionInfo? EncodingDecl S? '?>'
 //
 void DTDScanner::scanTextDecl()
 {
@@ -3733,7 +3737,7 @@ void DTDScanner::scanTextDecl()
             fScanner->emitError(XMLErrs::UnsupportedXMLVersion, bbVersion.getRawBuffer());
     }
 
-    // Ok, now we can have an encoding string, but we don't have to
+    // Ok, now we must have an encoding string
     XMLBufBid bbEncoding(fBufMgr);
     fReaderMgr->skipPastSpaces();
     bool gotEncoding = false;
@@ -3761,12 +3765,12 @@ void DTDScanner::scanTextDecl()
     }
 
     //
-    // [78] Encoding declarations are required in the external entity
+    // Encoding declarations are required in the external entity
     // if there is a text declaration present
     //
-    if (!fInternalSubset && !gotEncoding)
+    if (!gotEncoding)
     {
-      fScanner->emitError(XMLErrs::BadXMLEncoding);
+      fScanner->emitError(XMLErrs::EncodingRequired);
       fReaderMgr->skipPastChar(chCloseAngle);
       return;