[Home] [By Thread] [By Date] [Recent Entries]

  • From: David Megginson <david@m...>
  • To: xml-dev@x...
  • Date: 22 Apr 2000 08:37:08 -0400

Sebastien Sahuc <ssahuc@i...> writes:

> Suppose the Parser has fed your application with half of the XML 
> document and you don't need to go further. How can you gently say to 
> the parser you've done with it ? I would like not to send an 
> Exception, because at runtime it is too time consuming and not really 
> nice. 

In Java, an exception is the *normal* way to do this.  Here's an
example (for SAX1):

  public class DoneParsingException extends SAXException
  {
  }

and then

  public void startElement (String name, AttributeList atts)
  {
    if (iHaveSeenEnough) {
      throw new DoneParsingException();
    }
  }

and then

  try {
    parse(myDocument);
  } catch (DoneParsingException e) {
    System.out.println("Parsing finished OK");
  } catch (SAXException e) {
    System.out.println("Something went wrong");
  }

I'm not sure what is time consuming about this.


All the best,


David

-- 
David Megginson                 david@m...
           http://www.megginson.com/

***************************************************************************
This is xml-dev, the mailing list for XML developers.
To unsubscribe, mailto:majordomo@x...&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/
***************************************************************************

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member