You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "ambarish.d" <d....@gmail.com> on 2012/07/20 15:11:05 UTC

Re: Converting CSV to XML

Hello Claus,

Thanks for the help. Bindy was really helpful. 
I am still using xstream though, its lot more easier (I feel).

Giving the working solution of this problem if anybody needs one.

 /DataFormat bindy = new BindyCsvDataFormat("com.your.package.dto");
            		 from("file://TEST?fileName=Employee.csv").
	                    unmarshal(bindy). 
	                    marshal(). 
                        xstream(). 
                        to("file://TESTOUT?fileName=employee.xml"); /


This works as expected. /"com.your.package.dto.EmployeeDTO"/ has to be
annotated properly to make this work.

List of dependencies:

camel-bindy-2.9.0.jar, camel-core-2.9.0.jar,camel-csv-2.9.0.jar,
camel-xstream-2.9.0.jar,
slf4j-api-1.6.4.jar, slf4j-log4j12-1.6.4.jar,
solr-commons-csv-1.3.0.jar,xstream-1.3.1
  




-----
thanks
Amby
http://workingwithqueues.blogspot.com/ 
--
View this message in context: http://camel.465427.n5.nabble.com/Converting-CSV-to-XML-tp5711086p5716294.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Converting CSV to XML

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Sep 26, 2012 at 8:33 PM, German O <ge...@gmail.com> wrote:
> Hi, Is there a way to do this without passing throw a model?... just read the
> csv, and put in the that format?..
>
> My case is that the csv can change the columns, and then I have to output
> another xml, so I use a xsl to translate to the final XML.
>
> The idea is to put the csv into a simple XML like the one described here,
> and with that simple format, I can easy do the xsl to create the final xmls.
>

You can use a bean or template engine to transform the file input to
your XML like structure.
Can turn the file into a List<List> which you can then loop in the
template to output the xml.

Some template engines are:
http://camel.apache.org/velocity
http://camel.apache.org/freemarker

Using a bean is of course just plain java code, and you can then make
the xml structure in code.

Using a CSV component like
http://camel.apache.org/csv

And there is other CSV and XML related components / data format
http://camel.apache.org/data-format.html


> thanks.
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Converting-CSV-to-XML-tp5711086p5720047.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Converting CSV to XML

Posted by Christian Müller <ch...@gmail.com>.
Use the file component to read the file, access the in message body and do
what ever you need to do.

Best,
Christian

Sent from a mobile device
Am 27.09.2012 07:38 schrieb "German O" <ge...@gmail.com>:

> Hi, Is there a way to do this without passing throw a model?... just read
> the
> csv, and put in the that format?..
>
> My case is that the csv can change the columns, and then I have to output
> another xml, so I use a xsl to translate to the final XML.
>
> The idea is to put the csv into a simple XML like the one described here,
> and with that simple format, I can easy do the xsl to create the final
> xmls.
>
> thanks.
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Converting-CSV-to-XML-tp5711086p5720047.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Converting CSV to XML

Posted by German O <ge...@gmail.com>.
Hi, Is there a way to do this without passing throw a model?... just read the
csv, and put in the that format?..

My case is that the csv can change the columns, and then I have to output
another xml, so I use a xsl to translate to the final XML.

The idea is to put the csv into a simple XML like the one described here,
and with that simple format, I can easy do the xsl to create the final xmls.

thanks.




--
View this message in context: http://camel.465427.n5.nabble.com/Converting-CSV-to-XML-tp5711086p5720047.html
Sent from the Camel - Users mailing list archive at Nabble.com.