You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by AINDRILA ACHARYA <ai...@issac.in> on 2014/04/23 14:52:08 UTC

how do I check conditions in XML DSL

I have a CSV file which contain following data:

value1=A,value1=B

My requirement is that :

if value1=A
then go to fileA

if value1=B
then go to fileB

I want to do this using XML DSL.

I am attaching here with my code snippet,by which I can not check the
conditions by using xpath.

How do I write this xpath expression in Camel? 

Any help is greatly appreciated. 

Thanks in advance!


<routeContext id="actionRoutes"
xmlns="http://camel.apache.org/schema/spring">

			
			<route id="route1">
				<from uri="file:E:\\bankappfiles\\received?delete=true" />
				<log message="Title Name [${body}]"/>
				
				<split stopOnException="true">						  
			      <tokenize token=","/>
			      <choice>
			      <when>
			         <xpath resultType="java.lang.String">/value1</xpath>
			      </when>
			     
			      </choice>
			    
			  </split>
				<process ref="fileProcessor" />
			</route>
		
		
			
		
		
	    </routeContext>



--
View this message in context: http://camel.465427.n5.nabble.com/how-do-I-check-conditions-in-XML-DSL-tp5750490.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: how do I check conditions in XML DSL

Posted by Ra...@cognizant.com.
Does your file has only one line with csv seperated values ?

Do you want whole file to be transferred to the other directory based on logic ?

What if two conditions are satisfied on one line ? value1=A and value2=B .....

Here is the example you can start with ... you can use more features of simple language to build your condition.

                <route>
                        <from uri="file://csvfile" />
                        <split stopOnException="true">
                <tokenize token=","/>
                <choice>
                    <when>
                        <simple> ${in.body} == 'value1=A'</simple>
                        <to uri="file://csvfileoutA" />
                    </when>
                     <when>
                        <simple> ${in.body} == 'B'</simple>
                        <to uri="file://csvfileoutB" />
                    </when>
                    <otherwise>
                        <to uri="file://csvfileoutOther" />
                    </otherwise>
                </choice>
                        </split>
                        <to uri="file://csvfileout" />

- Ravi




________________________________________
From: AINDRILA ACHARYA [aindrila.a@issac.in]
Sent: Wednesday, April 23, 2014 6:22 PM
To: users@camel.apache.org
Subject: how do I check conditions in XML DSL

I have a CSV file which contain following data:

value1=A,value1=B

My requirement is that :

if value1=A
then go to fileA

if value1=B
then go to fileB

I want to do this using XML DSL.

I am attaching here with my code snippet,by which I can not check the
conditions by using xpath.

How do I write this xpath expression in Camel?

Any help is greatly appreciated.

Thanks in advance!


<routeContext id="actionRoutes"
xmlns="http://camel.apache.org/schema/spring">


                        <route id="route1">
                                <from uri="file:E:\\bankappfiles\\received?delete=true" />
                                <log message="Title Name [${body}]"/>

                                <split stopOnException="true">
                              <tokenize token=","/>
                              <choice>
                              <when>
                                 <xpath resultType="java.lang.String">/value1</xpath>
                              </when>

                              </choice>

                          </split>
                                <process ref="fileProcessor" />
                        </route>





            </routeContext>



--
View this message in context: http://camel.465427.n5.nabble.com/how-do-I-check-conditions-in-XML-DSL-tp5750490.html
Sent from the Camel - Users mailing list archive at Nabble.com.
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful.