Hi

Well Camel usually have a easier way than wring 20 lines of code.

There is a static evaluate/matches method on XPathBuilder you can pass
in your xpath + data, eg

boolean matches = XPathBuilder.xpath("/foo/bar/@xyz").matches(context,
"<foo><bar xyz='cheese'/></foo>")




On Thu, Aug 30, 2012 at 12:04 PM, Alexey <reshe...@gmail.com> wrote:
> Claus Ibsen-2, thank you very much!
>
> For the time begin, I did that follows:
>
> ---route---
> ...
> <filter>
>     <method ref="histActAggregator" method="xpathExecute(${headers.history},
> '/history/p[@id = &quot;RESTSYBRIGE&quot; and @state != &quot;NN&quot;]')"
> />
>     <to uri="activemq:queue:RESTRUCT.DECLINE"/>
> </filter>
> ...
>
> ---bean 'histActAggregator' ---
> ...
>     public boolean xpathExecute(String xml, String xpathStr) {
>         try {
>             XPathFactory factory = XPathFactory.newInstance();
>             XPath xpath = factory.newXPath();
>             XPathExpression expr = xpath.compile(xpathStr);
>             InputSource inputSource = new InputSource(new
> StringReader(xml));
>             Boolean result = (Boolean) expr.evaluate(inputSource,
> XPathConstants.BOOLEAN);
>
>             return result;
>         } catch (XPathExpressionException ex) {
>             logger.log(Level.SEVERE, "XPathExpressionException; In xml: " +
> xml + "; xpath expression: ", ex);
>             throw new RuntimeException(ex);
>         }
>     }
> ...
>
> May be the solution isn't very elegantly, but it works :)
>
> thanks
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/xpath-for-header-tp5718190p5718365.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to