Handling XML PARSE exceptions
If the XML parser encounters an anomaly or error during parsing, it sets an
exception code in the XML-CODE
special register and signals an XML
exception event.
About this task
If the exception code is within a certain range, you might be able to handle the exception event within your processing procedure, and resume parsing.
To handle an exception in the processing procedure, follow these steps:
Procedure
- Check the contents of
XML-CODE
. - Handle the exception appropriately.
-
Set
XML-CODE
to zero to indicate that you handled the exception. - Return control to the parser.
Results
The exception condition no longer exists.
You
can handle exceptions in this way only if the exception code that
is passed in XML-CODE
is within one of the following
ranges, which indicates that an encoding conflict was detected:
- 50 - 99
- 100,001 - 165,535
- 200,001 - 265,535
Exception codes 1 - 49: In the processing
procedure,
you can do limited handling of exceptions for which the exception
code is within the range 1 - 49. After an exception in this range
occurs, the parser does not signal any further normal events, except
the END-OF-DOCUMENT
event, even if you set XML-CODE
to
zero before returning. If you set XML-CODE
to zero,
the parser continues parsing the document and signals any exceptions
that it finds. (Doing so can provide a useful way to discover multiple
errors in the document.)
XML PARSE
event token
array, probably 8192 events.At the
end of parsing after an exception that has an exception
code in the range 1 - 49, control is passed to the statement
specified in the ON EXCEPTION
phrase. If you did
not code an ON EXCEPTION
phrase, control is passed
to the end of the XML PARSE
statement. XML-CODE
contains
the code set by the parser for the most recent exception.
For all exceptions other than those having an exception
code within one of the ranges described above, the parser does
not signal any further events, but passes control to the statement
specified in the ON EXCEPTION
phrase. XML-CODE
contains
the original exception code even if you set XML-CODE
in the
processing procedure before returning control to the parser.
If
you do not want to handle an exception, return control to the parser
without changing the value of XML-CODE
. The parser
transfers control to the statement specified in the ON EXCEPTION
phrase.
If you did not code an ON EXCEPTION
phrase, control
is transferred to the end of the XML PARSE
statement.
If
no unhandled exceptions occur before the end of parsing, control is
passed to the statement specified in the NOT ON EXCEPTION
phrase.
If you did not code a NOT ON EXCEPTION
phrase, control
is transferred to the end of the XML PARSE
statement. XML-CODE
contains
zero.