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 Steve Ichniowski <St...@campbell.com> on 2004/06/04 15:43:31 UTC

Catching Exceptions when parsing using DOM

When parsing xml files using DOM for which I have a schema, I am
noticing that if I intentionally

add an element that will cause the schema to yield an exception, that no
exception is caught.

 

I put the code in a try-block, also I call the setErrorHandler() method
for the parser

and set it to a valid error handler.

 

The error handler class does handle the error, but what about the
try-catch?  Why don't

exceptions get caught, namely when XMl is invalid for the assigned
schema?

 

I am setting validation to true for the parser, actually I am doing
exactly as a sample application.

 

Here all the exceptions I try to catch:

 

    catch (const XMLException& e)

  {

    char* errMsg = XMLString::transcode(e.getMessage());

  }

  catch (const DOMException& e)

  {

    char* errMsg = XMLString::transcode(e.msg);

  }

  catch (const SAXParseException& e)

  {

    char* errMsg = XMLString::transcode(e.getMessage());

  }

  catch (const Exception& e)

  {

    String s = e.Message;

  }

  catch (...)

  {

    int b = 5;

  }

 


______________________________________________________________________
Campbell & Company, Inc.:  The information in this e-mail may contain privileged/confidential information.  If you are not the intended recipient, you must not read, use, copy or disseminate the information or take any action in reliance thereupon.  If you have received this e-mail in error, please notify Campbell & Company, Inc. immediately by e-mail or telephone and delete the e-mail and any attachments from any computer.  The information in this e-mail does not constitute an offer to sell or the solicitation of an offer to buy any securities in any jurisdiction or for the benefit of any person.  
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________