You can terminate parsing deliberately by setting XML-CODE to -1 in your processing procedure before returning to the parser from any normal XML event (that is, not an EXCEPTION event). You can use this technique when you have seen enough of the document for your purposes or have detected some irregularity in the document that precludes further meaningful processing.
In this case, the parser does not signal any further events, although an exception condition exists. Therefore control returns to your ON EXCEPTION phrase, if you have specified it. There you can test if XML-CODE is -1, which indicates that you terminated the parse deliberately. If you do not specify an ON EXCEPTION phrase, control returns to the end of the XML PARSE statement.
You can also terminate parsing after any exception XML event by returning to the parser without changing 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 exception number.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.