From f1cb41ed17ed99f343b6ca650aa6cdc7db4bc119 Mon Sep 17 00:00:00 2001
From: Tinny Ng <tng@apache.org>
Date: Thu, 22 Aug 2002 19:29:13 +0000
Subject: [PATCH] [Bug 11448] DomCount has problems with XHTML1.1 DTD.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174167 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/framework/XMLEntityDecl.cpp   |  29 ++++---
 src/xercesc/framework/XMLEntityDecl.hpp   |  68 +++++++++++----
 src/xercesc/framework/XMLNotationDecl.cpp |  38 ++++----
 src/xercesc/framework/XMLNotationDecl.hpp |  49 ++++++++---
 src/xercesc/internal/ReaderMgr.cpp        | 101 ++++++++++++++++++++++
 src/xercesc/internal/ReaderMgr.hpp        |  14 +++
 src/xercesc/internal/XMLScanner2.cpp      |   5 +-
 src/xercesc/validators/DTD/DTDScanner.cpp |  19 +++-
 8 files changed, 259 insertions(+), 64 deletions(-)

diff --git a/src/xercesc/framework/XMLEntityDecl.cpp b/src/xercesc/framework/XMLEntityDecl.cpp
index 872fdba2a..162999547 100644
--- a/src/xercesc/framework/XMLEntityDecl.cpp
+++ b/src/xercesc/framework/XMLEntityDecl.cpp
@@ -1,37 +1,37 @@
 /*
  * The Apache Software License, Version 1.1
- * 
+ *
  * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
  * reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- * 
+ *    notice, this list of conditions and the following disclaimer.
+ *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
- * 
+ *
  * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
+ *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
- * 
+ *
  * 4. The names "Xerces" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
+ *    software without prior written permission. For written
  *    permission, please contact apache\@apache.org.
- * 
+ *
  * 5. Products derived from this software may not be called "Apache",
  *    nor may "Apache" appear in their name, without prior written
  *    permission of the Apache Software Foundation.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -45,7 +45,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
- * 
+ *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation, and was
  * originally based on software copyright (c) 1999, International
@@ -77,6 +77,7 @@ XMLEntityDecl::XMLEntityDecl() :
     , fNotationName(0)
     , fPublicId(0)
     , fSystemId(0)
+    , fBaseURI(0)
     , fValue(0)
     , fValueLen(0)
 {
@@ -88,6 +89,7 @@ XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName) :
     , fNotationName(0)
     , fPublicId(0)
     , fSystemId(0)
+    , fBaseURI(0)
     , fValue(0)
     , fValueLen(0)
 {
@@ -100,6 +102,7 @@ XMLEntityDecl::XMLEntityDecl(const  XMLCh* const    entName
     , fNotationName(0)
     , fPublicId(0)
     , fSystemId(0)
+    , fBaseURI(0)
     , fValue(0)
     , fValueLen(0)
 {
@@ -122,6 +125,7 @@ XMLEntityDecl::XMLEntityDecl(const  XMLCh* const    entName
     , fNotationName(0)
     , fPublicId(0)
     , fSystemId(0)
+    , fBaseURI(0)
     , fValue(0)
     , fValueLen(0)
 {
@@ -168,4 +172,5 @@ void XMLEntityDecl::cleanUp()
     delete [] fValue;
     delete [] fPublicId;
     delete [] fSystemId;
+    delete [] fBaseURI;
 }
diff --git a/src/xercesc/framework/XMLEntityDecl.hpp b/src/xercesc/framework/XMLEntityDecl.hpp
index cc3e0dcdc..ed87aaff3 100644
--- a/src/xercesc/framework/XMLEntityDecl.hpp
+++ b/src/xercesc/framework/XMLEntityDecl.hpp
@@ -1,37 +1,37 @@
 /*
  * The Apache Software License, Version 1.1
- * 
+ *
  * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
  * reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- * 
+ *    notice, this list of conditions and the following disclaimer.
+ *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
- * 
+ *
  * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
+ *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
- * 
+ *
  * 4. The names "Xerces" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
+ *    software without prior written permission. For written
  *    permission, please contact apache\@apache.org.
- * 
+ *
  * 5. Products derived from this software may not be called "Apache",
  *    nor may "Apache" appear in their name, without prior written
  *    permission of the Apache Software Foundation.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -45,7 +45,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
- * 
+ *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation, and was
  * originally based on software copyright (c) 1999, International
@@ -56,8 +56,11 @@
 
 /*
  * $Log$
- * Revision 1.1  2002/02/01 22:21:51  peiyongz
- * Initial revision
+ * Revision 1.2  2002/08/22 19:27:41  tng
+ * [Bug 11448] DomCount has problems with XHTML1.1 DTD.
+ *
+ * Revision 1.1.1.1  2002/02/01 22:21:51  peiyongz
+ * sane_include
  *
  * Revision 1.6  2000/02/24 20:00:23  abagchi
  * Swat for removing Log from API docs
@@ -114,7 +117,7 @@ public:
 
     /** @name Constructors */
     //@{
