W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > October to December 2002

Re: Validating xml using a schema with domparser does not work

From: by way of <lane@mcs.anl.gov>
Date: Thu, 03 Oct 2002 06:23:45 -0600
Message-Id: <>
To: W3C XML Schema Comments list <www-xml-schema-comments@w3.org>


I was having this same problem and eventually figured something out that 
works.  I think what's going on is that validation *is* happening when the 
schema is found, but the errors are not being propegated to the program 
using the parser.  The way I solved this was to use the parser's 
setErrorHandler() method, and pass an intance of the ErrorHandler interface 
which relays the errors to my code:

DOMParser xmlParser = new DOMParser();
xmlParser.setFeature("http://xml.org/sax/features/validation", true);
xmlParser.setErrorHandler(new MyErrorHandler());


public class MyErrorHandler implements ErrorHandler {
   public void error(SAXParserException saxpe) {
      System.error.println(saxpe.getMessage()); //or whatever

This seems kind of silly, IMHO, but it works for me.

Received on Thursday, 3 October 2002 08:35:27 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:08:59 UTC