XML-CODE

For each XML event except an EXCEPTION event, the parser sets the value of the XML-CODE special register to zero. For an EXCEPTION event, the parser sets XML-CODE to a value that identifies the specific exception.

For information about the possible exception codes, see the related references.

When the parser returns control to the XML PARSE statement from your processing procedure, XML-CODE generally contains the most recent value that was set by the parser. However, for any event other than EXCEPTION, if you set XML-CODE to -1 in your processing procedure, parsing terminates with a user-initiated exception condition when control returns to the parser, and XML-CODE retains the value -1.

For an EXCEPTION XML event, your processing procedure can, in some cases, set XML-CODE to a meaningful value before control returns to the parser. (For details, see the related tasks about handling XML PARSE exceptions and handling encoding conflicts.) If you set XML-CODE to any other nonzero value or set it for any other exception, the parser resets XML-CODE to the original exception code.

The following table shows the results of setting XML-CODE to various values. The leftmost column shows the type of XML event passed to the processing procedure; the other column headings show the XML-CODE value set by the processing procedure. The cell at the intersection of each row and column shows the action that the parser takes upon return from the processing procedure for a given combination of XML event and XML-CODE value.

Table 1. Result of processing-procedure changes to XML-CODE
XML event type -1 0

XML-CODE-100,000
(EBCDIC)
XML-CODE-200,000
(ASCII)

Other nonzero value
Encoding-conflict exception (exception codes 50 - 99) Ignores setting; keeps original XML-CODE value Chooses encoding depending on the specific exception code1 Ignores setting; keeps original XML-CODE value Ignores setting; keeps original XML-CODE value
Encoding-choice exception (exception codes > 100,000) Ignores setting; keeps original XML-CODE value Parses using the external code page2 Parses using the difference (shown above) as the encoding value2 Ignores setting; keeps original XML-CODE value
Other exception Ignores setting; keeps original XML-CODE value Limited continuation only for exception codes 1 - 493 Ignores setting; keeps original XML-CODE value Ignores setting; keeps original XML-CODE value
Normal event Ends immediately; XML-CODE = -14 [No apparent change to XML-CODE] Ends immediately; XML-CODE = -1 Ends immediately; XML-CODE = -1
For more information:
  1. See the exception codes in the related reference about XML PARSE exceptions.
  2. See the related task about handling encoding conflicts.
  3. See the related task about handling XML PARSE exceptions.
  4. See the related task about terminating XML parsing.

XML generation also uses the XML-CODE special register. For details, see the related task about handling XML GENERATE exceptions.

related concepts  
How the XML parser handles errors  

related tasks  
Writing procedures to process XML  
Handling XML PARSE exceptions  
Handling encoding conflicts  
Terminating XML parsing  
Handling XML GENERATE exceptions  

related references
XML PARSE exceptions  
XML GENERATE exceptions  
XML-CODE (COBOL for AIX Language Reference)
XML-EVENT (COBOL for AIX Language Reference)