-    
+
     /**
       *  Deafult Constructor
       */
@@ -128,7 +131,7 @@ public:
     (
         const   XMLCh* const    entName
     );
-    
+
     /**
       * Constructor with a const entity name and value
       *
@@ -175,7 +178,7 @@ public:
     /** Get the 'declared in internal subset' flag
       *
       * Gets the state of the flag which indicates whether the entity was
-      * declared in the internal or external subset. Some structural 
+      * declared in the internal or external subset. Some structural
       * description languages might not have an internal subset concept, in
       * which case this will always return false.
       */
@@ -206,7 +209,7 @@ public:
     //@{
 
     /**
-      * Gets the pool id of this entity. Validators maintain all decls in 
+      * Gets the pool id of this entity. Validators maintain all decls in
       * pools, from which they can be quickly extracted via id.
       */
     unsigned int getId() const;
@@ -236,6 +239,11 @@ public:
       */
     const XMLCh* getSystemId() const;
 
+    /**
+      * Gets the base URI for this entity.
+      */
+    const XMLCh* getBaseURI() const;
+
     /**
       * This method returns the value of an internal entity. If this is not
       * an internal entity (i.e. its external), then this will be a null
@@ -313,6 +321,14 @@ public:
      */
     void setSystemId(const XMLCh* const newId);
 
