|
Part 1 (3 Aug 05) I'm trying to test the new feature of ILE COBOL V5R3, the XML PARSE ability, but I have problems. When I try this simplest example: Identification division. Program-id. HelloXML. Data division. Working-storage section. 1 M. 2 pic x(40) value '<?xml version="1.0" encoding="ibm-37"?>'. 2 pic x(40) value '<msg type="succinct">Hello, World!</msg>'. Procedure division. Display 'XML Event XML Text' XML Parse M Processing procedure P End-XML Goback. P. If XML-Code = 0 Display XML-Event XML-Text End-if. End program HelloXML. I obtain Exception. The values of registers are: XML-CODE = 000000051 i.e. "The document was encoded in EBCDIC, and the document encoding declaration specified a supported EBCDIC encoding, but the parser does not support the CCSID of the COBOL source member." I'dont know why the parser does not support the CCSID of my source member, because the CCSID of my source file is 37 (just like the CCSID of XML) XML-EVENT = 'EXCEPTION ' When I try to look at XML-TEXT, I become the following message: Message ID . . . . . . : MCH0601 Severity . . . . . . . : 40 Message type . . . . . : Diagnostic Date sent . . . . . . : 03/08/05 Time sent . . . . . . : 09:13:55 Message . . . . : Space offset X'00FFF000' or X'0000000000000000' is outside current limit for object &1. Cause . . . . . : A program tried to set a space pointer or use storage outside a space, or tried to use an unallocated page in teraspace. The space class is X'04'. The space class designates the type of space: 00-primary associated space (includes space objects). 01-secondary associated space 0. 02-implicit process space for automatic storage. 03-implicit process space for static storage in activation group mark X'00000000'. 04-implicit process space for heap identifier X'00000000' in activation group mark X'00000000'. 05-constant space. 06-space for handle-based heap identifier X'00000000'. 07-teraspace offset X'0000000000000000'. 08-teraspace for OS/400 PASE memory address X'0000000000000000'. Offset X'00FFF000' only applies to storage outside teraspace. X'8000000000000000F1D06F2C2E001000' is a pointer to the teraspace page or the start of the implicit process space for the allocation. Can anybody say me, what's going wrong? Part 2 (11 Aug 05 8:34) The above mentioned problem can be partially solved by placing the XML document (encoded in CCSID=819) in the IFS directory e.g. /home/user1. The CCSID defined inside of the XML document must be 819 too, i.e.: <?xml version="1.0" encoding="ibm-819" standalone="yes"?> <!--This document is just an example--> <sandwich> <bread type="baker's best"/> <?spread please use real mayonnaise ?> <meat>Ham & turkey</meat> <filling>Cheese, lettuce, tomato, etc. </filling> <![CDATA[We should add a <relish> element in future!]]> <listprice>$4.99 </listprice> <discount>0.10</discount> </sandwich> and here is the COBOL sample program Process APOST Identification division. Program-id. xmlsampl2. Data division. Working-storage section. ****************************************************************** * XML document, encoded as initial values of data items. * ****************************************************************** 1 xml-id pic x(27) value '/home/user1/xmlsampldoc.xml'. 1 xml-document-length computational pic 999. ****************************************************************** * Sample data definitions for processing numeric XML content. * ****************************************************************** 1 current-element pic x(30). 1 list-price computational pic 9v99 value 0. 1 discount computational pic 9v99 value 0. 1 display-price pic $$9.99. Procedure division. mainline section. XML PARSE FILE-STREAM xml-id PROCESSING PROCEDURE xml-handler ON EXCEPTION display 'XML document error ' XML-CODE NOT ON EXCEPTION display 'XML document successfully parsed' END-XML ****************************************************************** * Process the transformed content and calculate promo price. * ****************************************************************** display ' ' display '-----+++++***** Using information from XML ' '*****+++++-----' display ' ' move list-price to display-price display ' Sandwich list price: ' display-price compute display-price = list-price * (1 - discount) display ' Promotional price: ' display-price display ' Get one today!' goback. xml-handler section. evaluate XML-EVENT * ==> Order XML events most frequent first when 'START-OF-ELEMENT' display 'Start element tag: <' XML-TEXT '>' move XML-TEXT to current-element when 'CONTENT-CHARACTERS' display 'Content characters: <' XML-TEXT '>' * ==> Transform XML content to operational COBOL data item... evaluate current-element when 'listprice' * ==> Using function NUMVAL-C... compute list-price = function numval-c(XML-TEXT) when 'discount' compute discount = function numval-c(XML-TEXT) end-evaluate when 'END-OF-ELEMENT' display 'End element tag: <' XML-TEXT '>' move spaces to current-element when 'START-OF-DOCUMENT' compute xml-document-length = function length(XML-TEXT) display 'Start of document: length=' xml-document-length ' characters.' when 'END-OF-DOCUMENT' display 'End of document.' when 'VERSION-INFORMATION' display 'Version: <' XML-TEXT '>' when 'ENCODING-DECLARATION' display 'Encoding: <' XML-TEXT '>' when 'STANDALONE-DECLARATION' display 'Standalone: <' XML-TEXT '>' when 'ATTRIBUTE-NAME' display 'Attribute name: <' XML-TEXT '>' when 'ATTRIBUTE-CHARACTERS' display 'Attribute value characters: <' XML-TEXT '>' when 'ATTRIBUTE-CHARACTER' display 'Attribute value character: <' XML-TEXT '>' when 'START-OF-CDATA-SECTION' display 'Start of CData: <' XML-TEXT '>' when 'END-OF-CDATA-SECTION' display 'End of CData: <' XML-TEXT '>' when 'CONTENT-CHARACTER' display 'Content character: <' XML-TEXT '>' when 'PROCESSING-INSTRUCTION-TARGET' display 'PI target: <' XML-TEXT '>' when 'PROCESSING-INSTRUCTION-DATA' display 'PI data: <' XML-TEXT '>' when 'COMMENT' display 'Comment: <' XML-TEXT '>' when 'EXCEPTION' compute xml-document-length = function length (XML-TEXT) display 'Exception ' XML-CODE ' at offset ' xml-document-length '.' when other display 'Unexpected XML event: ' XML-EVENT '.' end-evaluate . End program xmlsampl2. There is a CCSID-Option in ILE COBOL compiler too. After the compiling with the command CRTBNDCBL PGM(EBKPGMP/XMLSAMPL2) SRCFILE(RM/XMLSRC) SRCMBR(XMLSAMPL2) OPTION(*SOURCE *APOST) DBGVIEW(*SOURCE) ACTGRP(*CALLER) CCSID(819) (or without CCSID option) the program runs without exception, but the output is hieroglyphics (false encoding) e.g.: Start element tag: <Ë/>???ÄÇ> Content characters: < > Start element tag: <Â?Á/?> Attribute name: <?`?Á> Attribute value characters: <Â/,Á?> Attribute value character: < Attribute value characters: <Ë ÂÁË?> I don't know how to fix this problem.. I spoked with the IBM support too. At present it seems so, that XML PARSE statement in ILE COBOL has problems with encodings, it works probably only with CCSID=819. My opinion is, that the XML PARSE in ILE COBOL V5R3 statement is presently not fit for production use. Have you other experience with XML PARSE statement in ILE COBOL V5R3 ?
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.