Hi Paul,

     Your xmlErrorHandler works for me.  If you're not seeing error
messages, et al., make sure that you've turned on the validation feature:

   parser.setFeature("http://xml.org/sax/features/validation";,
                     true);

I hope that helps.

Thanks,

Henry
------------------------------------------------------------------------
Henry Zongaro      XML Parsers development
IBM SWS Toronto Lab   Tie Line 778-6044;  Phone (416) 448-6044
mailto:[EMAIL PROTECTED]


"Paul Flanagan" <[EMAIL PROTECTED]> on 2001/04/09 12:40:33 PM

Please respond to [EMAIL PROTECTED]

To:   <[EMAIL PROTECTED]>
cc:
Subject:  Problem with Error Handling


Can any one tell me if declaring an error handler such as:

parser.setErrorHandler( new xmlErrorHandler() ) ;

    try
    {
      parser.parse( fn ) ;
    }
    catch( Exception e )
    {
      consoleOutput( e + ":  Exception invoking parser", 0 ) ;
    }

is all I have to do in order to see errors in an XML document when using
the DOM parser?   What else do I need to do in order to see the line number
etc that the error is on?  Class xmlErrorHandler is shown below.

Thanks in advance

Paul



import org.xml.sax.ErrorHandler ;
import org.xml.sax.SAXParseException ;

public class xmlErrorHandler implements ErrorHandler
{
  public void error( SAXParseException saxe )
  {
    showDetails( "ERROR: " , saxe ) ;
  }

  public void fatalError( SAXParseException saxe )
  {
    showDetails( "FATAL ERROR: " , saxe ) ;
  }

  public void warning( SAXParseException saxe )
  {
    showDetails( "WARNING: " , saxe ) ;
  }

  void showDetails( String s, SAXParseException e )
  {
    String output ;

    output = s + "[" + e.getLineNumber() + ":" + e.getColumnNumber() +"] "+
e.getPublicId() ;

    System.out.println( output ) ;
    System.out.println( "--> " + e.getMessage() ) ;
  }
}


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

Reply via email to