[Editor's note: XML is an important data exchange technology that can use a focused tool suite for HP 3000 customers. The entry that follows explains how the latest XML solution gets the job done in the MPE/iX enterprise. Making a business case for using XML is detailed on our Nov. 27 entry.]
By Peter Prager
XML, which is a self-documenting, flexible data format, should give organizations an edge by providing reusable and repeatable standards which can be utilized throughout their business processes. XML Thunder, an XML suite from CanAm Software, visually enables all data mapping, conversion and error handling required for reliable XML-processing. This frees up developers to focus on business issues — a time-saving advantage when compared to compiler-dependent solutions.
XML has many benefits, but it is a complex technology featuring hundreds of rules. XML program development is an ideal target for automation as the rules are numerous, but very well defined. An XML handling program must implement all relevant aspects of the W3C rules with stable, efficient code. This code has to provide appropriate handling of simple and complex types, XML structures, features and error processing. More importantly, it has to be robust and reliable in order to handle mission critical data that organizations rely on for their business.
How does it work?
XML Thunder generates COBOL and/or C sub-programs that can be invoked from a main business program. These sub-programs are referred to as XML Handlers. XML Handlers do the actual XML processing on data received from the main program. The mainline interfaces with the XML processing sub-programs through a special data area called the Interface Data Structure or IDS.
There are two types of XML Handlers, XML Readers and XML Writers. An XML Reader is used when the content of an XML document needs to be made available to and processed using traditional COBOL or C data structures. When using an XML Reader the mainline may obtain the XML document in any manner which is suitable, e.g. MQ, RDBMS or a sequential file. Once the XML document is held in memory, the mainline will pass it to the XML Reader subprogram that was generated using XML Thunder. The XML Reader will parse the content of the XML document according to the design time rules and will pass the content back to the mainline in regular data structures for further processing.
An XML Writer is called from the main business program. Then an application needs to create an XML document. The main program will pass data using regular data structures to the XML Writer, which will construct the XML document from the data based on design time rules specified.
The generated code is entirely ANSI COBOL/C source code, without any hidden runtimes or executables.
Think of XML Thunder’s flow as consisting of three major steps: Select, when files are selected containing the XML schema/DTD and/or COBOL/C structures; Bind, when COBOL/C variables are mapped to the desired XML nodes; and Generate, when COBOL or C program code is generated implementing the XML Reader/Writer design.
XML Thunder allows developers to import existing files to assist with the creation of the XML Handler definition. These files can be either from the COBOL/C or from the XML world.
COBOL/C files could be COBOL copybooks, a COBOL program or a C header file. The COBOL/C (known as IDS) data structure will be created based on the XML information.
Document Type Definition (DTD)
Derive from IDS
The XML data will be created based on the COBOL/C (IDS) information.
Or still, a combination of the files above, or no files at all (the XML Handler will be created from scratch by the user)
Once the XML Handler definition is created based on the files imported, the developer needs to map the COBOL/C variables with the XML nodes. This is easily done using the graphical interface, through drag-and-drop.
XML Thunder will try to create the mapping, depending on the combination of files used in the selection step. If the imported file is an XML Schema (XSD) or DTD, then the corresponding COBOL/C data structures (IDS) will be automatically derived. XML Thunder creates all necessary IDS fields based on the XSD/DTD, and then maps each XML node to its corresponding COBOL/C field.
XML Thunder can also derive the XML Schema (XSD) from an existing COBOL/C data structure. To simplify things further, a wizard assembles an IDS from an existing COBOL program’s working storage by simply pointing and clicking. When deriving an XSD from existing data structures, XML Thunder also performs automatic mapping of the XML nodes and COBOL/C fields. Of course, these mappings can be deleted or easily changed if desired.
When both the COBOL/C data structures and the XSD/DTD are provided, then developers can perform manual mapping.
These features of XML Thunder maximize automation yet preserve flexibility, resulting in developers’ complete control over the XML Handler design. Once the XML Handler is designed, the next step is source code generation.
During code generation the actual COBOL or C sub-program, implementing the design time mapping rules, is generated. The generated XML Reader or XML Writer subprograms can then be integrated with the main business program to parse or create the appropriate XML documents. An Integration Wizard makes the task of integrating these handlers quick and easy.
With a few exceptions, the same XML Handler definition can be used to generate COBOL or C language code and as either an XML Reader or an XML Writer.
Once the appropriate XML Handler is generated and the mainline program changed to call it, they can be uploaded to the appropriate target platform, compiled, linked and tested.
Peter Prager is Director of XML and Reporting Solutions for Canam Software Labs. For more information about XML Thunder and to download a free trial, visit the Canam Web site at www.xmlthunder.com. The company also offers an online walkthrough of the solution at its Web site.