camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raul Kripalani <r...@evosent.com>
Subject Re: Choice with xpath
Date Tue, 23 Oct 2012 10:39:19 GMT
Hi German,

This is more of an XPath question rather than a Camel-related one, but here
goes the answer.

Do you have multiple occurrences of element 'a'? The double slash traverses
the entire input and returns all elements with name 'a' regardless of where
in the document they are.

Anyway, try these expressions, which are available on XPath 1.0:

   - starts-with(/a/b/text(), 'user')
   - starts-with(/a/b/text(), 'admin')

These will work if your input documents look like this, with no namespaces:

<a>
  <b>user</b>
</a>

Thanks,

*Raúl Kripalani*
Apache Camel Committer
Enterprise Architect, Program Manager, Open Source Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk <http://twitter.com/raulvk>

On Mon, Oct 22, 2012 at 6:45 PM, German O <german.otero@gmail.com> wrote:

> Hi, I have a situation where I have to do a choice with an xpath, and
> depending on the content of an xml tag, I need to do different things.
> Xml:
>
>   *user*
>
>
> other
>
>    *admin*
>
>
> Ie:
> <c:route>
>                         <c:from uri="file://{{handshakeFolder}}" />
>                         <c:choice>
>                                 <c:when>
>                                         <xpath>//a/b/text() start-with
> "user"</xpath>
>                                         <to uri="direct:user-handshake" />
>                                 </c:when>
>                                 <c:when>
>                                         <xpath>//a/b/text() start-with
> "admin"</xpath>
>                                         <to uri="direct:admin-handshake" />
>                                 </c:when>
>                         </c:choice>
>                 </c:route>
>
>
> I couldn't find the way to do this...
>
> Thanks.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Choice-with-xpath-tp5721410.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message