Mapping a Flat Structure to a Hierarchy
I have written at least one preprocessing program for the very real problem of mapping a flat structure to a hierarchy. Some low-end bookkeeping systems export invoices one line item at a time, with each line item containing all the information about the invoice. Each line in the file has the same format. This is the basic organization of the files handled by our CSVToXML converter in Chapter 7. So, how do we turn something like this into a more conventional invoice with a header section and a detail section for each line item? It's really not very difficult.
Here's our source file. It's an example invoice from Chapter 7 with two line items.
Source (FlatToHierarchy.xml)
<?xml version="1.0" encoding="UTF-8"?> ... |
Get Using XML with Legacy Business Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.