_____________________________________________________________________________________________________________________________________________________________

Creating an XML Handler using an XML Schema

This tutorial will help you to understand

·         How to create an XML Reader (Parser) and an XML Writer from an XML Schema.

·         How to set the generation options.

·         What files you should have after code generation.

·         How to write a Writer calling program.

_____________________________________________________________________________________________________________________________________________________________

 

Step 1: Launch XML Thunder

The welcome screen will appear and give you two different options, one to Create a New XML Handler and one to Open existing handlers. If you disabled the welcome screen, please click icon or choose XML Handler -> New from main menu.
For now, click the first option.


 

If the wizard starts with the Introduction panel, click Next.

 

Step 2: Select the IDS and XML source

On the Source panel, set the XML source to XML Schema and set the location to Program files\XML ThunderV4\tutorial\XML Schema Samples\BAXSD.xsd and set Derive from XML as your IDS source.  Click Next to continue.

 

Step 3: Specify Additional Properties

On the Properties panel, leave the default values for the Identifiers and set the XML Root Element to BANK. Click Next to continue.

          

 

Step 4: Confirm Selections

On the Summary panel, review the selections and click Finish.

 


XML Thunder will create an XML Handler design with the XML structure based on the schema provided and the IDS derived from the XML.  The mappings between IDS fields and XML nodes have been completed automatically.



Step 5: Generate the XML Handlers

Click Generate or select Tools -> Generate… from the main menu.

On the XML Reader tab

·         Select the XML Reader, IDS (Interface Data Structure) and Test Harness for generation.

·         Set source names to BNKRECR, BNKRECRC and BNKRECRT.

·         Access the More Options pane of the Test Harness and change “Read XML from” to “External File” and “Output Data” to “Display”.

On the XML Writer tab

·         Select XML Writer, IDS (Interface Data Structure) and Test Harness for generation. 

·         Set source names to BNKRECW, BNKRECWC and BNKRECWT.

·         Access the More Options pane of the Test Harness and change the Output Data to field to File.

Click Generate.

 

When generation completes, six COBOL source code files should be created. 

·         BNKRECR.cbl – The XML Reader

·         BNKRECRC.CPY – The copybook to support the API to the XML Reader

·         BNKRECRT.cbl – The Test Harness for the XML Reader

·         BNKRECW.cbl – The XML Writer

·         BNKRECWC.cpy - The copybook to support the API to the XML Writer

·         BNKRECWT.cbl - The Test Harness for the XML Writer

 

Step 6: Test the Generated Handlers

The generated COBOL source code can be can be compiled in the same manner you compile your other COBOL programs.  The Test Harness programs are fully functional standalone programs that can be run to test the XML Handlers.  Depending on your platform, you may find that minor changes to the Test Harness and JCL will be required to support the file processing. 

The Writer Test Harness program uses dummy data as content for the XML instance it creates.  Open the BNKRECWT.cbl program and change the following line:

From:

MOVE "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" TO BANK-Name-0005

MOVE 9 TO BANK-Name-len-0006

To:
            MOVE "Your Company Name" TO BANK-Name-0005

            MOVE 30 TO BANK-Name-len-0006

These changes, compile all open files, and run BAXSDWT.cbl. (the test harness). It should produce BAXSD.xml.
The generated XML file will look like:

 

Run BNKRECRT.cbl. The XML Reader will be invoked by the test harness which will then read the same XML document back into COBOL.