OK, I have an object class definition for a server application
that contains:
//--------------------------------------------------------------------
XercesDOMParser* parser ;
DOMTreeErrorReporter* errReporter ;
//--------------------------------------------------------------------
When I instantiate/open the object, I do this:
//--------------------------------------------------------------------
this->parser = new XercesDOMParser;
this->parser->setDoNamespaces( true );
this->parser->setDoSchema( true );
this->parser->setValidationSchemaFullChecking( true );
this->parser->setValidationScheme( XercesDOMParser::Val_Auto );
this->parser->setCreateEntityReferenceNodes( false );
this->parser->setExternalNoNamespaceSchemaLocation
( /* path to schema file location*/ ) ;
this->errReporter = new DOMTreeErrorReporter();
this->parser->setErrorHandler(this->errReporter);
//--------------------------------------------------------------------
And then I have a method called "validate" that does this:
//--------------------------------------------------------------------
bool myStreamHandler::validate ( int size, const char* buffer )
{
bool rc = true ;
const char* foo = "label" ;
// the error reporter object gets destroyed,
// so it needs to be re-instantiated to reuse this parser
if ( !this->errReporter )
{ this->errReporter = new DOMTreeErrorReporter();
this->parser->setErrorHandler(this->errReporter);
}
// convert the ascii text buffer to a form the parser will accept
MemBufInputSource* memBufIS = new MemBufInputSource
( (const XMLByte*) buffer,
size,
foo,
false
) ;
// validate it
try
{
this->parser->parse( *memBufIS ) ;
if ( this->parser->getErrorCount() > 0 )
{ cerr
<< "Got "
<< this->parser->getErrorCount()
<< " errors"
<< endl ;
rc = false ;
}
}
catch ( const XMLException& e )
{
...
}
catch (const DOMException& e)
{
...
}
catch (...)
{
...
}
// cleanup
delete memBufIS ;
return rc ;
}
//--------------------------------------------------------------------
The problem is that I get occasional Segnentation Faults on either the
creation of the MemBufInputSource object "memBufIS" or when I try to
parse it a few lines later.
I am using Xerces-C 2.6.0
Am I doing this properly or is there a differrent/better way to do it ?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]