+    /**
+     *  This method will set a new baseURI on this entity. This will
+     *  then control the URI used to resolve the relative system Id.
+     *
+     *  @param  newId     The new base URI to give to the entity.
+     */
+    void setBaseURI(const XMLCh* const newId);
+
     /**
      *  This method will set a new value for this entity. This is only
      *  valid if the entity is to be an internal entity. By setting this
@@ -383,6 +399,10 @@ private :
     //  fValueLen
     //      The entity's value and length, which is only valid if its an
     //      internal style entity.
+    //
+    //  fBaseURI
+    //      The base URI of the entity.   According to XML InfoSet, such value
+    //      is the URI where it is declared (NOT referenced).
     // -----------------------------------------------------------------------
     unsigned int    fId;
 	XMLCh*          fName;
@@ -391,6 +411,7 @@ private :
     XMLCh*          fSystemId;
     XMLCh*          fValue;
     unsigned int    fValueLen;
+    XMLCh*          fBaseURI;
 };
 
 
@@ -422,6 +443,11 @@ inline const XMLCh* XMLEntityDecl::getSystemId() const
     return fSystemId;
 }
 
+inline const XMLCh* XMLEntityDecl::getBaseURI() const
+{
+    return fBaseURI;
+}
+
 inline const XMLCh* XMLEntityDecl::getValue() const
 {
     return fValue;
@@ -471,6 +497,12 @@ inline void XMLEntityDecl::setSystemId(const XMLCh* const newId)
     fSystemId = XMLString::replicate(newId);
 }
 
+inline void XMLEntityDecl::setBaseURI(const XMLCh* const newId)
+{
+    delete [] fBaseURI;
+    fBaseURI = XMLString::replicate(newId);
+}
+
 inline void XMLEntityDecl::setValue(const XMLCh* const newValue)
 {
     delete [] fValue;
diff --git a/src/xercesc/framework/XMLNotationDecl.cpp b/src/xercesc/framework/XMLNotationDecl.cpp
index fccf55b33..9654867c4 100644
--- a/src/xercesc/framework/XMLNotationDecl.cpp
+++ b/src/xercesc/framework/XMLNotationDecl.cpp
@@ -1,37 +1,37 @@
 /*
  * The Apache Software License, Version 1.1
- * 
+ *
  * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
  * reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- * 
+ *    notice, this list of conditions and the following disclaimer.
+ *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
- * 
+ *
  * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
+ *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
- * 
+ *
  * 4. The names "Xerces" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
+ *    software without prior written permission. For written
  *    permission, please contact apache\@apache.org.
- * 
+ *
  * 5. Products derived from this software may not be called "Apache",
  *    nor may "Apache" appear in their name, without prior written
  *    permission of the Apache Software Foundation.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -45,7 +45,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
- * 
+ *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation, and was
  * originally based on software copyright (c) 1999, International
@@ -56,8 +56,11 @@
 
 /**
  * $Log$
- * Revision 1.1  2002/02/01 22:21:52  peiyongz
- * Initial revision
+ * Revision 1.2  2002/08/22 19:27:41  tng
+ * [Bug 11448] DomCount has problems with XHTML1.1 DTD.
+ *
+ * Revision 1.1.1.1  2002/02/01 22:21:52  peiyongz
+ * sane_include
  *
  * Revision 1.2  2000/02/06 07:47:48  rahulj
  * Year 2K copyright swat.
@@ -85,20 +88,24 @@ XMLNotationDecl::XMLNotationDecl() :
     fName(0)
     , fPublicId(0)
     , fSystemId(0)
+    , fBaseURI(0)
 {
 }
 
 XMLNotationDecl::XMLNotationDecl(   const   XMLCh* const    notName
                                     , const XMLCh* const    pubId
-                                    , const XMLCh* const    sysId) :
+                                    , const XMLCh* const    sysId
+                                    , const XMLCh* const    baseURI) :
     fName(0)
     , fPublicId(0)
     , fSystemId(0)
+    , fBaseURI(0)
 {
     try
     {
         fPublicId = XMLString::replicate(pubId);
         fSystemId = XMLString::replicate(sysId);
+        fBaseURI  = XMLString::replicate(baseURI);
         setName(notName);
     }
 
@@ -135,4 +142,5 @@ void XMLNotationDecl::cleanUp()
     delete [] fName;
     delete [] fPublicId;
     delete [] fSystemId;
+    delete [] fBaseURI;
 }
diff --git a/src/xercesc/framework/XMLNotationDecl.hpp b/src/xercesc/framework/XMLNotationDecl.hpp
index 7aff2852d..653307925 100644
--- a/src/xercesc/framework/XMLNotationDecl.hpp
+++ b/src/xercesc/framework/XMLNotationDecl.hpp
@@ -1,37 +1,37 @@
 /*
  * The Apache Software License, Version 1.1
- * 
+ *
  * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
  * reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- * 
+ *    notice, this list of conditions and the following disclaimer.
+ *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
- * 
+ *
  * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
+ *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
- * 
+ *
  * 4. The names "Xerces" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
+ *    software without prior written permission. For written
  *    permission, please contact apache\@apache.org.
- * 
+ *
  * 5. Products derived from this software may not be called "Apache",
  *    nor may "Apache" appear in their name, without prior written
  *    permission of the Apache Software Foundation.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -45,7 +45,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
- * 
+ *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation, and was
  * originally based on software copyright (c) 1999, International
@@ -56,8 +56,11 @@
 
 /*
  * $Log$
- * Revision 1.1  2002/02/01 22:21:52  peiyongz
- * Initial revision
+ * Revision 1.2  2002/08/22 19:27:41  tng
+ * [Bug 11448] DomCount has problems with XHTML1.1 DTD.
+ *
+ * Revision 1.1.1.1  2002/02/01 22:21:52  peiyongz
+ * sane_include
  *
  * Revision 1.5  2000/03/02 19:54:25  roddey
  * This checkin includes many changes done while waiting for the
@@ -111,6 +114,7 @@ public:
         const   XMLCh* const    notName
         , const XMLCh* const    pubId
         , const XMLCh* const    sysId
+        , const XMLCh* const    baseURI = 0
     );
     //@}
 
@@ -127,6 +131,7 @@ public:
     const XMLCh* getName() const;
     const XMLCh* getPublicId() const;
     const XMLCh* getSystemId() const;
+    const XMLCh* getBaseURI() const;
 
 
     // -----------------------------------------------------------------------
@@ -139,6 +144,7 @@ public:
     );
     void setPublicId(const XMLCh* const newId);
     void setSystemId(const XMLCh* const newId);
+    void setBaseURI(const XMLCh* const newId);
 
 
     // -----------------------------------------------------------------------
@@ -176,11 +182,15 @@ private :
     //
     //  fSystemId
     //      The text of the notation's system id, if any.
+    //
+    //  fBaseURI
+    //      The text of the notation's base URI
     // -----------------------------------------------------------------------
     unsigned int    fId;
 	XMLCh*          fName;
     XMLCh*          fPublicId;
     XMLCh*          fSystemId;
+    XMLCh*          fBaseURI;
 };
 
 
@@ -207,6 +217,11 @@ inline const XMLCh* XMLNotationDecl::getSystemId() const
     return fSystemId;
 }
 
+inline const XMLCh* XMLNotationDecl::getBaseURI() const
+{
+    return fBaseURI;
+}
+
 
 // -----------------------------------------------------------------------
 //  Setter methods
@@ -228,6 +243,12 @@ inline void XMLNotationDecl::setSystemId(const XMLCh* const newId)
     fSystemId = XMLString::replicate(newId);
 }
 
+inline void XMLNotationDecl::setBaseURI(const XMLCh* const newId)
+{
+    delete [] fBaseURI;
+    fBaseURI = XMLString::replicate(newId);
+}
+
 
 // ---------------------------------------------------------------------------
 //  XMLNotationDecl: Support named pool element semantics
diff --git a/src/xercesc/internal/ReaderMgr.cpp b/src/xercesc/internal/ReaderMgr.cpp
index 454b12010..0ff4f1122 100644
--- a/src/xercesc/internal/ReaderMgr.cpp
+++ b/src/xercesc/internal/ReaderMgr.cpp
@@ -578,6 +578,107 @@ XMLReader* ReaderMgr::createReader( const   XMLCh* const        sysId
 }
 
 
+XMLReader* ReaderMgr::createReader( const   XMLCh* const        baseURI
+                                    , const XMLCh* const        sysId
+                                    , const XMLCh* const        pubId
+                                    , const bool                xmlDecl
+                                    , const XMLReader::RefFrom  refFrom
+                                    , const XMLReader::Types    type
+                                    , const XMLReader::Sources  source
+                                    ,       InputSource*&       srcToFill)
+{
+    // Create a buffer for expanding the system id
+    XMLBuffer expSysId;
+
+    //
+    //  Allow the entity handler to expand the system id if they choose
+    //  to do so.
+    //
+    if (fEntityHandler)
+    {
+        if (!fEntityHandler->expandSystemId(sysId, expSysId))
+            expSysId.set(sysId);
+    }
+     else
+    {
+        expSysId.set(sysId);
+    }
+
+    // Call the entity resolver interface to get an input source
+    srcToFill = 0;
+    if (fEntityHandler)
+    {
+        srcToFill = fEntityHandler->resolveEntity
+        (
+            pubId
+            , expSysId.getRawBuffer()
+        );
+    }
+
+    //
+    //  If they didn't create a source via the entity resolver, then we
+    //  have to create one on our own.
+    //
+    if (!srcToFill)
+    {
+        LastExtEntityInfo lastInfo;
+        getLastExtEntityInfo(lastInfo);
+
+        try
+        {
+            XMLURL urlTmp((!baseURI || !*baseURI) ? lastInfo.systemId : baseURI, expSysId.getRawBuffer());
+
+            if (urlTmp.isRelative())
+            {
+                ThrowXML
+                (
+                    MalformedURLException
+                    , XMLExcepts::URL_NoProtocolPresent
+                );
+            }
+            srcToFill = new URLInputSource(urlTmp);
+        }
+
+        catch(const MalformedURLException&)
+        {
+            // Its not a URL, so lets assume its a local file name.
+            srcToFill = new LocalFileInputSource
+            (
+                lastInfo.systemId
+                , expSysId.getRawBuffer()
+            );
+        }
+    }
+
+    // Put a janitor on the input source
+    Janitor<InputSource> janSrc(srcToFill);
+
+    //
+    //  Now call the other version with the input source that we have, and
+    //  return the resulting reader.
+    //
+    XMLReader* retVal = createReader
+    (
+        *srcToFill
+        , xmlDecl
+        , refFrom
+        , type
+        , source
+    );
+
+    // Either way, we can release the input source now
+    janSrc.orphan();
+
+    // If it failed for any reason, then return zero.
+    if (!retVal)
+        return 0;
+
+    // Give this reader the next available reader number and return it
+    retVal->setReaderNum(fNextReaderNum++);
+    return retVal;
+}
+
+
 XMLReader*
 ReaderMgr::createIntEntReader(  const   XMLCh* const        sysId
                                 , const XMLReader::RefFrom  refFrom
diff --git a/src/xercesc/internal/ReaderMgr.hpp b/src/xercesc/internal/ReaderMgr.hpp
index 1d0753533..2ea7154ae 100644
--- a/src/xercesc/internal/ReaderMgr.hpp
+++ b/src/xercesc/internal/ReaderMgr.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.3  2002/08/22 19:28:11  tng
+ * [Bug 11448] DomCount has problems with XHTML1.1 DTD.
+ *
  * Revision 1.2  2002/05/27 18:42:14  tng
  * To get ready for 64 bit large file, use XMLSSize_t to represent line and column number.
  *
@@ -221,6 +224,17 @@ public :
         , const XMLReader::Sources  source
         ,       InputSource*&       srcToFill
     );
+    XMLReader* createReader
+    (
+        const   XMLCh* const        baseURI
+        , const XMLCh* const        sysId
+        , const XMLCh* const        pubId
+        , const bool                xmlDecl
+        , const XMLReader::RefFrom  refFrom
+        , const XMLReader::Types    type
+        , const XMLReader::Sources  source
+        ,       InputSource*&       srcToFill
+    );
     XMLReader* createIntEntReader
     (
         const   XMLCh* const        sysId
diff --git a/src/xercesc/internal/XMLScanner2.cpp b/src/xercesc/internal/XMLScanner2.cpp
index 2fb2d3b70..6e7810891 100644
--- a/src/xercesc/internal/XMLScanner2.cpp
+++ b/src/xercesc/internal/XMLScanner2.cpp
@@ -925,7 +925,7 @@ void XMLScanner::scanReset(const InputSource& src)
         fValidator = fDTDValidator;
         fValidator->setGrammar(fGrammar);
     }
- 
+
     if (fValScheme == Val_Auto) {
         fValidate = false;
     }
@@ -2920,7 +2920,8 @@ XMLScanner::scanEntityRef(  const   bool    inAttVal
         InputSource* srcUsed;
         XMLReader* reader = fReaderMgr.createReader
         (
-            decl->getSystemId()
+            decl->getBaseURI()
+            , decl->getSystemId()
             , decl->getPublicId()
             , false
             , XMLReader::RefFrom_NonLiteral
diff --git a/src/xercesc/validators/DTD/DTDScanner.cpp b/src/xercesc/validators/DTD/DTDScanner.cpp
index 4c599562a..d53c6bd77 100644
--- a/src/xercesc/validators/DTD/DTDScanner.cpp
+++ b/src/xercesc/validators/DTD/DTDScanner.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.10  2002/08/22 19:29:13  tng
+ * [Bug 11448] DomCount has problems with XHTML1.1 DTD.
+ *
  * Revision 1.9  2002/08/19 14:40:31  tng
  * Fix: public id / system id in entity decl should be null if empty
  *
@@ -360,7 +363,8 @@ bool DTDScanner::expandPERef( const   bool    scanExternal
         InputSource* srcUsed;
         XMLReader* reader = fReaderMgr->createReader
         (
-            decl->getSystemId()
+            decl->getBaseURI()
+            , decl->getSystemId()
             , decl->getPublicId()
             , false
             , inLiteral ? XMLReader::RefFrom_Literal : XMLReader::RefFrom_NonLiteral
@@ -1989,7 +1993,8 @@ DTDScanner::scanEntityRef(XMLCh& firstCh, XMLCh& secondCh, bool& escaped)
         InputSource* srcUsed;
         XMLReader* reader = fReaderMgr->createReader
         (
-            decl->getSystemId()
+            decl->getBaseURI()
+            , decl->getSystemId()
             , decl->getPublicId()
             , false
             , XMLReader::RefFrom_NonLiteral
@@ -2264,11 +2269,15 @@ bool DTDScanner::scanEntityDef(DTDEntityDecl& decl, const bool isPEDecl)
     if (!scanId(bbPubId.getBuffer(), bbSysId.getBuffer(), IDType_External))
         return false;
 
+    ReaderMgr::LastExtEntityInfo lastInfo;
+    fReaderMgr->getLastExtEntityInfo(lastInfo);
+
     // Fill in the id fields of the decl with the info we got
     const XMLCh* publicId = bbPubId.getRawBuffer();
-    const XMLCh* systemId = bbSysId.getRawBuffer();        
+    const XMLCh* systemId = bbSysId.getRawBuffer();
     decl.setPublicId((*publicId) ? publicId : 0);
     decl.setSystemId((*systemId) ? systemId : 0);
+    decl.setBaseURI((*lastInfo.systemId) ? lastInfo.systemId : 0);
 
     // If its a PE decl, we are done
     bool gotSpaces = checkForPERef(false, false, true);
@@ -3339,11 +3348,15 @@ void DTDScanner::scanNotationDecl()
         // Fill in a new notation declaration and add it to the pool
         const XMLCh* publicId = bbPubId.getRawBuffer();
         const XMLCh* systemId = bbSysId.getRawBuffer();
+        ReaderMgr::LastExtEntityInfo lastInfo;
+        fReaderMgr->getLastExtEntityInfo(lastInfo);
+
         decl = new XMLNotationDecl
         (
             bbName.getRawBuffer()
             , (*publicId) ? publicId : 0
             , (*systemId) ? systemId : 0
+            , (*lastInfo.systemId) ? lastInfo.systemId : 0
         );
         fDTDGrammar->putNotationDecl(decl);
     }
-- 
GitLab