diff --git a/src/parsers/SAX2XMLReaderImpl.cpp b/src/parsers/SAX2XMLReaderImpl.cpp
index ddd7b9462597167f48cefd40deecaa0be3ecc4fa..a790181af54ca967b477a19aaf073cc61de9f97f 100644
--- a/src/parsers/SAX2XMLReaderImpl.cpp
+++ b/src/parsers/SAX2XMLReaderImpl.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.5  2000/12/22 15:16:51  tng
+ * SAX2-ext's LexicalHandler support added by David Bertoni.
+ *
  * Revision 1.4  2000/08/09 23:39:58  jpolast
  * should be namespace-prefixes; not namespaces-prefixes
  *
@@ -91,6 +94,7 @@
 #include <util/RefStackOf.hpp>
 #include <util/XMLUniDefs.hpp>
 #include <sax2/ContentHandler.hpp>
+#include <sax2/LexicalHandler.hpp>
 #include <sax/DTDHandler.hpp>
 #include <sax/ErrorHandler.hpp>
 #include <sax/EntityResolver.hpp>
@@ -188,6 +192,7 @@ SAX2XMLReaderImpl::SAX2XMLReaderImpl() :
     , fElemDepth(0)
     , fEntityResolver(0)
     , fErrorHandler(0)
+   , fLexicalHandler(0)
     , fAdvDHCount(0)
     , fAdvDHList(0)
     , fAdvDHListSize(32)
@@ -308,6 +313,12 @@ void SAX2XMLReaderImpl::setErrorHandler(ErrorHandler* const handler)
 }
 
 
