XML-CODE Special Register

The XML-CODE special register is used for the following purposes:
  • To communicate status between the XML parser and the processing procedure that was identified in the XML PARSE statement
  • To indicate either that an XML GENERATE statement executed successfully or that an exception occurred during XML generation

The XML parser sets XML-CODE prior to transferring control to the processing procedure for each event and at parser termination. You can reset XML-CODE prior to returning control from the processing procedure to the XML parser.

The XML-CODE special register has the implicit definition:

01 XML-CODE PICTURE S9(9) USAGE BINARY VALUE 0.

When used in nested programs, this special register is implicitly defined with the global attribute in the outermost program.

When the XML parser encounters an XML event, it sets XML-CODE and then passes control to the processing procedure. For all events except an EXCEPTION event, XML-CODE contains zero when the processing procedure receives control.

For an EXCEPTION event, the parser sets XML-CODE to an exception code indicating the nature of the exception. Exception codes are detailed in the ILE COBOL Programmer's Guide.

You can set XML-CODE before returning to the parser, as follows:
  • To -1, after a normal event, to indicate that the parser is to terminate without causing an EXCEPTION event.
  • To zero, after an EXCEPTION event for which continuation is allowed, to indicate that the parser is to continue processing. The parser will attempt to continue processing the XML document, but results are undefined.

If you set XML-CODE to any other value before returning to the parser, results are undefined.

When the parser returns control to the XML PARSE statement, XML-CODE contains the most recent value set either by the parser or by the processing procedure.

At termination of an XML GENERATE statement, XML-CODE contains either zero, indicating successful completion of XML generation, or a nonzero error code, indicating that an exception occurred during XML generation. XML GENERATE exception codes are detailed in the ILE COBOL Programmer's Guide.