You are currently on IBM Systems Media’s archival website. Click here to view our new website.


Whats All the Fuss About XML?

At most of the conferences where we speak, as well as private classes we conduct, one of the most requested topics is XML - what is it and how do we deal with it in our RPG applications? So this month, we'll discuss the first of those questions.


XML stands for eXtensible Markup Language. Let's begin with a definition of a markup language, and then we'll see why this one is considered "extensible." A markup language is one where the data and information or instructions dealing with that data are intermixed. This is in contrast to a language like RPG where the logic instructions operate on a separate source of data, such as files or parameters. The most widely used markup language is HTML, where the markups, often referred to as tags, are used to specify how the data should look - for example whether it should be in bold or italics, the font, the color, whether it's a table or a paragraph, etc. HTML is, of course, the primary language utilized by browsers.

XML, on the other hand, is a language used to exchange data between programs. Therefore its tags are used to describe the content and structure of the data. That means the owner or originator of the data defines their own tags for a given document type. XML is really a language for creating other languages - hence the "extensible" description.

If you've never seen an XML document, imagine what the output of Display Physical File Member (DSPPFM) would look like if the field names were inserted at the beginning and end of each field. You could much more easily identify the content of each field without the need of a separate external file description from which you would work out where in the record each field begins and ends. If you can imagine that, you've just envisioned the basics of an XML document.

Of course, in our database files, we have only "flat" record data, whereas in our programs, we can have structures of data and repeating data in arrays. XML data has the flexibility to have structures (like RPG data structures, including nested data structures) and arrays. So an XML document is rarely as simple as the imagined DSPPFM output described above.

Why is a language needed to exchange data between programs? Why not simply pass parameters or exchange data in files? The idea of using XML to exchange data is that it's a ubiquitous language that can be processed by programs in any language on any platform. It relies on no particular operating system, programming language or database management system. It's used in place of traditional EDI applications to pass data between systems, and it's used in service-oriented architecture (SOA) applications to pass data to and from a service (an application function) on another system, much as we traditionally pass parameters between RPG programs.

Let's look at a simple XML document and review the syntax of the language. It doesn't take long because the syntax rules are very simple, however, they're stringently enforced.

<?xml version='1.0'?>
  <Contact>Sally Smith</Contact>
  <Company>Acme Computer Supplies</Company>
  <Address Type="Shipping">
   <Street>1234 Jones St</Street>
  <Address Type="Billing">
   <Street>4567 Main Street</Street>
   <Zip>55901</Zip>   </Address>

<Company>Phones R Us</Company>
<Address> <Street>5678 High Street</Street>
<City>Mytown</City> <State>GA</State>
<Zip>30033</Zip> </Address> </Customer>


Jon Paris is a technical editor with IBM Systems Magazine and co-owner of Partner400.

Susan Gantner is a technical editor with IBM Systems Magazine and co-owner of Partner400.



2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

Are You Multilingual?

Rational enables development in multiplatform environments

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters