Yep.  Here's the code I used to test:

int main(int argc, char* argv[])
{
  AwdSaxHandler *handler;
  std::ofstream *file = NULL;

  handler = new AwdSaxHandler();
  XMLPlatformUtils::Initialize();

  SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();

  parser->setContentHandler( handler );

  char *xml;
  if ( argc > 1 )
    xml = argv[1];
  else
    xml = "sample.xml";
  std::cout << "Starting parse of " << xml << std::endl << std::endl;
  try
  {
    parser->parse( xml );
  }
  catch ( SAXException &e )
  {
    std::cout << "Caught SAXException" << std::endl;
  }
  catch ( XMLException &e )
  {
    std::cout << "Caught XMLException" << std::endl;
  }
  std::cout << "End of parser of " << xml << std::endl;

  delete file;
  delete handler;

  return 0;
}

Also, my class, AwdSaxHandler, is derived from DefaultHandler. Here's the
declaration of my class:

#include <xercesc/sax2/DefaultHandler.hpp>

class AwdSaxHandler : public DefaultHandler
{
// Public methods
public:
  AwdSaxHandler(  );
  virtual ~AwdSaxHandler();

  void characters( const XMLCh *chars, const unsigned int length );
  void endCDATA();
  void endDocument();
  void endElement( const XMLCh * const uri,
                   const XMLCh * const localName,
                   const XMLCh * const qname );
  void setDocumentLocator( const Locator * const locator );
  void startDocument();
  void startElement( const XMLCh *uri,
                     const XMLCh *const localName,
                     const XMLCh *const qname,
                     const Attributes &attrs );
  void startCDATA();
};

Marc Robertson
Staff Consultant
AWD Development
DST Systems, Inc.


                                                                                       
                            
                    "Jeffrey                                                           
                            
                    Rodriguez"            To:     [EMAIL PROTECTED]          
                            
                    <jeffreyr_97@ho       cc:                                          
                            
                    tmail.com>            Subject:     Re: Problem with startElement 
and other SAX2 events         
                                                                                       
                            
                    11/02/2002                                                         
                            
                    09:46 PM                                                           
                            
                    Please respond                                                     
                            
                    to xerces-c-dev                                                    
                            
                                                                                       
                            
                                                                                       
                            




Hi Marc.

Did you register your handler?

e.g.

SAX2XMLReader *parser = XMLReaderFactory::createXMLReader();

          procsax  *handler = new AwdSaxHandler();

                parser->setContentHandler( handler );








>From: [EMAIL PROTECTED]
>Reply-To: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED]
>Subject: Problem with startElement and other SAX2 events
>Date: Fri, 1 Nov 2002 09:55:15 -0600
>
>Hi!
>
>I'm trying to write a SAX2 handler, and things aren't going as I expected.
>The startElement and characters methods of my class are not getting
called.
>I've stripped my handler down to the bare minimum( just writes to a log
>file as each method is entered ), and can't seem to figure out whats
>happening.  I've attached copies of my class, and the log I get when I use
>it.
>
>Any suggestions are greatly appreciated!
>
>Marc Robertson
>Staff Consultant
>AWD Development
>DST Systems, Inc.
>
>(See attached file: AwdSaxHandler.cpp)(See attached file:
>AwdSaxHandler.log)
><< AwdSaxHandler.cpp >>
><< AwdSaxHandler.log >>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to