Handling encoding conflicts

The way that you handle encoding-conflict exceptions depends on the setting of the XMLPARSE compiler option.

About this task

For XMLPARSE(XMLSS):

The parser does not continue after an encoding-conflict exception or after any other type of exception. Any changes that you make in the processing procedure to the value of XML-CODE are ignored. The value in XML-CODE when the parser returns to the XML PARSE statement is the original exception code that the parser set.

For XMLPARSE(COMPAT):

Your processing procedure might be able to handle exceptions for document encoding conflicts. Exception events in which the parse data item is alphanumeric and the exception code in XML-CODE is within the range 100,001 - 165,535 indicate that the code page of the document (as specified by its encoding declaration) conflicts with the external code-page information.

In this special case, you can choose to parse using the code page of the document by subtracting 100,000 from the value in XML-CODE. For instance, if XML-CODE contains 101,140, the code page of the document is 1140. Alternatively, you can choose to parse using the external code page by setting XML-CODE to zero before returning to the parser.

The parser takes one of three actions after returning from a processing procedure for an encoding-conflict exception event:

  • If you set XML-CODE to zero, the parser uses the external code page: the value of the CODEPAGE compiler option.
  • If you set XML-CODE to the code page of the document (that is, the original XML-CODE value minus 100,000), the parser uses the code page of the document.

    This is the only case in which the parser continues when XML-CODE has a nonzero value upon returning from a processing procedure.

  • Otherwise, the parser stops processing the document and returns control to the XML PARSE statement with an exception condition. XML-CODE contains the exception code that was originally passed with the exception event.

Related concepts    
XML-CODE  
XML input document encoding
      
How the XML parser handles errors  

Related tasks    
Handling XML PARSE exceptions  

Related references  
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