Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

COBOL using XML Parser
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
pleonard

New User


Joined: 20 Sep 2006
Posts: 19

PostPosted: Sat Dec 13, 2008 5:42 pm    Post subject: COBOL using XML Parser
Reply with quote

I'm processing the XML through program COBOL z/OS (I guess we use 3.4 compiler version). On this XML I have something called "encoding=utf-8" which is a lot of problems to process. The parser is out with xml-code=70 (exception) and I already attempting to change the codepage option using CODEPAGE(1208) but I got xml-code=320.

Looks like in COBOL 4 there are WITH ENCODING to be used in XML Parser but I have COBOL 3.4. Are there a way to use xml parser to processing this encoding using cobol 3.4 ?

Regards
Paulo
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Sat Dec 13, 2008 6:13 pm    Post subject:
Reply with quote

utf-8 is essentially ASCII, upgraded for Unicode. The XML encoding is determined by whatever generated the XML; if you don't change the encoding there you're wasting your time.

If you convert the file from ASCII to EBCDIC, you may be able to change the encoding from utf-i to ebcdic-cp-us and be able to read it in COBOL. However, that's not a viable long term solution IMHO since you need to be handling the code as specified by the generator.
Back to top
View user's profile Send private message
pleonard

New User


Joined: 20 Sep 2006
Posts: 19

PostPosted: Sat Dec 13, 2008 7:14 pm    Post subject: Reply to: COBOL using XML Parser
Reply with quote

How can I convert the message from ASCII to EBCDIC to manipulate it in COBOL ?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Sat Dec 13, 2008 7:37 pm    Post subject:
Reply with quote

Unix System Services command iconv will do the conversion, if the file is in Unix -- I'd probably OPUT it, convert it, and OGET it if this is a testing process underway.

If iconv isn't suitable, when you do the transfer do it as a text file.
Back to top
View user's profile Send private message
pleonard

New User


Joined: 20 Sep 2006
Posts: 19

PostPosted: Sat Dec 13, 2008 9:05 pm    Post subject: Reply to: COBOL using XML Parser
Reply with quote

It will be a problem. My program is called by a CICS transaction that passes a commonarea and XML DOCUMENT as parameters with encoding there.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Sat Dec 13, 2008 9:29 pm    Post subject:
Reply with quote

In that case, you can process it using UTF-8 or get the encoding changed on the source side.
Back to top
View user's profile Send private message
pleonard

New User


Joined: 20 Sep 2006
Posts: 19

PostPosted: Sat Dec 13, 2008 11:20 pm    Post subject: Reply to: COBOL using XML Parser
Reply with quote

but using XML PARSE I got XML-CODE=70. I tried to use CODEPAGE compile option with CODEPAGE(1208) NSYMBOL(NATIONAL) and is getting XML-CODE=320.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun Dec 14, 2008 12:39 am    Post subject:
Reply with quote

Hello,

You are changing "things" on the mainframe-side of the process. . . .

You need to have the file changed on the system that generates the file as Robert suggested.
Back to top
View user's profile Send private message
pleonard

New User


Joined: 20 Sep 2006
Posts: 19

PostPosted: Sun Dec 14, 2008 1:00 am    Post subject: Reply to: COBOL using XML Parser
Reply with quote

In that case, you can process it using UTF-8 or get the encoding changed on the source side.

How can I do that ?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun Dec 14, 2008 2:21 am    Post subject:
Reply with quote

Hello,

Quote:
How can I do that ?
You may or may not be able to. . .

I believe that if you get the file changed before you try to work with it, most or all of the problems will be resolved. One concern i would have is that even if you get something working, there may be some surprise later.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Sun Dec 14, 2008 3:20 am    Post subject:
Reply with quote

I have not done a lot of work on XML so I can't say 100% for sure what will work for you, but I find in the COBOL Language Reference manual section 6.2.41.3.2:
Quote:
When you parse ASCII XML documents, the document fragments passed to the processing procedure in special register XML-TEXT are encoded in ASCII. Because Enterprise COBOL operations such as move and comparison rely on EBCDIC encoding or on national characters for proper operation, you must convert the document fragments before using them. To do this, first convert from the ASCII code page of the XML document to national characters using the NATIONAL-OF intrinsic function. Then, if necessary, convert the result from national characters to EBCDIC using the DISPLAY-OF intrinsic function. You can do this without an explicit national data item, for example, MOVE FUNCTION DISPLAY-OF (FUNCTION NATIONAL-OF(XML-TEXT ascii-ccsid) ebcdic-ccsid) TO ebcdic-text.

