OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] I am going crazy!!

[ Lists Home | Date Index | Thread Index ]

From: "Rajesh AVRS" <rajesh.ram@wipro.com>
> What would be the typical
> implementation of the error Handler class?  I am just throwing the
> SAXParseException in the 'error()' & 'fatalError()' methods like this:
>
>  public void error(SAXParseException saxe) throws SAXParseException
>  {
>   throw new SAXParseException(saxe.toString(), saxe.getPublicId(),
> saxe.getSystemId(), saxe.getLineNumber(), saxe.getColumnNumber());
>  }
>
> does it make any sense?  I am still trying to understand what I did :-))
>

Sure it makes sense.  If you want to terminate parsing as soon as you come
across a single validity error, then what you've coded will work okay.
Throwing a SAXParseException from one of the event handlers is the only way
to terminate a SAX parse.  The thrown exception will be propagated up to the
caller of XMLReader.parse(), where it can be reported to the user.

On the other hand, if you want to report all the validity errors in a
document, you cannot throw an exception from the error handler.  In this
case your ErrorHandler.error() method will typically do the following:-
- report the error (perhaps to System.err)
- update a flag to indicate the document is invalid

The "invalid" flag can then be tested by the code that calls
XMLReader.parse().

Hope this helps.
~Rob






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS