[
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/
***************************************************************************
|