This utility provides the reverse functionality of the one we developed in the previous chapter. The file organization and rationales are the same.

The general requirement for this utility is to convert a CSV file to an XML instance document. Design considerations dictate that the XML document is of a specific format, that is, a specific XML grammar. Supporting more than one grammar for the output document will make the code a lot more complicated. Our output document may be transformed into other XML grammars using XSLT. The sample output shows both the direct output of the utility and what it might be transformed into using XSLT. The list below summarizes the required functionality.

  • Input : A CSV file in uniform Row/Column organization, that is, each row has the same column entries.

  • Processing : Each input CSV row is written to an Element named Row in the output XML document. Each column in the row is written to a child ColumnXX Element in the output XML document, where XX represents the column number. Quotation marks bracketing text and delimiting commas are discarded. Columns without content don't generate Elements.

  • Output : An XML instance document in a single file. The root Element is named SimpleCSV, with children Row and ColumnXX children of the Row.

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

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: