[use case] Csv2Xml
Description
The Csv2Xml use case illustrates the csv task in a file2file usage : transformation of csv datas to xml.
It may be easily extended to set2file and set2set usages.
Sample
Transform csv datas to xml.
$ tree --charset=ascii file2file/
file2file/
|-- build.xml
|-- gen
| `-- xml
| `-- out.xml
|-- src
| `-- csv
| `-- in.csv
`-- templates
`-- csv2xml.ftl
ant file - build.xml
<project name="usecases" xmlns:bj="antlib:org.bidji.taskdefs">
<target name="csv2xml" description="transform csv to xml">
<bj:csvt file="in.csv" tofile="out.csv" template="csv2xml.ftl" overwrite="true"/>
</target>
</project>
input file - in.csv
id;label;content
t01;Task #01;Todo1...
t02;Task #02;Todo2...
csv2xml.ftl
<?xml version="1.0"?>
<todolist>
[#foreach line in csv?api.lines()]
<task id="${line.id}">
<label>${line['label']}</label>
<content>${line.content}</content>
</task>
[/#foreach]
</todolist>
out.xml
<?xml version="1.0"?>
<todolist>
<task id="t01">
<label>Task #01</label>
<content>Todo1...</content>
</task>
<task id="t02">
<label>Task #02</label>
<content>Todo2...</content>
</task>
</todolist>