简体   繁体   中英

How to format and sort CSV to Xml using Mule?

I have a CSV file that looks like this:

2013-12-16 08:48:24,236;4B414D000000011613C3;SignalStrengthIndication=21;CellIdentity=2256; 2013-12-16 09:48:24,236;4B414D000000011613C3;SignalStrengthIndication=19;CellIdentity=2254;

as you can see the Uid 4B414D000000011613C3 will apear multiple times. I now want to use Mule studio to transform this CSV into XML format but I want the Uid to appear only once so the XML will look something like this:

<Root>
<MeterUID>4B414D000000011613C3</MeterUID>
   <GSMdata>
    <TimeStamp>2013-12-16 08:48:24,236</TimeStamp>
    <SignalStrengthIndication>21</SignalStrengthIndication>
    <CellID>2256</CellID>
   </GSMdata>
   <GSMdata>
    <TimeStamp>2013-12-16 09:48:24,236</TimeStamp>
    <SignalStrengthIndication>19</SignalStrengthIndication>
    <CellID>2254</CellID>
   </GSMdata>
</Root>

How would I achieve this in Mule?

I solved a similar problem in two steps. The first step consisted in transforming the CSV into an intermediate XML using Smooks. The second step used an XSL transformer to create the required XML from the intermediate XML.

The idea was taken from here:

http://pragmaticintegrator.wordpress.com/2010/04/29/using-smooksmule-to-transform-csv-file-to-xml-one/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM