diff --git a/src/xercesc/internal/DGXMLScanner.cpp b/src/xercesc/internal/DGXMLScanner.cpp
index 27ed02ece63744defd1de2acf5b7249da5ec2580..827779b9f8c8f520a5c411035baa83a59dc8974e 100644
--- a/src/xercesc/internal/DGXMLScanner.cpp
+++ b/src/xercesc/internal/DGXMLScanner.cpp
@@ -2473,14 +2473,16 @@ void DGXMLScanner::scanAttrListforNameSpaces(RefVectorOf<XMLAttr>* theAttrList,
 
 InputSource* DGXMLScanner::resolveSystemId(const XMLCh* const sysId)
 {
-    // Create a buffer for expanding the system id
-    XMLBufBid bbSys(&fBufMgr);
-    XMLBuffer& expSysId = bbSys.getBuffer();
-
-    XMLBuffer& normalizedSysId = bbSys.getBuffer();
+    //Normalize sysId 
+    XMLBufBid nnSys(&fBufMgr);
+    XMLBuffer& normalizedSysId = nnSys.getBuffer();
     XMLString::removeChar(sysId, 0xFFFF, normalizedSysId);
     const XMLCh* normalizedURI = normalizedSysId.getRawBuffer();
 
+    // Create a buffer for expanding the normalized system id
+    XMLBufBid bbSys(&fBufMgr);
+    XMLBuffer& expSysId = bbSys.getBuffer();
+
     //  Allow the entity handler to expand the system id if they choose
     //  to do so.
     InputSource* srcToFill = 0;
diff --git a/src/xercesc/internal/IGXMLScanner2.cpp b/src/xercesc/internal/IGXMLScanner2.cpp
index 544c4cb4250584691fdfc365fdb50a61cd11669c..26683dd0bd6ed7b3c38b53ce9d845a5ea7a00bd7 100644
--- a/src/xercesc/internal/IGXMLScanner2.cpp
+++ b/src/xercesc/internal/IGXMLScanner2.cpp
@@ -1712,17 +1712,19 @@ void IGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con
         parser.setUserEntityHandler(fEntityHandler);
         parser.setUserErrorReporter(fErrorReporter);
 
+        //Normalize loc
+        XMLBufBid nnSys(&fBufMgr);
+        XMLBuffer& normalizedSysId = nnSys.getBuffer();
+        XMLString::removeChar(loc, 0xFFFF, normalizedSysId);
+        const XMLCh* normalizedURI = normalizedSysId.getRawBuffer();
+
         // Create a buffer for expanding the system id
         XMLBufBid bbSys(&fBufMgr);
         XMLBuffer& expSysId = bbSys.getBuffer();
-        XMLBuffer& normalizedSysId = bbSys.getBuffer();
-
-        XMLString::removeChar(loc, 0xFFFF, normalizedSysId);
 
         //  Allow the entity handler to expand the system id if they choose
         //  to do so.
         InputSource* srcToFill = 0;
-        const XMLCh* normalizedURI = normalizedSysId.getRawBuffer();
         if (fEntityHandler)
         {
             if (!fEntityHandler->expandSystemId(normalizedURI, expSysId))
@@ -1892,14 +1894,16 @@ void IGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con
 
 InputSource* IGXMLScanner::resolveSystemId(const XMLCh* const sysId)
 {
+    //Normalize sysId 
+    XMLBufBid nnSys(&fBufMgr);
+    XMLBuffer& normalizedSysId = nnSys.getBuffer();
+    XMLString::removeChar(sysId, 0xFFFF, normalizedSysId);
+    const XMLCh* normalizedURI = normalizedSysId.getRawBuffer();
+
     // Create a buffer for expanding the system id
     XMLBufBid bbSys(&fBufMgr);
     XMLBuffer& expSysId = bbSys.getBuffer();
 
-    XMLBuffer& normalizedSysId = bbSys.getBuffer();
-    XMLString::removeChar(sysId, 0xFFFF, normalizedSysId);
-    const XMLCh* normalizedURI = normalizedSysId.getRawBuffer();
-
     //  Allow the entity handler to expand the system id if they choose
     //  to do so.
     InputSource* srcToFill = 0;
diff --git a/src/xercesc/internal/ReaderMgr.cpp b/src/xercesc/internal/ReaderMgr.cpp
index fa4bb90a96142d18ccf6e93d88606c4fe05c22de..3f7c3aacf31a6fec9e7c845a675ac1db48b4aed1 100644
--- a/src/xercesc/internal/ReaderMgr.cpp
+++ b/src/xercesc/internal/ReaderMgr.cpp
@@ -507,13 +507,14 @@ XMLReader* ReaderMgr::createReader( const   XMLCh* const        sysId
                                     ,       InputSource*&       srcToFill
                                     , const bool                calcSrcOfs)
 {
-    // Create a buffer for expanding the system id
-    XMLBuffer expSysId(1023, fMemoryManager);
-
-    XMLBuffer& normalizedSysId = expSysId;
+    //Normalize sysId 
+    XMLBuffer normalizedSysId(1023, fMemoryManager);
     XMLString::removeChar(sysId, 0xFFFF, normalizedSysId);
     const XMLCh* normalizedURI = normalizedSysId.getRawBuffer();
 
+    // Create a buffer for expanding the system id
+    XMLBuffer expSysId(1023, fMemoryManager);
+
     //
     //  Allow the entity handler to expand the system id if they choose
     //  to do so.
@@ -653,12 +654,14 @@ XMLReader* ReaderMgr::createReader( const   XMLCh* const        baseURI
                                     ,       InputSource*&       srcToFill
                                     , const bool                calcSrcOfs)
 {
+    //Normalize sysId 
+    XMLBuffer normalizedSysId(1023, fMemoryManager);
+    XMLString::removeChar(sysId, 0xFFFF, normalizedSysId);
+    const XMLCh* normalizedURI = normalizedSysId.getRawBuffer();
+
     // Create a buffer for expanding the system id
     XMLBuffer expSysId(1023, fMemoryManager);
 
-    XMLBuffer& normalizedSysId = expSysId;
-    XMLString::removeChar(sysId, 0xFFFF, normalizedSysId);
-    const XMLCh* normalizedURI = normalizedSysId.getRawBuffer();
     //
     //  Allow the entity handler to expand the system id if they choose
     //  to do so.
diff --git a/src/xercesc/internal/SGXMLScanner.cpp b/src/xercesc/internal/SGXMLScanner.cpp
index 048262c9e8b42fc9fdfbe1e6bd90fcc5676a131f..0fb0b855214d1038b5c70a59187d66dae1633e3b 100644
--- a/src/xercesc/internal/SGXMLScanner.cpp
+++ b/src/xercesc/internal/SGXMLScanner.cpp
@@ -3635,17 +3635,19 @@ void SGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con
         parser.setUserEntityHandler(fEntityHandler);
         parser.setUserErrorReporter(fErrorReporter);
 
+        //Normalize sysId 
+        XMLBufBid nnSys(&fBufMgr);
+        XMLBuffer& normalizedSysId = nnSys.getBuffer();
+        XMLString::removeChar(loc, 0xFFFF, normalizedSysId);
+        const XMLCh* normalizedURI = normalizedSysId.getRawBuffer();
+
         // Create a buffer for expanding the system id
         XMLBufBid bbSys(&fBufMgr);
         XMLBuffer& expSysId = bbSys.getBuffer();
-        XMLBuffer& normalizedSysId = bbSys.getBuffer();
-
-        XMLString::removeChar(loc, 0xFFFF, normalizedSysId);
 
         //  Allow the entity handler to expand the system id if they choose
         //  to do so.
         InputSource* srcToFill = 0;
-        const XMLCh* normalizedURI = normalizedSysId.getRawBuffer();
         if (fEntityHandler)
         {
             if (!fEntityHandler->expandSystemId(normalizedURI, expSysId))
@@ -3794,14 +3796,16 @@ void SGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con
 
 InputSource* SGXMLScanner::resolveSystemId(const XMLCh* const sysId)
 {
+    //Normalize sysId 
+    XMLBufBid nnSys(&fBufMgr);
+    XMLBuffer& normalizedSysId = nnSys.getBuffer();
+    XMLString::removeChar(sysId, 0xFFFF, normalizedSysId);
+    const XMLCh* normalizedURI = normalizedSysId.getRawBuffer();
+
     // Create a buffer for expanding the system id
     XMLBufBid bbSys(&fBufMgr);
     XMLBuffer& expSysId = bbSys.getBuffer();
 
-    XMLBuffer& normalizedSysId = bbSys.getBuffer();
-    XMLString::removeChar(sysId, 0xFFFF, normalizedSysId);
-    const XMLCh* normalizedURI = normalizedSysId.getRawBuffer();
-
     //  Allow the entity handler to expand the system id if they choose
     //  to do so.
     InputSource* srcToFill = 0;