Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Ways for generic/flexible XML Parsing

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Ways for generic/flexible XML Parsing
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: 1243
Location: Israel

PostPosted: Thu Mar 19, 2009 8:58 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts INREC PARSING and dictionary items migusd SYNCSORT 6 Fri Jun 02, 2017 8:02 pm
No new posts Generic rename by pattern‏ Steve Coalbran CLIST & REXX 6 Mon May 30, 2016 9:34 pm
No new posts Parsing and Listing a Subset of Recor... Charles Wolters IBM Tools 3 Fri Feb 05, 2016 10:39 pm
No new posts Parsing JCL SET var=value statements prino CLIST & REXX 0 Sat Dec 26, 2015 4:41 am
No new posts Issue in transfering control when Del... thesumitk CICS 10 Wed Apr 01, 2015 6:45 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us