I have an XML file that describes a header and a list. I need to generate a CSV file where the first line of the file is constructed from the header information and the subsequent lines of the file constructed from the list. The header has a different number of columns to the list items.
This is easy to do with xsl. How can I do it with the data mapper using the .NET mapping engine?
A simple example to explain. XSD of input xml
<xs:element name="A" />
<xs:element name="B" />
<xs:element name="Line" maxOccurs="unbounded">
<xs:element name="C" />
<xs:element name="D" />
<xs:element name="E" />
An Example Input XML
Required Text Output:
as individual csv files is easy (as it should be) but how can I can't see how to produce the required file.
I have considered working around and generating a sequence of strings for each line. In this case I cannot see how to push the header onto the front of the sequence. If I use 'sequence', it flattens the list of lines (If this workaround was possible my objection would be that the semantics of the data are lost.)
I don't think this is a particularly obscure thing to want to do. At present, because of the ability to visually map data, we want to recommend Liquid to our customers as a solution to some of their EDI problems. Not having this facility blocks that process.