0

I have a csv file and I have to convert it to a an xml with smooks, my csv file has this format:

firstname,lastname,gender,age,country

and I have to trasnform it to

<Message>
<record>
<name>firstname</name>
</record>
...
</Message>

I wrote my smooks configuration as:

<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
    xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.4.xsd"
    xmlns:csv="http://www.milyn.org/xsd/smooks/csv-1.2.xsd"
    xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd">

    <csv:reader fields="firstname,lastname,gender,age,country"
        separator=",;" rootElementName="Message" recordElementName="record" />

    <ftl:freemarker applyOnElement="Message">
        <ftl:template>
        <!--
            <ImageMessage>
                <record>${Message.record.firstname}</record>
            </Message>
         -->
         </ftl:template>
    </ftl:freemarker>

    <core:exports>
        <core:result type="org.milyn.payload.StringResult" />
    </core:exports>

</smooks-resource-list>

But that trow an error. If I delete the part of my code, than the basic transformation to xml works, so I suppose I'm using ftl in the wrong way. Any help?

ddelizia
  • 1,571
  • 5
  • 30
  • 54

1 Answers1

2

You have to bind it to a java object before using FreeTemplateMarker.

Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
C.Johnson
  • 180
  • 1
  • 1
  • 7