How to stop parsing XML in SAX

Hi,

I'm using "standard" XML library by Sun.

The parsing model is SAX (extending DefaultHandler).

How do I signal the XML parser to stop parsing?

(the reason is for example a data error is encountered and there is a need to cancel parsing any further)

Thanks.

[311 byte] By [Nik_Java] at [2007-9-26 3:17:08]
# 1
Hi,throw a new SAXParseException.Good Luck Roland
rkunzke at 2007-6-29 11:29:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
It's not a nice way, is it?Well, maybe it's the ONLY way?Any gurus?Thanks.
Nik_Java at 2007-6-29 11:29:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
Hi,i think yes, an this way isn't so bad.
rkunzke at 2007-6-29 11:29:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

I believe that's the only way. I created a PauseXMLParsingException that extends SAXException and then throw that. I Catch it in the calling code and know I stopped where I wanted without errors. What I'm searching for now is a way to resume parsing where I left off. However, my input stream is getting closed somehow when I throw the exception. If anyone has any ideas they would be much appreaciated :)

bdmolina at 2007-6-29 11:29:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5
Check this out (from a recently revived question I asked a while ago): http://www-106.ibm.com/developerworks/xml/library/x-tipsaxstop/index.html
mochamaniac at 2007-6-29 11:29:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6

I'm searching a way to restart saxParser after stopped it and reload XML document at the point where saxParser stopped.

If I use SAXException and stopped the Parser... after? How do I do it?

I think to use Thread, but I'm afraid I'll have same problem with this solution....

anybody have an good idea to do it?

Thanks in advance,

Angie

aserrac at 2007-6-29 11:29:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 7
Don't think you can. Once you throw any exception in any Java code, there is no way to continue on from the point where you threw that exception.
DrClap at 2007-6-29 11:29:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 8
I think so.I try to implement it by external producer and consumer thread.Thanks anyway.
aserrac at 2007-6-29 11:29:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...