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