On Sun, Aug 14, 2011 at 1:25 PM, Boris Kolpackov <[email protected]>
wrote:

Hi Bill,


Bill Moo <[email protected]> writes:

> First I guess it makes sense for me to ask the obvious question first. Is
> the Intel Compiler v12.0.1029.2010 on Windows 7 x64 supported?


There shouldn't be any issues as far as I know.


> I mean just that, no errors, no exceptions, nothing. I've got exception
> handling to cover all (known) occasions but I know by my console output
> that this method fails!


Xerces-C++ reports parsing/validation errors via an error handler, not
exceptions. If you haven't set an error handler, it will appear as if
the parser fails silently. To be sure, send a minimal but complete
test case that reproduces this problem.

Hi Boris, thanks for the reply, I am as far as I know using an error handler
set via the setErrorHandler method of the SAX2XMLParser instance. I'm using
Xerces in Qt so I've included the code in question:

bool bSuccess(false) ;
std::string xml("") ;
XMLPlatformUtils::Initialize() ;
qDebug() << "Parser: Reading File" ;
if (readFile(m_File, xml))
{
 qDebug() << "Parser: Read" << m_File.c_str() << "of size" << xml.size() ;
 try
 {
  qDebug() << "Parser: Init" ;
  MemBufInputSource buffer((const XMLByte *) xml.c_str(), xml.size(),
"empty", false) ;
  SAX2XMLReader * m_Parser = XMLReaderFactory::createXMLReader() ;
  m_Parser->setFeature(XMLUni::fgSAX2CoreValidation, false) ;
  m_Parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true) ;
  m_Parser->setFeature(XMLUni::fgXercesContinueAfterFatalError, true) ;
  qDebug() << "Parser: ErrorH" ;
  ParserEH * m_ErrorHandler = new ParserEH() ;
  if (m_ErrorHandler)
  {
   connect(m_ErrorHandler, SIGNAL(parserFail(const std::string&, const
std::string&)), this, SLOT(ParsingError(const std::string&, const
std::string&))) ;
   m_Parser->setErrorHandler(m_ErrorHandler);
  }
  qDebug() << "Parser: ContentH" ;
  SolutionCH * m_ContentHandler = new SolutionCH(m_Scenarios) ;
  if (m_ContentHandler)
  {
   connect(m_ContentHandler, SIGNAL(parserFail(const std::string&, const
std::string&)), this, SLOT(ParsingError(const std::string&, const
std::string&))) ;
   m_Parser->setContentHandler(m_ContentHandler) ;
  }
  if (m_Parser)
  {
   qDebug() << "Parser: Parsing" ;
   m_Parser->parse(buffer) ;
   qDebug() << "Parser: Reset UI" ;
   // Code removed
   bSuccess = true ;
  }
  else
  {
   qDebug() << "Init or Parser" ;
  }
  qDebug() << "Parser: Clean Up" ;
  delete m_ContentHandler ;
  delete m_ErrorHandler ;
  delete m_Parser ;
 }
 catch (const SAXParseException& e)
 {
  emit ParsingError(std::string("SXPE"), toNative(e.getMessage())) ;
 }
 catch (const SAXNotSupportedException & e)
 {
  emit ParsingError(std::string("SNSE"), toNative(e.getMessage())) ;
 }
 catch (const SAXNotRecognizedException & e)
 {
  emit ParsingError(std::string("SNRE"), toNative(e.getMessage())) ;
 }
 catch (const SAXException& e)
 {
  emit ParsingError(std::string("SAXE"), toNative(e.getMessage())) ;
 }
 catch (const XMLException& e)
 {
  emit ParsingError(std::string("XMLE"), toNative(e.getMessage())) ;
 }
 catch (const std::exception& e)
 {
    emit ParsingError(std::string("STDE"), e.what()) ;
 }
 catch (const std::runtime_error::exception& e)
 {
  emit ParsingError(std::string("SREE"), e.what()) ;
 }
 catch (...)
 {
  emit ParserError(std::string("Oops"), "Oh Bugger!") ;
 }
}
XMLPlatformUtils::Terminate() ;
qDebug() << "Parser: Done." ;

And this is my Error Handler :

ParserEH::ParserEH(QObject *parent) : QObject(parent), DefaultHandler()
    {

    }

    void ParserEH::warning(const SAXParseException &e)
    {
        emit parserFail(std::string("Warning"), toNative(e.getMessage())) ;
    }

    void ParserEH::error(const SAXParseException &e)
    {
        emit parserFail(std::string("Error"), toNative(e.getMessage())) ;
    }

    void ParserEH::fatalError(const SAXParseException &e)
    {
       emit parserFail(std::string("Fatal"), toNative(e.getMessage())) ;
    }

It is this line qDebug() << "Parser: Reset UI" ; I never see, when it fails
all I see is qDebug() << "Parser: Done." ;

This code 'works' as I see it as it parses the XML as expected and the
Content Handler creates classes which are handled in the missing code but
only 20% of the time.
Sometimes if I add then remove a character from the XML then save it (the
XML), it works, other times it just works, but not always, more often then
not it fails.

-- 
Bill

Reply via email to