user2169418
user2169418

Reputation: 11

XML Parsing Cobol

I have written a COBOL module for parsing a XML. XML value is stored in a DB2 table and I am running a select query to read the XML value. But while parsing, on the 1st instance itself it is throwing an exception with XML-CODE = 317. I did a search on this XML Code and found the description of this error as follows - 'The parser cannot determine the document encoding. The document may be damaged.'

There is no issue with the XML otherwise it would have thrown error while inserting into DB2 table. 1st tag in XML is which is also correct.

Can somebody please help me out in resolving this issue.

Thanks

Upvotes: 0

Views: 2405

Answers (2)

cschneid
cschneid

Reputation: 10775

You have given us some useful information...

  1. You are attempting to parse XML in COBOL
  2. The XML comes from another machine
  3. The XML is originally UTF-8
  4. The XML is stored in a DB2 table in a Unicode column
  5. The XML has a header indicating it is code page 1146
  6. You are receiving an XML-CODE of 317

What CODEPAGE option was your COBOL code compiled with? There may be an automatic conversion taking place, perhaps the header and the encoding no longer match after retrieval from DB2.

Are you parsing a PIC X field or a PIC N field?

Also, I suggest using the compile option XMLPARSE(XMLSS) as the "native COBOL" parser is deprecated as of Enterprise COBOL 5.1.

Upvotes: 1

Gilbert Le Blanc
Gilbert Le Blanc

Reputation: 51553

You probably have to specify an encoding on your XML header.

Here are some example encodings.

<?xml version="1.0" encoding="us-ascii"?>
<?xml version="1.0" encoding="windows-1252"?>
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-16"?>

Upvotes: 2

Related Questions