Talend Data Mapper - No examples of a flat file to complex XML
Hi I have been working on a flat file to complex XML structure with nested loops. My flat file has all of the data in a format which means there is a lot of replication. SO for every field in the XML document, there is a column in my flat file. This means that fields that occur once in the XML are repeated in the flat file for every loop that occurs in the XML. See below for a very basic example..... Expected XML <xml> <head1>head1</head1> <head2>head2</head2> <loop1> <data> <value1>value1a</value1> <loop2> <value2>value2a</value2> <value2>value2b</value2> <value2>value2c</value2> </loop2> </data> <data> <value1>value1b</value1> <loop2> <value2>value2d</value2> <value2>value2e</value2> <value2>value2f</value2> </loop2> </data> </loop1> </xml> Source File head1,head2,value1a,value2a head1,head2,value1a,value2b head1,head2,value1a,value2c head1,head2,value1b,value2d head1,head2,value1b,value2e head1,head2,value1b,value2f
I also have to enable several documents to be produced. So if you take the example above and add another column which would indicate a new file. For example.... file1,head1,head2,value1a,value2a file1,head1,head2,value1a,value2b file1,head1,head2,value1a,value2c file1,head1,head2,value1b,value2d file1,head1,head2,value1b,value2e file1,head1,head2,value1b,value2f file2,head3,head4,value1a,value2a file2,head3,head4,value1a,value2b file2,head3,head4,value1a,value2c file2,head3,head4,value1b,value2d file2,head3,head4,value1b,value2e file2,head3,head4,value1b,value2f Now the problem I have is that the Data Mapper is useless. OK, it might not be useless, but it is really badly documented, is not consistent with the rest of the tool, does not use the same terminology, does not use the same way of working, and errors with every attempt to get it to work. I have to say that I am tempted to just use JAXB to do this, but thought I would persevere. The big problem I have is that it falls over with looping issues on data that is not supposed to loop. So, because my headers (head1, head2, etc) are repeated with every row, I have to find a way of saying that I only want 1 value per group (lets say the group key is "file" for this). But there doesn't appear to be a function which does this....or at least they are not named in any way to aid in discovery. I am also wanting to produce multiple XML files (based on the "file" field) and everything I have read about this makes about as much sense as a toddler trying to read Chaucer. As you can tell, I am literally pulling my hair out here trying to do something that should be simple, should be a standard example and should have loads of examples online. But there is absolutely nothing to crib from. All of the examples using XML are reading from XML to another format and the example structures are so simple, there is no real need for the examples. So, does anyone know of any examples, maybe have an example they could send me, or maybe know of decent tutorial which explains this? Or do I have to use JAXB and code it in Java?
Re: Talend Data Mapper - No examples of a flat file to complex XML
I am working on a similar requirement, trying to create a json document with nested arrays instead of XML. Data mapper documentation is not great. It would be great if some from Talend provide an example or solution for this issue.