How the XML parser handles errors
When the XML parser detects an error in an XML document, it generates an XML exception event and passes control to your processing procedure.
The parser passes the following information in special registers to the processing procedure:
XML-EVENT
contains 'EXCEPTION
'.XML-CODE
contains a numeric exception code.The exception codes are described in the related references about
XML PARSE
exceptions.- For fatal exceptions,
XML-TEXT
orXML-NTEXT
contains the document text up to and including the point where the exception was detected. - For the warning exceptions
issued for using an undeclared prefix,
XML-TEXT
orXML-NTEXT
contains the fully qualified attribute name or element name. That is, the name includes the undeclared prefix and the separator colon (:). - If
XMLPARSE(COMPAT)
is in effect,XML-TEXT
orXML-NTEXT
contains the document text up to and including the point where the exception was detected. - If
XMLPARSE(XMLSS)
is in effect,XML-TEXT
orXML-NTEXT
contains the document text up to the point where the error or anomaly was detected. If you process the XML document one segment at a time, the applicable special register contains only the current segment.
All other XML special registers are empty with length zero.
For XMLPARSE(XMLSS)
:
Parsing cannot
continue after a fatal exception even if you set XML-CODE
to
zero in the processing procedure. Upon return to the parser from
the processing procedure, the parser transfers control to the ON
EXCEPTION
phrase, if specified; otherwise the parser transfers
control to the end of the XML PARSE
statement. XML-CODE
contains
the original exception code set by the parser.
For XMLPARSE(COMPAT)
:
The processing procedure might be able to handle an exception so that parsing continues if the exception code is within one of the following ranges:
- 1 - 99
- 100,001 - 165,535
If the exception code has any other nonzero value, parsing cannot continue.
Encoding
conflicts: The exceptions for encoding conflicts (50 - 99 and
300 - 399) are signaled before the parsing of the document begins.
For these exceptions, XML-TEXT
or XML-NTEXT
is
either length zero or contains only the encoding declaration value
from the document.
Exception
codes 1 - 49: An exception for which the exception code is in
the range 1 - 49 is a fatal error according to the XML specification.
Therefore, the parser does not continue normal parsing even if the
processing procedure handles the exception. However, the parser does
continue scanning for further errors until it reaches the end of the
document, or until the existing XML EVENT token array is exhausted.
For these exceptions, the parser does not signal any further normal
events except the END-OF-DOCUMENT
event.
Parsing XML documents one segment at a time
Handling XML PARSE exceptions
Handling encoding conflicts
Terminating XML parsing
XMLPARSE (compiler option)
The encoding of XML documents
XML PARSE exceptions with XMLPARSE(XMLSS) in effect
XML PARSE exceptions with XMLPARSE(COMPAT) in effect
z/OS XML System Services User's Guide and Reference
XML specification