diff --git a/src/xercesc/internal/DGXMLScanner.cpp b/src/xercesc/internal/DGXMLScanner.cpp
index 7a5aa5dee6ff02b27fdbb2eff9f590cf6e191c61..60d8b0cc25a4b6b6841f957f7840a81a9471adb2 100644
--- a/src/xercesc/internal/DGXMLScanner.cpp
+++ b/src/xercesc/internal/DGXMLScanner.cpp
@@ -925,7 +925,7 @@ void DGXMLScanner::scanDocTypeDecl()
         // Eat the opening square bracket
         fReaderMgr.getNextChar();
 
-        checkInternalDTD(hasExtSubset, sysId);
+        checkInternalDTD(hasExtSubset, sysId, pubId);
 
         //  And try to scan the internal subset. If we fail, try to recover
         //  by skipping forward tot he close angle and returning.
@@ -974,7 +974,8 @@ void DGXMLScanner::scanDocTypeDecl()
         Janitor<InputSource> janSrc(srcUsed);
         if (fUseCachedGrammar)
         {
-            srcUsed = resolveSystemId(sysId);
+            srcUsed = resolveSystemId(sysId, pubId);
+            janSrc.reset(srcUsed);
             Grammar* grammar = fGrammarResolver->getGrammar(srcUsed->getSystemId());
 
             if (grammar && grammar->getGrammarType() == Grammar::DTDGrammarType) {
@@ -1021,7 +1022,7 @@ void DGXMLScanner::scanDocTypeDecl()
         {
             // And now create a reader to read this entity
             XMLReader* reader;
-            if(srcUsed!=0)
+            if(srcUsed) {
                 reader = fReaderMgr.createReader
                         (
                             *srcUsed
@@ -1031,7 +1032,8 @@ void DGXMLScanner::scanDocTypeDecl()
                             , XMLReader::Source_External
                             , fCalculateSrcOfs
                         );
-            else
+            }
+            else {
                 reader = fReaderMgr.createReader
                         (
                             sysId
@@ -1043,7 +1045,8 @@ void DGXMLScanner::scanDocTypeDecl()
                             , srcUsed
                             , fCalculateSrcOfs
                         );
-
+                janSrc.reset(srcUsed);
+            }
             //  If it failed then throw an exception
             if (!reader)
                 ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Gen_CouldNotOpenDTD, srcUsed->getSystemId(), fMemoryManager);
@@ -2470,7 +2473,8 @@ void DGXMLScanner::scanAttrListforNameSpaces(RefVectorOf<XMLAttr>* theAttrList,
     }
 }
 
-InputSource* DGXMLScanner::resolveSystemId(const XMLCh* const sysId)
+InputSource* DGXMLScanner::resolveSystemId(const XMLCh* const sysId
+                                          ,const XMLCh* const pubId)
 {
     //Normalize sysId 
     XMLBufBid nnSys(&fBufMgr);
@@ -2493,7 +2497,7 @@ InputSource* DGXMLScanner::resolveSystemId(const XMLCh* const sysId)
         ReaderMgr::LastExtEntityInfo lastInfo;
         fReaderMgr.getLastExtEntityInfo(lastInfo);
         XMLResourceIdentifier resourceIdentifier(XMLResourceIdentifier::ExternalEntity,
-                            expSysId.getRawBuffer(), 0, XMLUni::fgZeroLenString, lastInfo.systemId);
+                            expSysId.getRawBuffer(), 0, pubId, lastInfo.systemId);
         srcToFill = fEntityHandler->resolveEntity(&resourceIdentifier);
     }
     else
