Not sure but hoping it helps.
Create a class for exception.
public class MySAXTerminatorException extends SAXException {
...
}
I guess there is an overridden method named startElement(...)
in SAX parser.
Keep a global boolean variable, set it to true when you want to and keep checking this value in very first lines of startElement method.
As every-time control has to come to this method, as soon as that boolean becomes true, execution will be terminated with an exception.
Something like this
if (someConditionOrOther) {
throw new MySAXTerminatorException();
}