+void SAX2XMLReaderImpl::setLexicalHandler(LexicalHandler* const handler)
+{
+    fLexicalHandler = handler;
+}
+
+
 void SAX2XMLReaderImpl::setEntityResolver(EntityResolver* const resolver)
 {
     fEntityResolver = resolver;
@@ -388,10 +399,18 @@ void SAX2XMLReaderImpl::docCharacters(  const   XMLCh* const    chars
     if (!fElemDepth)
         return;
 
+   // Call the installed LexicalHandler.
+   if (cdataSection && fLexicalHandler)
+        fLexicalHandler->startCDATA();
+
     // Just map to the SAX document handler
     if (fDocHandler)
         fDocHandler->characters(chars, length);
 
+   // Call the installed LexicalHandler.
+   if (cdataSection && fLexicalHandler)
+        fLexicalHandler->endCDATA();
+
     //
     //  If there are any installed advanced handlers, then lets call them
     //  with this info.
@@ -403,13 +422,21 @@ void SAX2XMLReaderImpl::docCharacters(  const   XMLCh* const    chars
 
 void SAX2XMLReaderImpl::docComment(const XMLCh* const commentText)
 {
+   // Call the installed LexicalHandler.
+   if (fLexicalHandler)
+   {
+        // SAX2 reports comment text like characters -- as an
+        // array with a length.
+        fLexicalHandler->comment(commentText, XMLString::stringLen(commentText));
+   }
+
     // Suppress passing through any comments before the root element.
     if (!fElemDepth)
         return;
 
     //
-    //  SAX has no way to report this. But, if there are any installed
-    //  advanced handlers, then lets call them with this info.
+    //  OK, if there are any installed advanced handlers,
+   // then let's call them with this info.
     //
     for (unsigned int index = 0; index < fAdvDHCount; index++)
         fAdvDHList[index]->docComment(commentText);
@@ -457,6 +484,10 @@ void SAX2XMLReaderImpl::endDocument()
 
 void SAX2XMLReaderImpl::endEntityReference(const XMLEntityDecl& entityDecl)
 {
+   // Call the installed LexicalHandler.
+   if (fLexicalHandler)
+        fLexicalHandler->endEntity(entityDecl.getName());
+
     //
     //  SAX has no way to report this event. But, if there are any installed
     //  advanced handlers, then lets call them with this info.
@@ -712,6 +743,9 @@ void SAX2XMLReaderImpl::endElement( const   XMLElementDecl& elemDecl
 
 void SAX2XMLReaderImpl::startEntityReference(const XMLEntityDecl& entityDecl)
 {
+   // Call the installed LexicalHandler.
+   if (fLexicalHandler)
+        fLexicalHandler->startEntity(entityDecl.getName());
     //
     //  SAX has no way to report this. But, If there are any installed
     //  advanced handlers, then lets call them with this info.
@@ -742,6 +776,10 @@ void SAX2XMLReaderImpl::doctypeDecl(const   DTDElementDecl& elemDecl
                             , const XMLCh* const    systemId
                             , const bool            hasIntSubset)
 {
+   // Call the installed LexicalHandler.
+   if (fLexicalHandler)
+        fLexicalHandler->startDTD(elemDecl.getFullName(), publicId, systemId);
+
     // Unused by SAX DTDHandler interface at this time
 }
 
@@ -780,6 +818,10 @@ void SAX2XMLReaderImpl::endIntSubset()
 
 void SAX2XMLReaderImpl::endExtSubset()
 {
+   // Call the installed LexicalHandler.
+   if (fLexicalHandler)
+        fLexicalHandler->endDTD();
+
     // Unused by SAX DTDHandler interface at this time
 }
 
diff --git a/src/parsers/SAX2XMLReaderImpl.hpp b/src/parsers/SAX2XMLReaderImpl.hpp
index 2c31e6b66e9cfcdadb2e9a84f8c07bd0b2164f99..42f1c995c9446f05c58cb61be761a854a75f1210 100644
--- a/src/parsers/SAX2XMLReaderImpl.hpp
+++ b/src/parsers/SAX2XMLReaderImpl.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.4  2000/12/22 15:16:53  tng
+ * SAX2-ext's LexicalHandler support added by David Bertoni.
+ *
  * Revision 1.3  2000/08/09 22:16:13  jpolast
  * many conformance & stability changes:
  *   - ContentHandler::resetDocument() removed
@@ -93,6 +96,7 @@
 #include <framework/XMLBufferMgr.hpp>
 
 class ContentHandler;
+class LexicalHandler;
 
 /**
   * This class implements the SAX2 'XMLReader' interface and should be
@@ -402,6 +406,13 @@ public :
       */
     virtual ErrorHandler* getErrorHandler() const ;
 
+    /**
+      * This method returns the installed lexical handler.
+      *
+      * @return A pointer to the installed lexical handler object.
+      */
+    virtual LexicalHandler* getLexicalHandler() const ;
+
     /** @name Implementation of SAX 2.0 interface's. */
     //@{
     /**
@@ -496,6 +507,24 @@ public :
     virtual void setErrorHandler(ErrorHandler* const handler) ;
 
 	/**
+    * Allow an application to register a lexical event handler.
+    *
+    * If the application does not register a lexical handler,
+    * all events reported by the SAX parser will be silently
+    * ignored. (this is the default behaviour implemented by HandlerBase).
+    *
+    * Applications may register a new or different handler in the
+    * middle of a parse, and the SAX parser must begin using the new
+    * handler immediately.
+    *
+    * @param handler The error handler.
+    * @see LexicalHandler#LexicalHandler
+    * @see SAXException#SAXException
+    * @see HandlerBase#HandlerBase
+    */
+    virtual void setLexicalHandler(LexicalHandler* const handler) ;
+
+   /**
 	  * This method sets a Feature as per the SAX2 spec (such as
 	  * do validation)
 	  *
@@ -996,6 +1025,7 @@ private :
     unsigned int               fElemDepth;
     EntityResolver*            fEntityResolver;
     ErrorHandler*              fErrorHandler;
+   LexicalHandler*            fLexicalHandler;
     unsigned int               fAdvDHCount;
     XMLDocumentHandler**       fAdvDHList;
     unsigned int               fAdvDHListSize;
@@ -1034,6 +1064,11 @@ inline ErrorHandler* SAX2XMLReaderImpl::getErrorHandler() const
 	return fErrorHandler;
 }
 
+inline LexicalHandler* SAX2XMLReaderImpl::getLexicalHandler() const
+{
+   return fLexicalHandler;
+}
+
 inline XMLValidator* SAX2XMLReaderImpl::getValidator() const
 {
 	return fValidator;
diff --git a/src/sax2/DefaultHandler.hpp b/src/sax2/DefaultHandler.hpp
index 240957680a82994ea2e8b0ef03827b4d1af6f646..f048c9bb3fb85a2f6b690ff5a846569e74d4ff38 100644
--- a/src/sax2/DefaultHandler.hpp
+++ b/src/sax2/DefaultHandler.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.4  2000/12/22 15:17:01  tng
+ * SAX2-ext's LexicalHandler support added by David Bertoni.
+ *
  * Revision 1.3  2000/08/14 18:56:14  aruna1
  * Virtual parameter inconsistency fixed
  *
@@ -75,6 +78,7 @@
 #define DEFAULTHANDLER_HPP
 
 #include <sax2/ContentHandler.hpp>
+#include <sax2/LexicalHandler.hpp>
 #include <sax/DTDHandler.hpp>
 #include <sax/EntityResolver.hpp>
 #include <sax/ErrorHandler.hpp>
@@ -108,7 +112,8 @@ class SAX2_EXPORT DefaultHandler :
     public EntityResolver, 
 	public DTDHandler, 
 	public ContentHandler, 
-	public ErrorHandler
+   public ErrorHandler,
+   public LexicalHandler
 {
 public:
   /** @name Default handlers for the DocumentHandler interface */
@@ -483,6 +488,108 @@ public:
         , const XMLCh* const    notationName
     );
     //@}
+
+
+    /** @name Default implementation of LexicalHandler interface. */
+
+    //@{
+   /**
+    * Receive notification of comments.
+    *
+    * <p>The Parser will call this method to report each occurence of
+    * a comment in the XML document.</p>
+    *
+    * <p>The application must not attempt to read from the array
+    * outside of the specified range.</p>
+    *
+    * @param chars The characters from the XML document.
+    * @param length The number of characters to read from the array.
+    * @exception SAXException Any SAX exception, possibly
+    *            wrapping another exception.
+    */
+    virtual void comment
+    (
+        const   XMLCh* const    chars
+        , const unsigned int    length
+    );
+
+  /**
+    * Receive notification of the end of a CDATA section.
+    *
+    * <p>The SAX parser will invoke this method at the end of
+    * each CDATA parsed.</p>
+    *
+    * @exception SAXException Any SAX exception, possibly
+    *            wrapping another exception.
+    */
+    virtual void endCDATA ();
+
+  /**
+    * Receive notification of the end of the DTD declarations.
+    *
+    * <p>The SAX parser will invoke this method at the end of the
+    * DTD</p>
+    *
+    * @exception SAXException Any SAX exception, possibly
+    *            wrapping another exception.
+    */
+    virtual void endDTD ();
+
+  /**
+    * Receive notification of the end of an entity.
+    *
+    * <p>The SAX parser will invoke this method at the end of an
+    * entity</p>
+    *
+    * @param name The name of the entity that is ending.
+    * @exception SAXException Any SAX exception, possibly
+    *            wrapping another exception.
+    */
+    virtual void endEntity (const XMLCh* const name);
+
+  /**
+    * Receive notification of the start of a CDATA section.
+    *
+    * <p>The SAX parser will invoke this method at the start of
+    * each CDATA parsed.</p>
+    *
+    * @exception SAXException Any SAX exception, possibly
+    *            wrapping another exception.
+    */
+    virtual void startCDATA ();
+
+  /**
+    * Receive notification of the start of the DTD declarations.
+    *
+    * <p>The SAX parser will invoke this method at the start of the
+    * DTD</p>
+    *
+    * @param name The document type name.
+    * @param publicId The declared public identifier for the external DTD subset, or null if none was declared.
+    * @param systemId The declared system identifier for the external DTD subset, or null if none was declared.
+    * @exception SAXException Any SAX exception, possibly
+    *            wrapping another exception.
+    */
+    virtual void startDTD
+    (
+        const   XMLCh* const    name
+        , const   XMLCh* const    publicId
+        , const   XMLCh* const    systemId
+    );
+
+  /**
+    * Receive notification of the start of an entity.
+    *
+    * <p>The SAX parser will invoke this method at the start of an
+    * entity</p>
+    *
+    * @param name The name of the entity that is starting.
+    * @exception SAXException Any SAX exception, possibly
+    *            wrapping another exception.
+    */
+    virtual void startEntity (const XMLCh* const name);
+
+    //@}
 };
 
 
@@ -592,4 +699,35 @@ inline void DefaultHandler::skippedEntity ( const	XMLCh* const	name )
 {
 }
 
+inline void DefaultHandler::comment(  const   XMLCh* const    chars
+                                       , const unsigned int    length)
+{
+}
+
+inline void DefaultHandler::endCDATA ()
+{
+}
+
+inline void DefaultHandler::endDTD ()
+{
+}
+
+inline void DefaultHandler::endEntity (const XMLCh* const name)
+{
+}
+
+inline void DefaultHandler::startCDATA ()
+{
+}
+
+inline void DefaultHandler::startDTD(  const   XMLCh* const    name
+                                        , const   XMLCh* const publicId
+                                        , const   XMLCh* const systemId)
+{
+}
+
+inline void DefaultHandler::startEntity (const XMLCh* const name)
+{
+}
+
 #endif // ! DEFAULTHANDLER_HPP
diff --git a/src/sax2/LexicalHandler.hpp b/src/sax2/LexicalHandler.hpp
new file mode 100644
index 0000000000000000000000000000000000000000..cc81151da91875474ff50ef9637db15a7188b981
--- /dev/null
+++ b/src/sax2/LexicalHandler.hpp
@@ -0,0 +1,213 @@
+/*
+ * 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. 
+ * 
+ * 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:  
+ *       "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 
+ *    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
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * 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
+ * Business Machines, Inc., http://www.ibm.com .  For more information
+ * on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/*
+ * $Log$
+ * Revision 1.1  2000/12/22 15:17:04  tng
+ * SAX2-ext's LexicalHandler support added by David Bertoni.
+ *
+ *
+ */
+
+
+#ifndef LEXICALHANDLER_HPP
+#define LEXICALHANDLER_HPP
+
+#include <util/XercesDefs.hpp>
+
+
+/**
+  * Receive notification of lexical events.
+  *
+  * <p>This is an extension handler for that provides lexical information
+  * about an XML document.  It does not provide information about document
+  * content.  For those events, an application must register an instance of
+  * a ContentHandler.</p>
+  *
+  * <p>The order of events in this interface is very important, and
+  * mirrors the order of information in the document itself.  For
+  * example, startDTD() and endDTD() events will occur before the
+  * first element in the document.</p>
+  *
+  * @see SAX2XMLReader#setLexicalHandler
+  * @see SAX2XMLReader#setContentHandler
+  */
+
+class SAX2_EXPORT LexicalHandler
+{
+public:
+    /** @name Constructors and Destructor */
+    //@{
+    /** Default constructor */
+    LexicalHandler()
+    {
+    }
+
+    /** Destructor */
+    virtual ~LexicalHandler()
+    {
+    }
+    //@}
+
+    /** @name The virtual document handler interface */
+    
+    //@{
+   /**
+    * Receive notification of comments.
+    *
+    * <p>The Parser will call this method to report each occurence of
+    * a comment in the XML document.</p>
+    *
+    * <p>The application must not attempt to read from the array
+    * outside of the specified range.</p>
+    *
+    * @param chars The characters from the XML document.
+    * @param length The number of characters to read from the array.
+    * @exception SAXException Any SAX exception, possibly
+    *            wrapping another exception.
+    */
+    virtual void comment
+    (
+        const   XMLCh* const    chars
+        , const unsigned int    length
+    ) = 0;
+
+  /**
+    * Receive notification of the end of a CDATA section.
+    *
+    * <p>The SAX parser will invoke this method at the end of
+    * each CDATA parsed.</p>
+    *
+    * @exception SAXException Any SAX exception, possibly
+    *            wrapping another exception.
+    */
+    virtual void endCDATA () = 0;
+
+  /**
+    * Receive notification of the end of the DTD declarations.
+    *
+    * <p>The SAX parser will invoke this method at the end of the
+    * DTD</p>
+    *
+    * @exception SAXException Any SAX exception, possibly
+    *            wrapping another exception.
+    */
+    virtual void endDTD () = 0;
+
+  /**
+    * Receive notification of the end of an entity.
+    *
+    * <p>The SAX parser will invoke this method at the end of an
+    * entity</p>
+    *
+    * @param name The name of the entity that is ending.
+    * @exception SAXException Any SAX exception, possibly
+    *            wrapping another exception.
+    */
+    virtual void endEntity (const XMLCh* const name) = 0;
+
+  /**
+    * Receive notification of the start of a CDATA section.
+    *
+    * <p>The SAX parser will invoke this method at the start of
+    * each CDATA parsed.</p>
+    *
+    * @exception SAXException Any SAX exception, possibly
+    *            wrapping another exception.
+    */
+    virtual void startCDATA () = 0;
+
+  /**
+    * Receive notification of the start of the DTD declarations.
+    *
+    * <p>The SAX parser will invoke this method at the start of the
+    * DTD</p>
+    *
+    * @param name The document type name.
+    * @param publicId The declared public identifier for the external DTD subset, or null if none was declared.
+    * @param systemId The declared system identifier for the external DTD subset, or null if none was declared.
+    * @exception SAXException Any SAX exception, possibly
+    *            wrapping another exception.
+    */
+    virtual void startDTD
+    (
+        const   XMLCh* const    name
+        , const   XMLCh* const    publicId
+        , const   XMLCh* const    systemId
+    ) = 0;
+
+  /**
+    * Receive notification of the start of an entity.
+    *
+    * <p>The SAX parser will invoke this method at the start of an
+    * entity</p>
+    *
+    * @param name The name of the entity that is starting.
+    * @exception SAXException Any SAX exception, possibly
+    *            wrapping another exception.
+    */
+    virtual void startEntity (const XMLCh* const name) = 0;
+
+    //@}
+private :
+    /* Unimplemented Constructors and operators */
+    /* Copy constructor */
+    LexicalHandler(const LexicalHandler&);
+    /** Assignment operator */
+    void operator=(const LexicalHandler&);
+};
+
+#endif
diff --git a/src/sax2/SAX2XMLReader.hpp b/src/sax2/SAX2XMLReader.hpp
index ae81eb1e8cdd3b898c8e10d4bff8bc7e70014182..c5312cf05be840f2f24d5a6c01aa89e6df81a434 100644
--- a/src/sax2/SAX2XMLReader.hpp
+++ b/src/sax2/SAX2XMLReader.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.4  2000/12/22 15:17:04  tng
+ * SAX2-ext's LexicalHandler support added by David Bertoni.
+ *
  * Revision 1.3  2000/08/09 22:19:29  jpolast
  * many conformance & stability changes:
  *   - ContentHandler::resetDocument() removed
@@ -92,6 +95,7 @@ class DTDHandler;
 class EntityResolver;
 class ErrorHandler;
 class InputSource;
+class LexicalHandler;
 
 class SAX2_EXPORT SAX2XMLReader
 {
@@ -153,6 +157,13 @@ public:
       */
     virtual ErrorHandler* getErrorHandler() const = 0 ;
 
+	/**
+      * This method returns the installed lexical handler.
+      *
+      * @return A pointer to the installed lexical handler object.
+      */
+    virtual LexicalHandler* getLexicalHandler() const = 0 ;
+
 	/**
 	  * This method gets a Feature as per the SAX2 spec (such as
       * do validation)
@@ -320,6 +331,24 @@ public:
     */
     virtual void setErrorHandler(ErrorHandler* const handler) = 0;
 
+   /**
+    * Allow an application to register a lexical event handler.
+    *
+    * If the application does not register a lexical handler,
+    * all events reported by the SAX parser will be silently
+    * ignored. (this is the default behaviour implemented by HandlerBase).
+    *
+    * Applications may register a new or different handler in the
+    * middle of a parse, and the SAX parser must begin using the new
+    * handler immediately.
+    *
+    * @param handler The error handler.
+    * @see LexicalHandler#LexicalHandler
+    * @see SAXException#SAXException
+    * @see HandlerBase#HandlerBase
+    */
+    virtual void setLexicalHandler(LexicalHandler* const handler) = 0;
+
   /**
 	* This method sets a Feature as per the SAX2 spec (such as
 	* do validation)