From: Paul Knudsen on

Post on Kasamba, in case you missed it: Can sign up and respond
directly if interested.

Hi, Need the link to tutorial or the book name that helps me to
modify/code COBOL program to convert flat file into XML format. I know
COBOL but don't know XML. Thanks
From: Richard on


Paul Knudsen wrote:
> Post on Kasamba, in case you missed it: Can sign up and respond
> directly if interested.
>
> Hi, Need the link to tutorial or the book name that helps me to
> modify/code COBOL program to convert flat file into XML format. I know
> COBOL but don't know XML. Thanks

The way that I output XML (or HTML, CSV, etc), is to use a template
and a templating routine.

The template is just a text file. It could be in sections, or it could
use counters to repeat blocks as required. The easiest way is to have
sections (here indicated by ':'). Options are started by '*': Tags,
where data is substituted, are <!%tagname%>.

*XML
*CRLF
:header
<?XML ...
<order>
<oderheader>
<ordernumber><!%orederno%></ordernumber>
<customer id="<!%customer%>">
<customer_name><!%custname%></customername>
<delivery_address>
<street><!%cdadd1%></street>
....
</delivery_address>
</customer>
</orederheader>
:oderline
<orderline>
From: Richard on


Paul Knudsen wrote:
> Post on Kasamba, in case you missed it: Can sign up and respond
> directly if interested.
>
> Hi, Need the link to tutorial or the book name that helps me to
> modify/code COBOL program to convert flat file into XML format. I know
> COBOL but don't know XML. Thanks

The way that I output XML (or HTML, CSV, etc), is to use a template
and a templating routine.

The template is just a text file. It could be in sections, or it could
use counters to repeat blocks as required. The easiest way is to have
sections (here indicated by ':'). Options are started by '*': Tags,
where data is substituted, are <!%tagname%>.

*XML
*CRLF
:header
<?XML ...
<order>
<oderheader>
<ordernumber><!%orderno%></ordernumber>
<customer id="<!%customer%>">
<customer_name><!%custname%></customername>
<delivery_address>
<street><!%cdadd1%></street>
....
</delivery_address>
</customer>
</orederheader>
:oderline
<orderline>
<product><!%prodcode%></product>
....

</orderline>
:trailer
</order>

In the application set up a table of tagname: value pairs, probably
preset in W-S.

01 XML-Header.
03 FILLER PIC X(12) VALUE "orderno".
03 XML-OrderNo PIC X(40).
03 FILLER PIC X(12) VALUE "customer".
03 XML-Customer PIC X(40).
.....
03 FILLER PIC X(12) VALUE SPACES
03 FILLER PIC X(40).

01 XML-OrderLine.
03 FILLER PIC X(12) VALUE "prodcode".
03 XML-ProdCode PIC X(40).
....

Ine the program:

MOVE ?? TO XML-OrderNo
MOVE .. TO XML-Customer

CALL "template" USING "xmlorder" "header" XML-Header

PERFORM
UNTIL all lines output

MOVE ?? TO XML-ProdCode
MOVE .. TO XML-OrderQty

CALL "template" USING "xmlorder" "orderline" XML-
OrderLine
END-PERFORM

CALL "template" USING "xmlorder" "trailer" XML-Trailer

In program template:

LINKAGE SECTION.
01 Template-Name PIC X(12).
01 Template-Section PIC X(12).
01 Template-Data.
03 Template-Item OCCURS 100.
05 Template-Tag PIC X(12).
05 Tremplate-Value PIC X(40).
PROCEDURE DIVISION.

The program needs to identify first time in so it will open and read
the template into an array and set up a table of sections with start
end indexes into the line table.

Then for each line in the section being output replace the tagnames
with the value from the table. (a space tagname ends the table).

Then you won't care about what the output looks like. If it needs to
change just adjust the template. If they want it as a CSV or HTML or
some other then just use a different template.



From: Michael Mattias on
"Paul Knudsen" <pknudsen(a)NOSPAMyahoo.com> wrote in message
news:mk65p3t0gved4r3p9jnq230kjuo6pk5pan(a)4ax.com...
>
> Hi, Need the link to tutorial or the book name that helps me to
> modify/code COBOL program to convert flat file into XML format. I know
> COBOL but don't know XML. Thanks

Tutorials on XML (and much much more): http://www.w3schools.com/

MCM



From: William M. Klein on
What is your COBOL compiler? Some (not all) COBOL compilers have specific syntax
to do this "automatically" (more or less). (Even with those, you can use "brute
force" coding - and may even need to for some types of XML).

--
Bill Klein
wmklein <at> ix.netcom.com
"Paul Knudsen" <pknudsen(a)NOSPAMyahoo.com> wrote in message
news:mk65p3t0gved4r3p9jnq230kjuo6pk5pan(a)4ax.com...
>
> Post on Kasamba, in case you missed it: Can sign up and respond
> directly if interested.
>
> Hi, Need the link to tutorial or the book name that helps me to
> modify/code COBOL program to convert flat file into XML format. I know
> COBOL but don't know XML. Thanks