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

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to