Hi,

We are developing an module which reads data from XML File & we are using
SAX Parser for parsing.
Below is the pseudo code for the same:

      XMLReader xmlReader = XMLReaderFactory.createXMLReader(
"org.apache.xerces.parsers.SAXParser" );
      xmlReader = XMLReaderFactory.createXMLReader();
      SAXXMLHanlder handler = new SAXXMLHanlder();

      xmlReader.setContentHandler(handler);
      xmlReader.setFeature("http://xml.org/sax/features/validation",true);
      SAXXMLValidator errorHandler = new SAXXMLValidator();
      xmlReader.setErrorHandler(errorHandler);
      xmlReader.parse(...);

We also have SAXXMLValidator Class implementing ErrorHandler, which just
prints error messages to Logs.

The issue is, when the XML Document is malformed, errors are reported in
the logs and the execution proceeds ahead. There is no Exception thrown out
for any well-formedness error.

Is this the usual behavior? Or are we missing anything out, as we want the
processing to halt if XML is not well-formed.

Any ideas in this regards would be highly appreciated.

Thanks,
Khyati

Khyati Rana
Software Engineer
Zycus, Inc.
Spend Data Management Solutions
Save Whenever you Spend

Tel. - +91-22-56407676  Ext – 7625
Fax - +91-22-26850580
[EMAIL PROTECTED]

Your only obligation in any lifetime is to be true to " yourself ".  -
Richard Bach

~~~~~~~~~~~Disclaimer~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This e-mail contains confidential information and may be legally
privileged. It is intended solely for the addressee. Access to this email
by anyone else is unauthorized. If you are not the intended addressee,
please inform the sender immediately, delete the e-mail and do not copy,
disseminate, distribute, store, print or deliver this e-mail or information
therein to anybody. The sender and the Company are not liable for any
errors or omissions in this e-mail or for any claims, losses, damages
arising out of this e-mail and information contained therein.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to