Requirements


For desktop applications, the most commonly supported format for importing and exporting data is the comma-separated value format. So, it makes a lot of sense to develop a utility that converts XML documents to CSV files.

The general requirement for this utility is to convert an XML document to a CSV file. Design considerations dictate that the XML document is of a specific format, that is, that it complies with a specific XML grammar. XML documents in other formats may be transformed into this format using XSLT. Here's a summary of the required functionality.

  • Input : An XML instance document in a single file. The root Element may have any name . The root Element has one or more child Elements named Row, each representing a row in the target CSV file. Each Row Element has one or more child Elements that represent the columns in the row. These are named ColumnXX, where XX is the column number, with a leading number 0. The ColumnXX Elements are simple Elements with text context. The rationale for this grammar is given in the Design section later in this chapter.

  • Processing : Each input Row Element is written to a record in the CSV output file, with the ColumnXX Elements written to the appropriate column numbers . Text content of the columns is enclosed in quotation marks. Commas are inserted as field delimiters.

  • Output : A CSV file in Row/Column organization.

One qualification needs to be made here. In the strictest terms, the XML instance document does not have to be entirely contained within a single disk file. It may contain external entities that are defined in other XML documents in other disk files. However, this is so uncommon for most of the applications for which this book is targeted that I will stay with the generalization that we process a single XML instance document in a single file.

Why the Lowest Common Denominator?

CSV-formatted files are sometimes called the lowest common denominator for data exchange. This means that most applications that are able to export or import data will at least support CSV files. But why do we say lowest common denominator? In mathematics, the least common denominator is always the number 1. Don't we really care about the greatest common denominator, or the highest or best thing that is common? English is a funny language!



Using XML with Legacy Business Applications
Using XML with Legacy Business Applications
ISBN: 0321154940
EAN: 2147483647
Year: 2003
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net