Hi All,

Can any one look into my issue below.
Please help.

With Best Regards
Gaurav Sharma

-----Original Message-----
From: Sharma, Gaurav [mailto:[email protected]] 
Sent: Wednesday, July 07, 2010 8:33 AM
To: [email protected]
Subject: How to use xerces exceptions

Hi All,

Can anyone tell the exact way of how an exception can be caught if any error 
occurs while parsing? I am using the code as follows:

   XercesDOMParser* parser = new XercesDOMParser(0, 
XMLPlatformUtils::fgMemoryManager, gp);
   parser->setDoNamespaces(OEF_TRUE);
   parser->setValidationScheme(XercesDOMParser::Val_Always);
   parser->setDoSchema(OEF_TRUE);
   parser->setValidationSchemaFullChecking(OEF_TRUE);
   parser->setIncludeIgnorableWhitespace(OEF_FALSE);
   parser->setCreateCommentNodes(OEF_FALSE);
   parser->cacheGrammarFromParse(OEF_TRUE);
   parser->useCachedGrammarInParse(OEF_TRUE);
   parser->setLoadSchema(OEF_FALSE);
   parser->setHandleMultipleImports(OEF_TRUE);
   try
   {
     parser->parse(xml_buffer);

   }
   catch(const OutOfMemoryException& e)
   {
      // Exception handling code
   }
   catch(const XMLException& e)
   {
      // Exception handling code
   }
   catch(const DOMException& e)
   {
      // Exception handling code
   }

My code is unable to catch any of the exception generated by parse function in 
try block while validating against an xsd. So what I do is use getErrorCount() 
function. But that is not the right way. Exception should be generated and 
caught in any of the catch block.

Kindly suggest me the right way using xerces exception handling. If possible 
pls provide some sample lines of code.

With Best Regards
Gaurav Sharma

The information contained in this electronic mail transmission 
may be privileged and confidential, and therefore, protected 
from disclosure. If you have received this communication in 
error, please notify us immediately by replying to this 
message and deleting it from your computer without copying 
or disclosing it.



The information contained in this electronic mail transmission 
may be privileged and confidential, and therefore, protected 
from disclosure. If you have received this communication in 
error, please notify us immediately by replying to this 
message and deleting it from your computer without copying 
or disclosing it.


Reply via email to