Choice with an xquery

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Choice with an xquery

Thomas Hehl
This: http://camel.apache.org/predicate.html says that I can use an
xquery in a predicate, but I can't find an example.

My message coming back contains a status tag. I want to check it for
"OK" to make sure it processed correctly. Here's what I wrote to make
sure the concept was sound.

                         .transform().xquery("/status", String.class)
                         .choice()
                           .when(body().isEqualTo("OK"))

But this destroys the entire message. I would like something like:
body().xquery("/status", String.class).isEqualTo("OK").

I could always do a contains, but two letters is a little likely to
appear in the string. I might try a regex if this won't work, but wanted
to try first.

Thanks.


Reply | Threaded
Open this post in threaded view
|

Re: Choice with an xquery

arno noordover
As seen in http://camel.apache.org/xquery.html you should be able to do something like
Namespaces ns = new Namespaces("c", "http://acme.com/cheese");

from("direct:start").
        filter().xquery("/c:person[@name='James']", ns).
        to("mock:result");
when you replace this example with:
choice()
.when().xquery(...).to(...)
.otherwise().to(...)
.endChoice()
you more or less should be up and running