XML – the savior of read anywhere data formats, the biggest thing since the text file, and the replacement for EDI formats around the globe. Yet to most of us, almost useless.
In the AS/400 world we relied heavily on standard data formats (EdiFact, Preminos to name but a few) to transmit data in recognisable formats for years. The standard was not hard to follow and served its purpose well. These days nearly all systems have XML interface sockets that allow you to plug in data as required. Within these pages we have discussed using XML and XSL to relay spool file data, but so far we have not been faced with a real application that makes our eyes open in the AS400 iSeries arena.
Craig Rutledge Jr., who, along with input from Martin (DBG400) Rowe, has come up with a unique and powerful source transfer utility that allows the creation of groups of source objects into XML format. The source, attributes and even creation commands are all provided in an XML document that can be transferred via the web, email, disk or whatever means you deem fit.
The starting portion of the code contains the source code necessary to generate the parser, that will in turn, generate the program or other objects being transferred. What is more, Craig offers the XML generator and XML parser as freeware, so you can use the same technique to bundle and distribute your own source code.
How easy is it?
Very. The first thing to do is download one of the many .zip files available from Craig’s site. Inside the .zip file is a single XML file that is to be copied to a source member on the AS/400. I used a FTP transfer to put the XML into a source member. The XML has an embedded DTD (Data Type Definition) embedded into each file for XML validation purposes.
Once you have the XML in a source member, you will need to copy out the XML parser program into its own source member. The code is easily identifiable as the data between the “<install_program>” XML tags.
Once the install program source has been extracted, just follow the compile instructions and you have a ready made parser for any of Craig’s tools and utilities. This should now be sufficient to parse and compile automatically any source member package built by the XMLGEN utility.
The first program I downloaded from Craig’s site is the XML generator. This now allows me to create my own software packages in XML format. So after creating the XML parser, it is a simply a case of running the parser over the XML package to create the generator.
The first version of Craig’s XMLGEN (Generate XML) command used a simple file to store the details of the package that was created. This was soon replaced (in less than a week!) with a simple utility for building the details of a package in CLP members. The CLP member contains the details of all the source members to be included, as well as a unique function for adding additional commands.
The command scripting part was developed by Martin Rowe, which provides three very simple commands:
- XMLGENINC – Include the source for the XML deconstruct program (*YES/*NO)
- XMLGENMBR – The source library/file(member) plus destination, attribute, and auto generate details
- XMLGENCMD – a command that lets you create ad-hoc commands to be used in the object creation process
In very simple terms, this means that packages can be built (and rebuilt) based on details retrieved from a CLP source member. Putting this into practice, the simplest of the commands (XMLGENINC) tells the XML generator whether to include the parser. Remember the parser only needs to be built once.
The XMLGENMBR command allows you to tailor the generation to be extremely specific with the extraction of the data, remembering that the attributes will be used at the re-creation stage:
XMLGENMBR XMBR(XMLGEN) XMBRATR(CLP) XFROMSRCF(JCLSRC) + XFROMSRCL(JCRCMDS) XTOSRCF(QCLSRC) + XOBJTYPE(*PGM) XGENCRT(*YES)
The XMLGENCMD allows any command to be imbedded within the command parameters, for example:
XMLGENCMD XCMD(ADDBNDDIRE BNDDIR(&TOLIB/A) + OBJ((&TOLIB/QASDD)))
Note that the command also supports a variable &tolib. This can be overridden at re-creation time so that the library specified on the re-creation command is the library that will contain the objects.
Which commands can be included in the package? Easy answer, all of them!
So, if you haven’t got the general picture yet, what Craig and Martin have developed is a easy to use, fully configurable, source distribution method that will create objects from source, execute any imaginable command, that allows support for all object types, overrides, creation/stopping/starting of subsystems, binding to anything that is bindable, etc. etc. What’s more, it comes in a simple, readable, compressible, distributable, generally able format! And it is free!
The next step is to fire up the (fully help text documented) command:
Press enter when you have filled in your command options and in a flash shortly you have a XML package ready for distribution to wherever! Want to see the result?
Where do we go from here?
As Craig points out, the method is very simple indeed, and opens up possibilities for extracting and populating other database files easily. Perhaps too easily!
For source and object distribution it opens new possibilities as is. Craig’s main intention is for distributing code easily from his web site, but I am starting to think ahead in terms of application usage. Anybody seeing a use here and starting to put the seeds of a an application framework together should speak up and combine forces with Craig.
We believe this to be a world’s first, and I am sure we will be seeing a lot more of this mentioned in the near future.