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.
XML PARSE STRING-TO-BE-PARSED PROCESSING PROCEDURE XML-HANDLER-SECTION
NOT ON EXCEPTION
This is to indicate the start of a XML tag
This is to indicate the end of a XML tag
This is to indicate one set of special characters inside the XML data (please refer to the above link for more details)
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)
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 ?
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.
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.