Handling XML GENERATE exceptions
When an error is detected during generation of XML output,
an exception condition exists. You can write code to check the XML-CODE special
register, which contains a numeric exception code that indicates the
error type.
About this task
To handle errors, use either or both of the following
phrases of the XML GENERATE statement:
ON EXCEPTIONCOUNT IN
If
you code the ON EXCEPTION phrase in the XML
GENERATE statement, control is transferred to the imperative
statement that you specify. You might code an imperative statement,
for example, to display the XML-CODE value. If you
do not code an ON EXCEPTION phrase, control is transferred
to the end of the XML GENERATE statement.
When
an error occurs, one problem might be that the data item that receives
the XML output is not large enough. In that case, the XML output is
not complete, and the XML-CODE special register contains
error code 400.
You can examine the generated XML output by doing these steps:
Procedure
Results
Use the contents of XML-CODE to determine
what corrective action to take. For a list of the exceptions that
can occur during XML generation, see the related reference below.