lt IE 9]>lt IE 9]>lt IE 9]>
Thunder Suite   •  JSON Thunder   •  XML Thunder   •  FAQs   •  Tutorials   •  Wiki   •  Levelset History   •  JSON Thunder Technical Details   •  XML Thunder Technical Details

Thunder Wiki for Thunder Suite, JSON Thunder & XML Thunder

Creating an XML Handler

Overview»

XML Thunder generates COBOL or C source code for Reading and / or Writing XML instances. Using the XML Thunder toolset, you create an XML Handler design that specifies the mapping between program data fields and XML nodes and the data validation rules that should be applied.

The following section will walk you through creating and generating an XML Handler to give you a quick overview of how XML Thunder works.

Launch the New Handler Design Wizard»

To create a new XML handler, launch the XML wizard by either clicking on XML Handler > New… from the menu or click on the icon on the tool bar (see below)

Image

Select the source for the XML and Program Data Field Structures»

An XML Thunder Handler design is based on a mapping between program data fields (called an IDS) and XML nodes. To create a new XML Handler, you begin by specifying the source for these two data structures. You can choose from a number of possible IDS and XML combinations, but for this example choose “Derive fom XML” for the IDS and “XML Structure -> XSD”. Prompt out and select the BAXSD.xsd schema from the tutorials folder where XML Thunder was unstalled (e.g. c:\program files\canam\XML Thunder\Tutorials\BAXSD.xsd).

Image

Specify the XML Handler Properties»

Some schemas can have more than one possible root element. This schema has only one possible root though so we can accept the default.

Image

Summary»

The Summary window lists the selections made. Click “Finish” to confirm the selections and create a XML Handler design.

Image

The Handler design»

When you click on “Finish”, XML Thunder will use your selections to create the Handler Design. In this case, the XML structure and validation rules have been created using the selected schema and any subordinate schemas it imported. The program data fields – also called Interface Data Structure (IDS) – were derived from the XML nodes. The mappings between the XML nodes and program data fields were done automatically.

Image

Generate the Handlers»

From the Handler design, you can now generate either an XML Reader or an XML Writer. You can also optionally choose to generate a Test Harness for testing and an IDS (COBOL copybook or C Header) file.

XML Reader Generation Tab

Image

XML Writer Generation Tab

Image

If you choose to generate both an XML Reader and an XML Writer - as well as the Test Harnesses and header files, then 6 source code files will be created.

Image

XML Reader Source Code»

For an XML Reader, the following code has been generated:

BAXSDR – The XML Reader module. This is a C code sub-program. You call this program passing it the XML document in a variable (called XML-BUFFER). The Reader validates the document, parses the nodes into C structures (called the Interface Data Structure or IDS) and then returns these structures back to the calling program.

BAXSDRT – The XML Reader Test Harness. This is a fully functional program used to test the XML Reader. It can read in an XML file, or create one inline using dummy data values. The Test Harness passes the XML document to the XML Reader via the XML-BUFFER variable. It receives back the parsed content in the IDS (i.e. C structures). Note: The Test Harness is optional. It gives you a great way to quickly test your XML Reader. It also gives you an example of how you would call the XML Reader from your own program.

BAXSDRC – The XML Reader Header File. This is the IDS (i.e. the C structures) used as the API to the XML Reader. This is optional. Neither the Test Harness, nor the XML Reader use the header file. It is generated for your convenience – for use in your programs that will call the Reader.

XML Writer Source Code»

For an XML Writer, the following code has been generated:

BAXSDW – The XML Writer module. This is a C sub-program. You call this program passing it the XML content via the IDS (i.e. C structures). The Writer will validate the content and assemble the XML document. The XML document is returned to the calling program via the XML-BUFFER variable.

BAXSDWT – The XML Writer Test Harness. This is a fully functional program used to test the XML Writer. It populates the IDS (i.e. the program data fields) using dummy data values (x’s for character and 9’s for numeric values). The Test Harness passes the XML content via the program data fields to the XML Writer. It receives back the XML document via the XML-BUFFER variable. Note: The Test Harness is optional. It gives you a great way to quickly test your XML Writer. It also gives you an example of how you would call the XML Writer from your own program.

BAXSDWC – The XML Writer Header File. This is the IDS (C structures) used as the API to the XML Writer. This is optional. Neither the Test Harness, nor the XML Writer use the header file. It is generated for your convenience – for use in your programs that will call the Writer.

Testing the XML Handlers»

Testing the XML Reader: To test your XML Reader, compile the BAXSDRT and BAXSDR programs. The BAXSDRT (i.e. the Test Harness) is the main program. It calls the BAXSDR program (i.e. the XML Reader). The header file is not needed to test the Handler.

Testing the XML Writer: To test your XML Writer, compile the BAXSDWT and BAXSDW programs. The BAXSDWT (i.e. the Test Harness) is the main program. It calls the BAXSDW program (i.e. the XML Writer). The header file is not needed to test the Handler.

Modified on 2013/09/26 16:31 by SuperUser Account