diff --git a/src/xercesc/internal/DGXMLScanner.hpp b/src/xercesc/internal/DGXMLScanner.hpp
index 7b41f3724f5cc32d3c705b54f7dc54751157152a..a558fe592c0ff07c6c8f1bb5d7b284df3b53b2a4 100644
--- a/src/xercesc/internal/DGXMLScanner.hpp
+++ b/src/xercesc/internal/DGXMLScanner.hpp
@@ -16,6 +16,9 @@
 
 /*
  * $Log$
+ * Revision 1.15  2004/12/03 19:40:30  cargilld
+ * Change call to resolveEntity to pass in public id so that only one call to resolveEntity is needed (a follow-on to Alberto's fix).
+ *
  * Revision 1.14  2004/09/08 13:56:13  peiyongz
  * Apache License Version 2.0
  *
@@ -150,7 +153,8 @@ private :
     virtual void scanDocTypeDecl();
     virtual void scanReset(const InputSource& src);
     virtual void sendCharData(XMLBuffer& toSend);
-    virtual InputSource* resolveSystemId(const XMLCh* const sysId); 
+    virtual InputSource* resolveSystemId(const XMLCh* const sysId
+                                        ,const XMLCh* const pubId); 
 
     // -----------------------------------------------------------------------
     //  Private helper methods
diff --git a/src/xercesc/internal/IGXMLScanner.cpp b/src/xercesc/internal/IGXMLScanner.cpp
index bf41c9ea2028357d8aa29a78a9835483c47d4751..faf8a25b6f2abf5cea100650762d7b73c0815b0c 100644
--- a/src/xercesc/internal/IGXMLScanner.cpp
+++ b/src/xercesc/internal/IGXMLScanner.cpp
@@ -1376,7 +1376,7 @@ void IGXMLScanner::scanDocTypeDecl()
         // Eat the opening square bracket
         fReaderMgr.getNextChar();
 
-        checkInternalDTD(hasExtSubset, sysId);
+        checkInternalDTD(hasExtSubset, sysId, pubId);
 
         //  And try to scan the internal subset. If we fail, try to recover
         //  by skipping forward tot he close angle and returning.
@@ -1425,7 +1425,8 @@ void IGXMLScanner::scanDocTypeDecl()
         Janitor<InputSource> janSrc(srcUsed);
         if (fUseCachedGrammar)
         {
-            srcUsed = resolveSystemId(sysId);
+            srcUsed = resolveSystemId(sysId, pubId);
+            janSrc.reset(srcUsed);
             Grammar* grammar = fGrammarResolver->getGrammar(srcUsed->getSystemId());
 
             if (grammar && grammar->getGrammarType() == Grammar::DTDGrammarType) {
@@ -1470,7 +1471,7 @@ void IGXMLScanner::scanDocTypeDecl()
         {
             // And now create a reader to read this entity
             XMLReader* reader;
-            if(srcUsed!=0)
+            if (srcUsed) {
                 reader = fReaderMgr.createReader
                         (
                             *srcUsed
@@ -1480,7 +1481,8 @@ void IGXMLScanner::scanDocTypeDecl()
                             , XMLReader::Source_External
                             , fCalculateSrcOfs
                         );
-            else
+            }
+            else {
                 reader = fReaderMgr.createReader
                         (
                             sysId
@@ -1492,7 +1494,8 @@ void IGXMLScanner::scanDocTypeDecl()
                             , srcUsed
                             , fCalculateSrcOfs
                         );
-
+                janSrc.reset(srcUsed);
+            }
             //  If it failed then throw an exception
             if (!reader)
                 ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Gen_CouldNotOpenDTD, srcUsed->getSystemId(), fMemoryManager);
diff --git a/src/xercesc/internal/IGXMLScanner.hpp b/src/xercesc/internal/IGXMLScanner.hpp
index 6bea074aabf20ec958aa4a9ee08d10d73c3afd38..308468554508200933692b3af911e7257ef8ed93 100644
--- a/src/xercesc/internal/IGXMLScanner.hpp
+++ b/src/xercesc/internal/IGXMLScanner.hpp
@@ -16,6 +16,9 @@
 
 /*
  * $Log$
+ * Revision 1.24  2004/12/03 19:40:30  cargilld
+ * Change call to resolveEntity to pass in public id so that only one call to resolveEntity is needed (a follow-on to Alberto's fix).
+ *
  * Revision 1.23  2004/09/08 13:56:13  peiyongz
  * Apache License Version 2.0
  *
@@ -189,7 +192,8 @@ private :
     virtual void scanDocTypeDecl();
     virtual void scanReset(const InputSource& src);
     virtual void sendCharData(XMLBuffer& toSend);
-    virtual InputSource* resolveSystemId(const XMLCh* const sysId);
+    virtual InputSource* resolveSystemId(const XMLCh* const sysId
+                                        ,const XMLCh* const pubId);
 
     // -----------------------------------------------------------------------
     //  Private helper methods
diff --git a/src/xercesc/internal/IGXMLScanner2.cpp b/src/xercesc/internal/IGXMLScanner2.cpp
index 74296dabafd773619a65a437faa6f99879f80507..e50e7dbf9038df64eac3f31ebd6238df8e40c7a9 100644
--- a/src/xercesc/internal/IGXMLScanner2.cpp
+++ b/src/xercesc/internal/IGXMLScanner2.cpp
@@ -1839,7 +1839,8 @@ void IGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con
         fModel = fGrammarResolver->getXSModel();
 }
 
-InputSource* IGXMLScanner::resolveSystemId(const XMLCh* const sysId)
+InputSource* IGXMLScanner::resolveSystemId(const XMLCh* const sysId
+                                          ,const XMLCh* const pubId)
 {
     //Normalize sysId 
     XMLBufBid nnSys(&fBufMgr);
@@ -1862,7 +1863,7 @@ InputSource* IGXMLScanner::resolveSystemId(const XMLCh* const sysId)
         ReaderMgr::LastExtEntityInfo lastInfo;
         fReaderMgr.getLastExtEntityInfo(lastInfo);
         XMLResourceIdentifier resourceIdentifier(XMLResourceIdentifier::ExternalEntity,
-                              expSysId.getRawBuffer(), 0, XMLUni::fgZeroLenString, lastInfo.systemId);
+                              expSysId.getRawBuffer(), 0, pubId, lastInfo.systemId);
         srcToFill = fEntityHandler->resolveEntity(&resourceIdentifier);
     }
     else
diff --git a/src/xercesc/internal/SGXMLScanner.cpp b/src/xercesc/internal/SGXMLScanner.cpp
index f7bea5c89111f2248ad4aaa6c86fabcf166cd5c1..0d7371cc7e974313b46f903b9dfe45016d8d6e30 100644
--- a/src/xercesc/internal/SGXMLScanner.cpp
+++ b/src/xercesc/internal/SGXMLScanner.cpp
@@ -3671,7 +3671,8 @@ void SGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con
         fModel = fGrammarResolver->getXSModel();
 }
 
-InputSource* SGXMLScanner::resolveSystemId(const XMLCh* const sysId)
+InputSource* SGXMLScanner::resolveSystemId(const XMLCh* const sysId
+                                          ,const XMLCh* const pubId)
 {
     //Normalize sysId 
     XMLBufBid nnSys(&fBufMgr);
@@ -3694,7 +3695,7 @@ InputSource* SGXMLScanner::resolveSystemId(const XMLCh* const sysId)
         ReaderMgr::LastExtEntityInfo lastInfo;
         fReaderMgr.getLastExtEntityInfo(lastInfo);
         XMLResourceIdentifier resourceIdentifier(XMLResourceIdentifier::ExternalEntity,
-                            expSysId.getRawBuffer(), 0, XMLUni::fgZeroLenString, lastInfo.systemId);
+                            expSysId.getRawBuffer(), 0, pubId, lastInfo.systemId);
         srcToFill = fEntityHandler->resolveEntity(&resourceIdentifier);
     }
     else
diff --git a/src/xercesc/internal/SGXMLScanner.hpp b/src/xercesc/internal/SGXMLScanner.hpp
index 5792c1bcc8af66a84a8f1a94247f2281cad7009e..2f9f8b11909dbf6b15d99660b9bb047a19e9e8bf 100644
--- a/src/xercesc/internal/SGXMLScanner.hpp
+++ b/src/xercesc/internal/SGXMLScanner.hpp
@@ -16,6 +16,9 @@
 
 /*
  * $Log$
+ * Revision 1.22  2004/12/03 19:40:30  cargilld
+ * Change call to resolveEntity to pass in public id so that only one call to resolveEntity is needed (a follow-on to Alberto's fix).
+ *
  * Revision 1.21  2004/09/27 21:04:38  knoaman
  * Update SGXMLScanner to allow access of data and methods to XSAXMLScanner
  *
@@ -280,7 +283,8 @@ private :
     );
     virtual void scanDocTypeDecl();
     virtual void sendCharData(XMLBuffer& toSend);
-    virtual InputSource* resolveSystemId(const XMLCh* const sysId);
+    virtual InputSource* resolveSystemId(const XMLCh* const sysId
+                                        ,const XMLCh* const pubId);
 
     // -----------------------------------------------------------------------
     //  Private helper methods
diff --git a/src/xercesc/internal/WFXMLScanner.cpp b/src/xercesc/internal/WFXMLScanner.cpp
index fc627c9f4bca14d618a50daae67f32af3beaa476..26402755e0e0d19b8d51a3c323d63f58e283986f 100644
--- a/src/xercesc/internal/WFXMLScanner.cpp
+++ b/src/xercesc/internal/WFXMLScanner.cpp
@@ -2053,7 +2053,8 @@ void WFXMLScanner::scanCharData(XMLBuffer& toUse)
     sendCharData(toUse);
 }
 
-InputSource* WFXMLScanner::resolveSystemId(const XMLCh* const)
+InputSource* WFXMLScanner::resolveSystemId(const XMLCh* const
+                                          ,const XMLCh* const pubId)
 {
     return 0;
 }
diff --git a/src/xercesc/internal/WFXMLScanner.hpp b/src/xercesc/internal/WFXMLScanner.hpp
index 66e85678eab5cf6d83df5cd1f20c2e66fa4fa267..f1ea5ab55ac687f333c73a49b27dac87d91f1c6f 100644
--- a/src/xercesc/internal/WFXMLScanner.hpp
+++ b/src/xercesc/internal/WFXMLScanner.hpp
@@ -16,6 +16,9 @@
 
 /*
  * $Log$
+ * Revision 1.12  2004/12/03 19:40:30  cargilld
+ * Change call to resolveEntity to pass in public id so that only one call to resolveEntity is needed (a follow-on to Alberto's fix).
+ *
  * Revision 1.11  2004/09/08 13:56:13  peiyongz
  * Apache License Version 2.0
  *
@@ -138,7 +141,8 @@ private :
     virtual void scanDocTypeDecl();
     virtual void scanReset(const InputSource& src);
     virtual void sendCharData(XMLBuffer& toSend);
-    virtual InputSource* resolveSystemId(const XMLCh* const sysId);
+    virtual InputSource* resolveSystemId(const XMLCh* const sysId
+                                        ,const XMLCh* const pubId);
 
     // -----------------------------------------------------------------------
     //  Private helper methods
diff --git a/src/xercesc/internal/XMLScanner.cpp b/src/xercesc/internal/XMLScanner.cpp
index 13d4980d7c778c86528a714c07dab1c36dd11386..b46f4387c9813a7e9c149ffc3396aecf9e494f3d 100644
--- a/src/xercesc/internal/XMLScanner.cpp
+++ b/src/xercesc/internal/XMLScanner.cpp
@@ -1745,14 +1745,16 @@ void XMLScanner::setURIStringPool(XMLStringPool* const stringPool)
  *   otherwise it is allowed.
  *
  ***/
