On Thu, Apr 12, 2012 at 5:05 PM, bjacob <[email protected]> wrote:
> I've a problem when using xpath filter. Here is my code below.
> -----------------------------------------------------
> public class XMLFileFilter extends RouteBuilder{
>
>        public void configure() {
>
>              from("file://data/inbox?noop=true")
>              .filter()
>              .xpath("/orders/order/@id")
>              .to("file://data/outbox?fileName=fin.xml");
>           }
>
> }
> -----------------------------------------------------
> Here is my input file.
> --------------data/inbox/a.xml---------------------------------------
> <orders>
>  <order id="1"></order>
>  <order id="2"></order>
> </orders>
> -----------------------------------------------------
>
> I was trying to read the input file a.xml and filter it to just write the
> order ids to a different file(fin.xml) using camel. For some reason, the
> filter doesn't work and I always get the output same as the input without
> any change.
>

You need to use a different EIP pattern. The filter is like a if XXX statement.
So if the xpath predicate is true, the message is continued routed. So
in your case the xpath
predicate is that there should be a order/id attribute.

You may want to transform the XML using XSLT, or some other custom
transformation.
http://camel.apache.org/xslt


> Can somebody help me on this?
>
> Thanks
> Boney
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Xpath-filter-issue-tp5635933p5635933.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to