Just an important observation I discovered ...

When I use DOMSource as the XML document source, the error handler
methods fatalError, error and warning get the value -1 for,
getLineNumber() and getColumnNumber() for the SAXParseException
object. i.e., for DOMSource mechanism, retreiving line and column
numbers for the errors/warnings is not possible.

But I get the correct line numbers for errors/warnings if I use,
StreamSource as the XML document source.

So my below suggestion is wrong, for DOMSource. Sorry, it was not tested ...

On Mon, Oct 27, 2008 at 9:06 AM, Mukul Gandhi <[EMAIL PROTECTED]> wrote:
> 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