IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Ways for generic/flexible XML Parsing


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
PL1user

New User


Joined: 26 Nov 2008
Posts: 13
Location: UK

PostPosted: Thu Mar 19, 2009 6:32 pm
Reply with quote

Hi

I have used XML Parsing and XML Generate before but now I have come across an even tougher challenge.

To briefly tell the requirement,

We would receive an XML File from an interfacing system. This is a XML file, and this file would be based on a specific schema. We need to do the following as soon as we receive,

1. XSD Validation.
2. Strip XML data into a flat file. This flat file would be used by our application (running on IBM Mainframe).

Vice versa, we should create an XML file using a normal flat file. This XML file would then be sent back to the interfacing team. This file would mostly be a reconciliation file letting them know what we have processed.

Now the challenge is, the schema is liable for a change frequently. This means they might introduce a new tag and we might need to process that as well.

The way XML Parse works, I normally have to identify what start of tag element i have read and then determine what i need to do with the data.

For E.G.
Code:
<Details><Name>PL1User</Name><Company>IBM</Company></Details>


I execute the following,
Code:
XML PARSE STRING-TO-BE-PARSED PROCESSING PROCEDURE XML-HANDLER-SECTION
ON EXCEPTION
      <ABEND>
NOT ON EXCEPTION
        CONTINUE
END-XML.


Code:
EVALUATE XML-EVENT
WHEN 'START-OF-ELEMENT'
            This is to indicate the start of a XML tag

WHEN 'END-OF-ELEMENT'
            This is to indicate the end of a XML tag

WHEN 'CONTENT-NATIONAL-CHARACTER'
            This is to indicate one set of special characters inside the XML data (please refer to the above link for more details)

WHEN 'CONTENT-CHARACTER'
            This is to indicate another set of special characters (&, ‘, “, <, >, ~ and so on) inside the XML data (please refer to the above link for more details)

WHEN 'CONTENT-CHARACTERS'
            This is to indicate the actual XML data


I hardcode the tag name and determine what i need to do if that tag appears. But can this be made generic in COBOL ? Can I just have the XML SCHEMA in one file and a file layout (matching the XML schema) & then read through the XML String of data and just unpack them into the file, regardless of what tags they are ? This way, if the schema changes, i just have to change the file layout. The programs remains untouched ?

Request you to advice me.

Thanks.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Mar 19, 2009 8:58 pm
Reply with quote

I have started to work on something that have similarities with your request.

We are using COPY statements for all data layouts (files, linkage areas, commareas and so on).
By running the copybook in my engine, I am supposed to generate (and compile) automatically a cobol program that performs XML to COPY or COPY to XML conversion.

There is one program for each COPY statement.
When the COPY changes, the program can be easily re-generated to reflect the change.

This project has been relegated to my backdrawer, but I had a working prototype.
Written in REXX, with a panel to collect the information and a skeleton containing the cobol program.

Quote:
This way, if the schema changes, i just have to change the file layout. The programs remains untouched ?
It's not exactly like you said, but maybe it's close enough to be helpful.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Parsing Large JSON file using COBOL COBOL Programming 4
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts parsing with startat and endbefr SYNCSORT 10
No new posts CICS webservice - Flexible Interface CICS 0
No new posts XML Parsing in COBOL creating "h... COBOL Programming 0
Search our Forums:

Back to Top