You can reliably write ASCII XML fragments to a file or database without conversion.
I would try the recommended conversion
Code:
MOVE FUNCTION DISPLAY-OF (FUNCTION NATIONAL-OF(XML-TEXT 819) 1047) TO XML-EBCDIC-TEXT.
819 is the LATIN-1 ASCII code page ccsid and 1047 is the LATIN-1 EBCDIC code page ccsid.
Back to top
View user's profile Send private message
pleonard

New User


Joined: 20 Sep 2006
Posts: 19

PostPosted: Sun Dec 14, 2008 7:30 pm    Post subject: Reply to: COBOL using XML Parser
Reply with quote

After did the changes I got XML-CODE=317

317 The parser cannot determine the document encoding. The document might be damaged.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Sun Dec 14, 2008 8:16 pm    Post subject:
Reply with quote

Going back to your original post, the 70 is listed in the Programming Guide as meaning
Quote:
| The basic document encoding was
| EBCDIC, and the CODEPAGE compiler
| option specified a supported EBCDIC
| code page, but the document encoding
| declaration did not specify a
| supported EBCDIC code page.

which tells me that the file was converted from ASCII to EBCDIC but the encoding within the document was not updated. Can you try moving this file from its source as a binary file rather than text to see if the 70 goes away?

Alternatively, you could recompile the program with CODEPAGE(819) and see if the 70 goes away.
Back to top
View user's profile Send private message
pleonard

New User


Joined: 20 Sep 2006
Posts: 19

PostPosted: Sun Dec 14, 2008 9:00 pm    Post subject: Reply to: COBOL using XML Parser
Reply with quote

Now I got XML-CODE=73

73 The actual document encoding was EBCDIC, but neither the CODEPAGE compiler option nor the document encoding declaration specified a supported EBCDIC code page. The parser uses EBCDIC code page 1140 (USA, Canada, . . . Euro Country Extended Code Page).
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Mon Dec 15, 2008 1:21 am    Post subject:
Reply with quote

OK, recompile without the codepage option and change the encoding= string in the file from utf-8 to EBCDIC; basically the problem you keep getting is that the encoding= name must match the actual file encoding. Your file does not match; it appears to be an EBCDIC file with encoding=utf-8 specified. You can either change the file encoding by changing the file (and I do not know how to recode it from EBCDIC to utf-8 without additional research), or change what is expected by changing the encoding= string within the file.
Back to top
View user's profile Send private message
pleonard

New User


Joined: 20 Sep 2006
Posts: 19

PostPosted: Mon Dec 15, 2008 5:17 pm    Post subject: Reply to: COBOL using XML Parser
Reply with quote

I put EBCDIC in place of UTF-8 in the file, keep the MOVE FUNCTION DISPLAY OF with DBCS option (it is required when we use DISPLAY OF function) however, I got xml-code=317 again making move from ASCII to EBCDIC. Attempting to move from EBCDIC to ASCII I got xml-code=83.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Mon Dec 15, 2008 6:43 pm    Post subject:
Reply with quote

The 83 is promising -- it indicates the XML parser recognizes the file as being ASCII but the encoding didn't match -- try encoding='iso8859-1' for this file since that would indicate Latin-I ASCII.

Also, note that error codes 1 to 99 are error codes that XML handles and supposedly allows you to continue; have you checked the output field with the 70 or 83 error codes?
Back to top
View user's profile Send private message
pleonard

New User


Joined: 20 Sep 2006
Posts: 19

PostPosted: Mon Dec 15, 2008 6:57 pm    Post subject:
Reply with quote

I changed the file to be 'iso8859-1' and resubmit and got xml-code=317. How can I interpose the xml-code 70 or 83 in my program ?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Mon Dec 15, 2008 7:25 pm    Post subject:
Reply with quote

You've hit the limits of my knowledge -- if there's anybody with XML expertise at your site, you need to talk over your problem with them. The 317 is not an error that can be continued; 70 or 83 allow you to set XML-CODE to zero and continue processing according to the manual.

The error codes you've posted are consistently encoding conflict errors -- where the file is EBCDIC and the encoding= option of XML does not reflect an EBCDIC encoding, or the file is ASCII and the encoding= option does not reflect an ASCII encoding. The difficulty is finding an encoding string (819 or iso8859-1 or whatever) that allows the ASCII file to be processed, or the EBCDIC file to be processed with encoding=1047 or whatever: EBCDIC would be better since the mainframe would allow you to view the output but getting it processed would be the first thing.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Dec 16, 2008 1:18 am    Post subject:
Reply with quote

Hello,

To return to an earlier part of the topic - it may be helpful to try re-creating the file and using this new file for continued testing. . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us