[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: I am going crazy!!


xmlreader parse
From: "Rajesh AVRS" <rajesh.ram@w...>
> 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



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.