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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: How to ask a SAX parser to stop firing events ? (whithout using Exce

[ Lists Home | Date Index | Thread Index ]
  • From: David Megginson <david@megginson.com>
  • To: xml-dev@xml.org
  • Date: 22 Apr 2000 08:37:08 -0400

Sebastien Sahuc <ssahuc@imediation.com> 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@megginson.com
           http://www.megginson.com/

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




 

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

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