You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "shekher.awasthi" <sh...@gmail.com> on 2011/08/25 09:42:14 UTC
Passing input fileName along the complete route
Hi All,
While working i came across a requirements where i have to name the final
output file based on the input file
e.g
if the name of the input file is a.xml and i need to convert it to csv at
the end than the output file should be named as
customoutput_a.xml.csv
like in my case i have the following route
<route id="demo">
<from uri="{{demo.filePath}}"/>
<choice>
<when>
<simple>${file:ext} == 'csv'</simple>
<unmarshal>
<csv/>
</unmarshal>
<to uri="bean:converter?method=process" />
<to uri="file://data/output?fileName=tmpXML.xml" />
</when>
</choice>
<to uri="{{demo.tmpXMLtoStandardXML}}"/>
<to uri="file://data/output?fileName=3_StandardXML.xml" />
<to uri="{{demo.StandardXMLToImpexXslFile}}"/>
<to uri="{{demo.targetXMLFile}}"/>
</route>
now in such case in the last route point i have to name the file based on
the input file name, can any one help me how i can pass the input file name
throughout the route in camel so that i can extract the file name when
producing final output
Thanks in advance
--
View this message in context: http://camel.465427.n5.nabble.com/Passing-input-fileName-along-the-complete-route-tp4733437p4733437.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Passing input fileName along the complete route
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
See the file language (its part of the simple language)
http://camel.apache.org/file-language.html
So in the to endpoint you can use a simple expression to define the file name
For example something like:
<to uri="file:dir?fileName=something-${file:onlyname}"/>
On Thu, Aug 25, 2011 at 9:42 AM, shekher.awasthi
<sh...@gmail.com> wrote:
> Hi All,
>
> While working i came across a requirements where i have to name the final
> output file based on the input file
> e.g
> if the name of the input file is a.xml and i need to convert it to csv at
> the end than the output file should be named as
> customoutput_a.xml.csv
> like in my case i have the following route
>
> <route id="demo">
>
> <from uri="{{demo.filePath}}"/>
>
> <choice>
> <when>
> <simple>${file:ext} == 'csv'</simple>
> <unmarshal>
> <csv/>
> </unmarshal>
>
> <to uri="bean:converter?method=process" />
> <to uri="file://data/output?fileName=tmpXML.xml" />
> </when>
> </choice>
>
> <to uri="{{demo.tmpXMLtoStandardXML}}"/>
> <to uri="file://data/output?fileName=3_StandardXML.xml" />
> <to uri="{{demo.StandardXMLToImpexXslFile}}"/>
> <to uri="{{demo.targetXMLFile}}"/>
> </route>
>
> now in such case in the last route point i have to name the file based on
> the input file name, can any one help me how i can pass the input file name
> throughout the route in camel so that i can extract the file name when
> producing final output
>
> Thanks in advance
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Passing-input-fileName-along-the-complete-route-tp4733437p4733437.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/