few years ago Kurt Cagle wrote an article discussing how to convert fixed-width text records to XML
, a more malleable format, making it possible to use XSL and XSLT to further transform those records into almost any format needed. Kurt's article was educational, an excellent solution, and a fun project to play with, but in the long run, writing tedious and repetitive data transformations manually is a poor business solution. This is where GoXML Transform Designer
GoXML is a relatively new product on the market that simplifies working with flat files to help step up your data integration projects. The application requires a recent version of the JRE, but the install package checks your system and gives you the option to choose a local JRE if you already have one installed, or install one if you don't.
|Figure 1. CSV Subscriber List: This sample CSV file is a straightforward list of subscriber records with column names in the first line.|
In this article, I'll show you how to use GoXML to reduce the process of transforming flat-files into a required XML format to a few mouse clicks and keyboard strokes. All the files used and created in this sample are included in the downloadable sample code
A Transformation Scenario
This example scenario uses a flat-file list of Web site subscribers. Each line includes a subscriber ID, name, e-mail address and a "yes" or "no" field that indicates whether the subscriber opted-in to receive e-mail notifications. The information was collected at a conference, so the data is in Comma Separated Value (CSV) format, and includes column headers in the first line (see Figure 1
|Figure 2. Template XML Format: After transforming the CSV file shown in Figure 1 into XML, you should have a list of subscribers in the format shown here.|
In this scenario, the company's subscriber import tool requires the data to be in XML format, so you need to create a mapping to transform this CSV data into a specific XML format. The source data file is named subscribers2.csv
and the target data, or template, is mailingList.xml
(see Figure 2
). The target data format includes a root node of <subscribers>
that contains a list of <subscriber>
child nodes for each user in the mailing list. Each subscriber has firstName
elements that correspond directly to the fields in the CSV file. After completing the transformation you want to save the results as mailingListFinal2.xml
|Author's note: The names for the sample data in this scenario and sample project were created with a name generator, so any name, similar or actual to anyone real, is purely coincidental.