Terminating XML parsing

You can terminate parsing immediately, without processing any remaining XML text, by setting XML-CODE to -1 in your processing procedure before the procedure returns to the parser from any normal XML event (that is, any event other than EXCEPTION).

About this task

You can use this technique when the processing procedure has examined enough of the document or has detected some irregularity in the document that precludes further meaningful processing.

If you terminate parsing in this way, the parser does not signal any further XML events, including the exception event. Control transfers to the ON EXCEPTION phrase of the XML PARSE statement, if that phrase was specified.

In the imperative statement of the ON EXCEPTION phrase, you can determine whether parsing was deliberately terminated by testing whether XML-CODE contains -1. If you do not specify the ON EXCEPTION phrase, control transfers to the end of the XML PARSE statement.

If the XMLPARSE(COMPAT) compiler option is in effect, you can also terminate parsing after any XML EXCEPTION event by returning to the parser from the processing procedure without changing the value in XML-CODE. The result is similar to the result of deliberate termination, except that the parser returns to the XML PARSE statement with XML-CODE containing the original exception code.

If the XMLPARSE(XMLSS) option is in effect, parsing always terminates after any exception event.