In my application when the parser found an error and call the error handler
a SIGSEGV occur.
Belowe I copy the piece of code which can cause the problem.
I'm new on using xerces-c so mybe I forget something.
Can someone help me ?
Regards, Enzo Arlati
[EMAIL PROTECTED]
XercesDOMParser * domParser;
DOMPrintErrorHandler * errReporter;
// -------------------------------------------------------
domParser = new XercesDOMParser;
domParser->setValidationScheme( XercesDOMParser::Val_Auto );
domParser->setDoNamespaces( false );
domParser->setDoSchema( false );
domParser->setValidationSchemaFullChecking( false );
domParser->setCreateEntityReferenceNodes( true );
errReporter = new DOMPrintErrorHandler();
domParser->setErrorHandler( (ErrorHandler*) errReporter );
string sfile( "/home/enzo/test1.xml" );
domParser->parse( sfile.c_str() );
where DOMPrintErrorHandler is defined as show belowe:
#ifndef DOMPRINTERRORHANDLER_H
#define DOMPRINTERRORHANDLER_H
#include <xercesc/dom/DOMErrorHandler.hpp>
XERCES_CPP_NAMESPACE_USE
class DOMPrintErrorHandler : public DOMErrorHandler
{
public:
DOMPrintErrorHandler();
~DOMPrintErrorHandler();
/** @name The error handler interface */
bool handleError(const DOMError& domError);
void resetErrors(){};
private :
/* Unimplemented constructors and operators */
DOMPrintErrorHandler(const DOMErrorHandler&);
void operator=(const DOMErrorHandler&);
};
#endif
====================================================
#include "domprinterrorhandler.h"
#include <xercesc/util/XMLString.hpp>
#include <xercesc/dom/DOMError.hpp>
#include <xercesc/dom/DOMLocator.hpp>
#include <xercesc/dom/DOMNode.hpp>
#include <iostream>
#include "ae_util.h"
DOMPrintErrorHandler::DOMPrintErrorHandler()
{
}
DOMPrintErrorHandler::~DOMPrintErrorHandler()
{
}
bool DOMPrintErrorHandler::handleError(const DOMError &domError)
{
string stmp;
char buffer[1024];
char buffer2[1024];
bool rc;
MYLOG( "----------------------------------------------------" );
switch( domError.getSeverity() )
{
case DOMError::DOM_SEVERITY_WARNING :
MYLOG( " [DOMPrintErrorHandler::handleError] warning " );
rc = true;
break;
case DOMError::DOM_SEVERITY_ERROR:
MYLOG( " [DOMPrintErrorHandler::handleError] error " );
rc = true;
break;
case DOMError::DOM_SEVERITY_FATAL_ERROR:
MYLOG( " [DOMPrintErrorHandler::handleError] fatal error" );
rc = false;
break;
default:
MYLOG( " [DOMPrintErrorHandler::handleError] unknown error " );
rc = false;
}
DOMLocator *pLocation = domError.getLocation();
stmp = ae_util::format_string( "[DOMPrintErrorHandler::handleError]
Location line=%d column=%d ooffset=%d",
pLocation->getLineNumber(),
pLocation->getColumnNumber(),
pLocation->getOffset());
MYLOG( stmp );
DOMNode *pDomNode = pLocation->getErrorNode();
XMLString::transcode(pDomNode->getNodeName(), buffer, 1023);
XMLString::transcode(pLocation->getURI(), buffer2, 1023);
stmp = ae_util::format_string( "[DOMPrintErrorHandler::handleError]
Nodo=%s URI=%s",
buffer, buffer2 );
MYLOG( stmp );
MYLOG( "----------------------------------------------------" );
return rc;
} // ____________ DOMPrintErrorHandler::handleError
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]