xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dwayne Schultz" <Dwa...@Schultz.net>
Subject RE: Required - example java code to demonstrate error reporting
Date Fri, 07 Apr 2000 05:47:59 GMT
> From: Jayne_Peachey@jba.co.uk [mailto:Jayne_Peachey@jba.co.uk]
> 
> Now that XML Schemas are replacing DTD's I've started use
> the Xerces Java Parser 1.0.3 but in my java class, when I parse my XML
> document (which has a schema associated in it),
> only syntactic errors are detected  by a SAXException being 
> thrown - such
> as a tag without an end tag - these can be detected in both 
> the XML Schema
> and the base XML,
> but I am unable to detect other errors such as an element that has
> minOccurs='2', but it is only occurs once.
> 

Did you register an error handler?

ErrorHandler errorHandler = new ErrorHandler() {
    public void fatalError(SAXParseException exception)
        throws SAXException {
        throw exception;
    }
    public void error(SAXParseException exception)
        throws SAXException {
        throw exception;
    }
    public void warning(SAXParseException exception)
        throws SAXException {
        exception.printStackTrace();
    }
};
parser.setErrorHandler(errorHandler);

Mime
View raw message