Hi Yes that's what I did, though it's not directly the class Validator class that's directly involved. I used a SAXParser on which I set a custom DefaultHandler, like this :
SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); spf.setValidating(true); SAXParser sp = spf.newSAXParser(); sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); sp.setProperty(JAXP_SCHEMA_SOURCE, "file:" + xsdUri); sp.parse(xml, new MessageContentHandler(type)); Note : I've checked in the code of SaxParser ( http://kickjava.com/src/javax/xml/parsers/SAXParser.java.htm ) and it affects the HandlerBase as the ErrorHandler. Here is my custom class MessageContentHandler (part of it) : private class MessageContentHandler extends DefaultHandler { private String type; private int niveau = 0; private int numBalise = 0; public MessageContentHandler(String type) { super(); this.type = type; } public void warning(SAXParseException exception) throws SAXException { creerAlerte(exception.getLocalizedMessage(), type, getNumBalise()); } public void fatalError(SAXParseException exception) throws SAXException { creerAlerte(exception.getLocalizedMessage(), type, getNumBalise()); } public void error(SAXParseException exception) throws SAXException { creerAlerte(exception.getLocalizedMessage(), type, getNumBalise()); } (snip) Please note that the method "creerAlerte" doesn't throw any exception, it just registers the messages. Hoping that you have any hint... Regards, Guillaume 2010/5/21 Michael Glavassevich <mrgla...@ca.ibm.com> > Hi Guillaume, > > Which API are you using and did you register an error handler? > > The default error handler for a JAXP Validator is defined as: > > class DraconianErrorHandler implements ErrorHandler { > public void fatalError( SAXParseException e ) throws SAXException { > throw e; > } > public void error( SAXParseException e ) throws SAXException { > throw e; > } > public void warning( SAXParseException e ) throws SAXException { > // noop > } > } > > If you're using this API and didn't supply your own error handler, the > validator will always stop on the first error. > > Thanks. > > [1] > http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/validation/Validator.html#setErrorHandler(org.xml.sax.ErrorHandler)<http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/validation/Validator.html#setErrorHandler%28org.xml.sax.ErrorHandler%29> > > Michael Glavassevich > XML Parser Development > IBM Toronto Lab > E-mail: mrgla...@ca.ibm.com > E-mail: mrgla...@apache.org > > guillaume.desh...@gmail.com wrote on 05/21/2010 05:13:25 AM: > >