Yes , implement your own error handler like this, works fine for me

timo


/**
 *   MyErrorHandler implements the SAX
 *   ErrorHandler interface and defines callback
 *   behavior for the SAX callbacks associated with an XML
 *   document's errors.
 */
class MyErrorHandler implements org.xml.sax.ErrorHandler  {
//class MyErrorHandler extends DefaultHandler  {

    /** Reference to handlerFactory singleton */
    ParHandlerFactory handlerFactory;

    /**
     * <p>
     * This will report a warning that has occurred; this indicates
     *   that while no XML rules were "broken", something appears
     *   to be incorrect or missing.
     * </p>
     *
     * @param exception <code>SAXParseException</code> that occurred.
     * @throws <code>SAXException</code> when things go wrong
     */
    public void warning(SAXParseException exception)
        throws SAXException {

        String errorText = "Message\n" +
                           "  Line:    " +
                              exception.getLineNumber() + "\n" +
                           "  URI:     " +
                              exception.getSystemId() + "\n" +
                           "  Message: " +
                              exception.getMessage();
//
handlerFactory.displayErrorPlain(Defines.errorType.message,"xml_parsing_erro
r",errorText);
        //throw new SAXException("Warning encountered");
    }

    /**
     * <p>
     * This will report an error that has occurred; this indicates
     *   that a rule was broken, typically in validation, but that
     *   parsing can reasonably continue.
     * </p>
     *
     * @param exception <code>SAXParseException</code> that occurred.
     * @throws <code>SAXException</code> when things go wrong
     */
    public void error(SAXParseException exception)
        throws SAXException {

        String errorText = "Warning\n" +
                           "  Line:    " +
                              exception.getLineNumber() + "\n" +
                           "  URI:     " +
                              exception.getSystemId() + "\n" +
                           "  Message: " +
                              exception.getMessage();
//
handlerFactory.displayErrorPlain(Defines.errorType.warning,"xml_parsing_erro
r",errorText);
        //throw new SAXException("Error encountered");
    }

    /**
     * <p>
     * This will report a fatal error that has occurred; this indicates
     *   that a rule has been broken that makes continued parsing either
     *   impossible or an almost certain waste of time.
     * </p>
     *
     * @param exception <code>SAXParseException</code> that occurred.
     * @throws <code>SAXException</code> when things go wrong
     */
    public void fatalError(SAXParseException exception)
        throws SAXException {

        String errorText = "fatalError\n" +
                           "  Line:    " +
                              exception.getLineNumber() + "\n" +
                           "  URI:     " +
                              exception.getSystemId() + "\n" +
                           "  Message: " +
                              exception.getMessage();
 
_handlerFactory.displayErrorPlain(Defines.errorType.error,"xml_parsing_error
",errorText);
        //throw new SAXException("Fatal Error encountered");
    }

-----Urspr�ngliche Nachricht-----
Von: Per Lundkvist [mailto:[EMAIL PROTECTED]
Gesendet am: Freitag, 16. M�rz 2001 16:08
An: '[EMAIL PROTECTED]'
Betreff: RE: Validating a xml

You have to add your own ErrorHandler that takes care of the errors. It
seems that the default error handler just ignores all errors.

/per


> -----Original Message-----
> From: Mel Rod [SMTP:[EMAIL PROTECTED]
> Sent: Friday, March 16, 2001 2:54 PM
> To:   [EMAIL PROTECTED]
> Subject:      Validating a xml
> 
> 
> Hi,
> 
> I have an xml file and a dtd. I am trying to parse it using the
> validating parser. For some reason it does not throw any exceptions on non
> 
> conformace. I have set the validating feature to true.
> 
> Please advise.
> 
> Melroy
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to