X hits on this document

391 views

0 shares

0 downloads

0 comments

103 / 120

Table 9.8. Implementation of a COBOL XML layer to the legacy application.

01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48:

$set preprocess(prexml) o(foo.pp) warn

endp

****************************************************************** ** Wrapper program that provides an XML interface to SMPLCALC ** ******************************************************************

IDENTIFICATION DIVISION.

PROGRAM-ID. 'XML2CALC'. DATA DIVISION. WORKING-STORAGE SECTION.

  • *

    Input/Output data structure 01 SMPLCALC-INTERFACE. 02 SI-OPERAND-1 PIC S9(9) COMP-5. 02 SI-OPERAND-2 PIC S9(9) COMP-5. 02 SI-OPERATION PIC X. 88 DO-ADD VALUE '+'. 88 DO-SUB VALUE '-'. 88 DO-MUL VALUE '*'. 02 SI-RESULT PIC S9(18) COMP-5. 02 SI-RESULT-MESSAGE PIC X(128).

    • *

      XML parsing state 01 XML-PARSE-STATE.

02 CURR-ELE-NAME 02 CURR-ELE-CONT LINKAGE SECTION.

PIC X(256). PIC X(256).

01

XML-DOC-LEN

PIC

S9(9) COMP-5.

01

XML-DOC-TXT

PIC

X(32767).

PROCEDURE

DIVISION

USING

XML-DOC-LEN

XML-DOC-TXT.

MAINLINE SECTION.

  • *

    Parse XML into SMPLCALC-INTERFACE XML PARSE XML-DOC-TXT(1:XML-DOC-LEN) PROCESSING PROCEDURE XML-HANDLER END-XML

    • *

      Invoke legacy COBOL application SMPLCALC CALL 'SMPLCALC' USING SMPLCALC-INTERFACE

    • *

      Generate XML from SMPLCALC-INTERFACE XML GENERATE XML-DOC-TXT FROM SMPLCALC-INTERFACE COUNT IN XML-DOC-LEN END-XML

    • *

      Return to client program GOBACK

.

  • *

    +--------------------------------------------------------------+

* | XML event handler for marshalling XML into COBOL data * | +--------------------------------------------------------------+ XML-HANDLER. EVALUATE XML-EVENT WHEN 'START-OF-ELEMENT' MOVE XML-TEXT TO CURR-ELE-NAME WHEN 'CONTENT-CHARACTERS'

49:

EVALUATE CURR-ELE-NAME

95

Document info
Document views391
Page views392
Page last viewedSat Dec 10 23:25:37 UTC 2016
Pages120
Paragraphs2913
Words25794

Comments