camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmoulliard <>
Subject Re: Is there a way to extend marshall method of CsvDataFormat class
Date Fri, 12 Dec 2008 10:28:39 GMT

By reading the smooks documentation
I have discovered that it is possible to bind csv to POJO.

Here is an example :

<?xml version="1.0"?>
<smooks-resource-list xmlns=""

   <csv:reader fields="firstname,lastname,gender,age,country" separator="|"
quote="'" skipLines="1" />

     <jb:bindings beanId="customerList" class="java.util.ArrayList"
            <jb:wiring beanIdRef="customer" />

        <jb:bindings beanId="customer" class="com.acme.Customer"
            <jb:value property="firstName" data="csv-record/firstName" />
            <jb:value property="lastName" data="csv-record/lastName" />
            <jb:value property="gender" data="csv-record/gender"
decoder="Enum" >
            <jb:decodeParam name="enumType">com.acme.Gender</jb:decodeParam>
            <jb:value property="age" data="csv-record/age" decoder="Integer"


I try to test this to see how I can extract the POJO because the result
coming from smooks.filter(inputstream, result, executioncontext) method is
of type :
- DOMResult,
- SAXResult,
- StreamResult

Remark : The only regret that I have is that everything is mapped by Smooks
in SAXEvents or DOMEvents. So additional step is required to handle the
result (when this is not XML). I think that it is time to create a project
JAnXB (Java Api for non XML binding) using the same concept as JAXB2 to bind
data with POJO using annotations. 



James.Strachan wrote:
> 2008/12/11 cmoulliard <>:
>> One question :
>> In case, we would like to use smooks to bind CSV content to Java Objects
>> :
>> Shall we have to transform CSV to XML and next XML to Java or can I
>> directly
>> bind the SAX events generated by smooks (after reading my CSV file) to
>> java
>> objects using <jb:wiring> <jb:binding> ?
> I dunno - we need a Smooks expert to comment really - but if Smooks
> can go from CSV -> Bean then I'd say we just let Smooks do that?
> -- 
> James
> -------
> Open Source Integration

Charles Moulliard
SOA Architect

My Blog :  
View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message