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() ) ;
  }
}

Reply via email to