Hi, Mukul Thanks for your response, but I'm not looking for column and row numbers in the XML document. I might have been a little ambiguous in using the word "location". What I need is the reference to the Node object in the DOM tree that caused the validation error. The perfect solution would be for the SAXException to contain a reference to that Node.
I started looking at the source of org.apache.xerces.impl.xs.XMLSchemaValidator, and I see a method called processOneAttribute, which has all this info for attributes. There is also code that deals with Elements and also has the references to Nodes. I'm going to study this a little and see if I can do something with it. Alex ----- Original Message ---- From: Mukul Gandhi <[EMAIL PROTECTED]> To: j-users@xerces.apache.org Cc: Alex Talis <[EMAIL PROTECTED]> Sent: Sunday, October 26, 2008 8:36:26 PM Subject: Re: How to get exact location of schema validation errors? On Mon, Oct 27, 2008 at 7:07 AM, Alex Talis <[EMAIL PROTECTED]> wrote: > I'm using JAXP to validate a DOM Document with a Validator. When validation > fails, I get an exception with a pretty descriptive message, but no way to > pinpoint where in the document the error was found. You can set an error handler to a validator. for e.g., Validator validator = schema.newValidator(); MyErrorHandler errorHandler = new MyErrorHandler(); validator.setErrorHandler(errorHandler); validator.validate(new DOMSource ... Then in MyErrorHandler, you should write as, class MyErrorHandler implements ErrorHandler { public void fatalError(SAXParseException e) throws SAXException { } public void error(SAXParseException e) throws SAXException { } public void warning(SAXParseException e) throws SAXException { } within the methods, fatalError, error or warning, you can get location of the error/problem as, e.getLineNumber() e.getColumnNumber() -- Regards, Mukul Gandhi