Mapping Your Data to XML the Easy Way

Web Languages
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

We IT folks are never satisfied! We always want more. If we can’t get more, we will attempt to make more out of what we have. This is what makes our industry so great (or horribly complicated and impossible to follow, depending on your attitude). We keep making things better, faster, and more universal. Java is the poster child for the IT way of thinking. Java has become the universal language of programming because of its Write Once, Run Anywhere (WORA) capabilities. Concerns for its speed are being answered everyday in the form of new releases and performance tips. But we want more.

XML to the Rescue

As Java applications began to move data around, it was realized that data representation as portable as the Java language itself was required. Extensible Markup Language (XML) was developed out of need for something that could truly represent data as opposed to simply formatting and displaying data as HTML accomplishes so well. Now, XML is quickly becoming the universal tool for mapping data between databases. It is more than a markup language, as Mark Johnson states in his article “XML for the absolute beginner” ( jw-04-1999/jw-04-xml_p.html), “XML is a metalanguage—a language used to define new markup languages. With XML, you can create a language crafted specifically for your application or domain.” He further states that with XML, you now have “a powerful tool for data representation, storage, modeling, and interoperation.” But we want more.

Did You Check Out the Form on That XML?

A well-formed XML document means that it follows XML standards. What does that mean? Well, compare it to an RPG compiler. A compiler makes sure that the RPG code is syntactically correct: all variables are defined, IF statements have associated ENDIF statements, etc. An XML parser is sort of the compiler for XML. Many vendors offer parsers as free downloads, and they are necessary (unless you want to write your own) to determine if all the tags makes sense and are nested correctly. Well, as some of you may be aware, a program does not necessarily perform properly simply because it is compiled. (A shock to many, I’m sure.) The same holds true for XML. A well-formed document may still contain data that doesn’t match its document type definition (DTD). For an XML

document to be valid, it must be well-formed and contain data that matches the DTD. Mark Johnson says that “The DTD defines the [XML] document type. It accounts for the Extensible in XML. The DTD is how you actually define a new markup language—what I often call a dialect of XML. DTDs currently are being written for an enormous number of different problem domains, and each DTD defines a new markup language.” So, if you create a DTD, or use a standard DTD such as the electronic data interchange standard XML/EDI, along with one of the many parsers available, much of the programming is done for you with regard to extracting data from an XML document. But we want more.

XML and Your Data: Bridge the Gap

IBM’s alphaWorks has developed a tool called XML Lightweight Extractor (XLE) that allows you to create XML documents from your data source without writing detailed access queries to first extract the data before employing other methods to convert the query results into XML. XLE allows you to interpret a given DTD and map it to tables, rows, and columns of your data source. With that, you are then able to extract a well-formed and valid XML document based directly on your data source. The following is a list of features:

• XLE currently supports Java Database Connectivity (JDBC) compliant data sources.

• Given a DTD and a set of tables accessible through JDBC, you can interpret the DTD file to create a mapping file called a DTDSA file.

• When a particular XML document is requested, the user specifies the DTDSA file and zero or more runtime parameters, and XLE will construct the appropriate XML document from the underlying data sources and return it to the user.

• The mapping mechanisms of DTDSA allow XLE to assemble an XML document from a relational table, a set of relational tables related by foreign-key relationships, or more advanced relationships.

You can download XLE from IBM’s alphaWorks site at This product is currently in the development stages and is not yet fully supported by IBM; however, you have the opportunity to download XLE in its alpha state, play with it a little, and share your comments with the alphaWorks team. Additionally, you can see how others rated XLE as well as join an XLE discussion group at www.alphaworks. With Java, XML, XML parsers, DTDs, and the new XLE technology, you now have all the tools necessary for writing business applications that easily cross platform and data barriers. What more could you ask for? I know...silly question.