I have found how to retrieve the Java objects created after the CSV content has been binded to POJO.
I will contact Claus in order to add a new Class in Camel-smooks extra project to map CSV with JAVA Beans. Question : Should we have to provide the class name to bind to CSV as a parameter of the SmooksCSVDataFormat() ? Charles cmoulliard wrote: > > By reading the smooks documentation > (http://www.smooks.org/documentation/documentation-smooks-1-1-x/structured-data-event-stream-processing-with-smooks-v1-1) > I have discovered that it is possible to bind csv to POJO. > > Here is an example : > > <?xml version="1.0"?> > <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" > > xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.1.xsd"> > > <csv:reader fields="firstname,lastname,gender,age,country" > separator="|" quote="'" skipLines="1" /> > > <jb:bindings beanId="customerList" class="java.util.ArrayList" > createOnElement="csv-set"> > <jb:wiring beanIdRef="customer" /> > </jb:bindings> > > <jb:bindings beanId="customer" class="com.acme.Customer" > createOnElement="csv-record"> > <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> > <jb:value property="age" data="csv-record/age" > decoder="Integer" /> > </jb:bindings> > > </smooks-resource-list> > > 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. > > KR, > > Charles > > James.Strachan wrote: >> >> 2008/12/11 cmoulliard <[email protected]>: >>> >>> 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 >> ------- >> http://macstrac.blogspot.com/ >> >> Open Source Integration >> http://fusesource.com/ >> >> > > ----- Charles Moulliard SOA Architect My Blog : http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/ -- View this message in context: http://www.nabble.com/Is-there-a-way-to-extend-marshall-method-of-CsvDataFormat-class-tp20955830s22882p20975714.html Sent from the Camel - Users mailing list archive at Nabble.com.
