I was able to get this very thing to work just yesterday.  If you're
extending the DefaultHandler, make sure your method signatures are exactly
the same.  Here is the handler class that I used with the SAX parser:
public class SAXErrorHandler extends DefaultHandler {

    public SAXErrorHandler() {
    }

    public void error(SAXParseException spe) {
        System.out.println("Error in file \"" + spe.getSystemId() + "\""
                + ", line #" + spe.getLineNumber() + ": " + spe.toString
());
    }

    public void warning(SAXParseException spe) {
        System.out.println("Warning in file \"" + spe.getSystemId() + "\""
                + ", line #" + spe.getLineNumber() + ": " + spe.toString
());
    }

    public void fatalError(SAXParseException spe) throws
org.xml.sax.SAXException {
        System.out.println("Fatal Error in file \"" + spe.getSystemId() + "
\""
                + ", line #" + spe.getLineNumber() + ": " + spe.toString
());
        throw new org.xml.sax.SAXException(spe);
    }
}

Matt


                                                                                
                              
                    callista                                                    
                              
                    <[EMAIL PROTECTED]        To:     [EMAIL PROTECTED]         
                        
                    ecity.com>           cc:                                    
                              
                                         Fax to:                                
                              
                    03/27/01             Subject:     When does a 
SAXParser/XMLParser notify and              
                    03:28 AM             error/warning/fatal error?             
                              
                    Please                                                      
                              
                    respond to                                                  
                              
                    xerces-j-user                                               
                              
                                                                                
                              
                                                                                
                              




This is kind of urgent.

I was wondering if anyone knows when a SAXParser or XMLParser notifies the
error/warning/fatalerror methods of the ErrorHandler. I thought that when
an xml page does not fulfill the syntax of a dtd it would generate an error
for example when an attribute defined as #REQUIRED but is not specified in
the xml. Somehow, my program can't seem to be able to catch this error.

How do I go about this? I need to make sure that everything that has been
defined as #REQUIRED in the dtd is infact specified in the xml being parsed
and throws an error if it's not.

Thanks.

Callista Chuah

---------------------------------------------------------------------
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