You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Da...@lotus.com on 2000/12/21 22:34:19 UTC
Patches to implement SAX2-ext LexicalHandler
Hi,
I have implemented SAX2-ext's LexicalHandler class in Xerces-C. The diffs
are attached. It would be great if someone could review the patches and
apply them. Xalan-C needs support for lexical information to be able to
use SAX2 for parsing.
Also, I have not received a reply to a previous email I posted about some
issues with the SAX2 implementation. Should I re-send the message?
Thanks!
Dave
This file is new and belongs in xml-xerces/c/src/sax2:
(See attached file: LexicalHandler.hpp)
Diffs:
cvs diff DefaultHandler.hpp (in directory V:\xml-xerces\c\src\sax2\)
Index: DefaultHandler.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/sax2/DefaultHandler.hpp,v
retrieving revision 1.3
diff -r1.3 DefaultHandler.hpp
77a78
> #include <sax2/LexicalHandler.hpp>
111c112,113
< public ErrorHandler
---
> public ErrorHandler,
> public LexicalHandler
485a488,589
>
>
> /** @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);
>
> //@}
591a696,726
> {
> }
>
> 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)
*****CVS exited normally with code 1*****
cvs diff SAX2XMLReader.hpp (in directory V:\xml-xerces\c\src\sax2\)
Index: SAX2XMLReader.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/sax2/SAX2XMLReader.hpp,v
retrieving revision 1.3
diff -r1.3 SAX2XMLReader.hpp
94a95
> class LexicalHandler;
155a157,163
> /**
> * This method returns the installed lexical handler.
> *
> * @return A pointer to the installed lexical handler object.
> */
> virtual LexicalHandler* getLexicalHandler() const = 0 ;
>
321a330,347
>
> /**
> * 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;
*****CVS exited normally with code 1*****
cvs diff SAX2XMLReaderImpl.cpp (in directory V:\xml-xerces\c\src\parsers\)
Index: SAX2XMLReaderImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/parsers/SAX2XMLReaderImpl.cpp,v
retrieving revision 1.4
diff -r1.4 SAX2XMLReaderImpl.cpp
93a94
> #include <sax2/LexicalHandler.hpp>
190a192
> , fLexicalHandler(0)
310a313,318
> void SAX2XMLReaderImpl::setLexicalHandler(LexicalHandler* const handler)
> {
> fLexicalHandler = handler;
> }
>
>
390a399,402
> // Call the installed LexicalHandler.
> if (cdataSection && fLexicalHandler)
> fLexicalHandler->startCDATA();
>
394a407,410
> // Call the installed LexicalHandler.
> if (cdataSection && fLexicalHandler)
> fLexicalHandler->endCDATA();
>
405a422,429
> // Call the installed LexicalHandler.
> if (fLexicalHandler)
> {
> // SAX2 reports comment text like characters -- as an
> // array with a length.
> fLexicalHandler->comment(commentText,
XMLString::stringLen(commentText));
> }
>
411,412c435,436
< // 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.
459a484,487
> // Call the installed LexicalHandler.
> if (fLexicalHandler)
> fLexicalHandler->endEntity(entityDecl.getName());
>
714a743,745
> // Call the installed LexicalHandler.
> if (fLexicalHandler)
> fLexicalHandler->startEntity(entityDecl.getName());
744a776,779
> // Call the installed LexicalHandler.
> if (fLexicalHandler)
> fLexicalHandler->startDTD(elemDecl.getFullName(), publicId,
systemId);
>
782a818,821
> // Call the installed LexicalHandler.
> if (fLexicalHandler)
> fLexicalHandler->endDTD();
>
*****CVS exited normally with code 1*****
cvs diff SAX2XMLReaderImpl.hpp (in directory V:\xml-xerces\c\src\parsers\)
Index: SAX2XMLReaderImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/parsers/SAX2XMLReaderImpl.hpp,v
retrieving revision 1.3
diff -r1.3 SAX2XMLReaderImpl.hpp
95a96
> class LexicalHandler;
404a406,412
> /**
> * This method returns the installed lexical handler.
> *
> * @return A pointer to the installed lexical handler object.
> */
> virtual LexicalHandler* getLexicalHandler() const ;
>
498a507,524
> * 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) ;
>
> /**
998a1025
> LexicalHandler* fLexicalHandler;
1034a1062,1066
> }
>
> inline LexicalHandler* SAX2XMLReaderImpl::getLexicalHandler() const
> {
> return fLexicalHandler;
*****CVS exited normally with code 1*****