I am parsing an XML file with SAXReader and would like to stop after a certain amount of time (timeout) in case the file is too large. At a high level, I would like to throw a SAXException in the ContentHandler (in, say, startElement).
The idea is described here: http://www.ibm.com/developerworks/xml/library/x-tipsaxstop/
However, dom4j's SAXReader uses ElementHandler where the "onStart" and "onEnd" events don't allow throwing of exceptions. I'm a little stuck as to what to do here.
Any suggestions? Thanks.