-void XMLScanner::checkInternalDTD(bool hasExtSubset, const XMLCh* const sysId)
+void XMLScanner::checkInternalDTD(bool hasExtSubset
+                                 ,const XMLCh* const sysId
+                                 ,const XMLCh* const pubId)
 {
     if (fToCacheGrammar)
         ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Val_CantHaveIntSS, fMemoryManager);
 
     if (fUseCachedGrammar && hasExtSubset )
     {
-        InputSource* sysIdSrc = resolveSystemId(sysId);
+        InputSource* sysIdSrc = resolveSystemId(sysId, pubId);
         Janitor<InputSource> janSysIdSrc(sysIdSrc);
         Grammar* grammar = fGrammarResolver->getGrammar(sysIdSrc->getSystemId());
 
diff --git a/src/xercesc/internal/XMLScanner.hpp b/src/xercesc/internal/XMLScanner.hpp
index 3ab9230ec0b08cea14ab269297bf3065ae375044..51b5e3d9abcfa0b6dc9cc7bf2c378a14e8efd606 100644
--- a/src/xercesc/internal/XMLScanner.hpp
+++ b/src/xercesc/internal/XMLScanner.hpp
@@ -16,6 +16,9 @@
 
 /*
  * $Log$
+ * Revision 1.44  2004/12/03 19:40:30  cargilld
+ * Change call to resolveEntity to pass in public id so that only one call to resolveEntity is needed (a follow-on to Alberto's fix).
+ *
  * Revision 1.43  2004/10/12 21:33:05  peiyongz
  * Change attribute number threshold to 100
  *
@@ -728,7 +731,8 @@ protected:
     virtual void sendCharData(XMLBuffer& toSend) = 0;
 
     //return owned by the caller
-    virtual InputSource* resolveSystemId(const XMLCh* const sysId) {return 0;};
+    virtual InputSource* resolveSystemId(const XMLCh* const sysId
+                                        ,const XMLCh* const pubId) {return 0;};
 
     // -----------------------------------------------------------------------
     //  Protected scanning methods
@@ -744,7 +748,7 @@ protected:
     // -----------------------------------------------------------------------
     //  Private helper methods
     // -----------------------------------------------------------------------
-    void checkInternalDTD(bool hasExtSubset, const XMLCh* const sysId);
+    void checkInternalDTD(bool hasExtSubset, const XMLCh* const sysId, const XMLCh* const pubId);
     void checkIDRefs();
     bool isLegalToken(const XMLPScanToken& toCheck);
     XMLTokens senseNextToken(unsigned int& orgReader);
diff --git a/src/xercesc/util/XMLResourceIdentifier.hpp b/src/xercesc/util/XMLResourceIdentifier.hpp
index c4d09d09c0aec5b3818c68bdd30bdbbdf4644952..a86ca277ab5959b2565c6afd73bf10769b403a05 100644
--- a/src/xercesc/util/XMLResourceIdentifier.hpp
+++ b/src/xercesc/util/XMLResourceIdentifier.hpp
@@ -16,6 +16,9 @@
 
 /*
  * $Log$
+ * Revision 1.8  2004/12/03 19:40:32  cargilld
+ * Change call to resolveEntity to pass in public id so that only one call to resolveEntity is needed (a follow-on to Alberto's fix).
+ *
  * Revision 1.7  2004/09/26 01:06:31  cargilld
  * Fix documentation generation problem.  Replace <pre> with <code>.  Patch from James Littlejohn.
  *
@@ -210,10 +213,10 @@ inline XMLResourceIdentifier::XMLResourceIdentifier(const ResourceIdentifierType
                             , const XMLCh* const  publicId
                             , const XMLCh* const  baseURI )
     : fResourceIdentifierType(resourceIdentifierType)
-    , fPublicId(publicId)
     , fSystemId(systemId)
-    , fBaseURI(baseURI)
-    , fNameSpace(nameSpace)    
+    , fNameSpace(nameSpace)
+    , fPublicId(publicId)
+    , fBaseURI(baseURI)     
 {
 }