You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by npa <np...@gmail.com> on 2014/04/04 20:45:50 UTC

Camel XPath....Parsing a part of message Body...

I have a simple flow that reads from an activemq1 and parses an id from the
message and sends the id across to another activemq2.

Here is an example of message that gets written to activemq1:

<Customer>
  <Order>
     <id>123</id>
  </Order>
<Customer>

I need to parse out the id from the above message body and send the below
message to activemq2:

"Order with id{123} has been queued"

This is the flow that I cameup with, but it writes the complete request xml
to the queue, but not the message that I am looking for:

<from uri="jms:queue:Q.activemq1"/>
   <setBody>
        <xpath>"/Customer/Order/id/@value/text()"</xpath>
    </setBody>
 <to uri="jms:queue:Q.activemq2"/>

Anything wrong in the above



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-XPath-Parsing-a-part-of-message-Body-tp5749823.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel XPath....Parsing a part of message Body...

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

The xpath should not have " " around it

On Fri, Apr 4, 2014 at 8:45 PM, npa <np...@gmail.com> wrote:
> I have a simple flow that reads from an activemq1 and parses an id from the
> message and sends the id across to another activemq2.
>
> Here is an example of message that gets written to activemq1:
>
> <Customer>
>   <Order>
>      <id>123</id>
>   </Order>
> <Customer>
>
> I need to parse out the id from the above message body and send the below
> message to activemq2:
>
> "Order with id{123} has been queued"
>
> This is the flow that I cameup with, but it writes the complete request xml
> to the queue, but not the message that I am looking for:
>
> <from uri="jms:queue:Q.activemq1"/>
>    <setBody>
>         <xpath>"/Customer/Order/id/@value/text()"</xpath>
>     </setBody>
>  <to uri="jms:queue:Q.activemq2"/>
>
> Anything wrong in the above
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-XPath-Parsing-a-part-of-message-Body-tp5749823.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io

Re: Camel XPath....Parsing a part of message Body...

Posted by Christian Müller <ch...@gmail.com>.
I suggest adding the camel-saxon dependency and use:
<xpath saxon="true">/CamelData/Provider/text()</xpath>

Best,

Christian
-----------------

Software Integration Specialist

Apache Member
V.P. Apache Camel | Apache Camel PMC Member | Apache Camel committer
Apache Incubator PMC Member

https://www.linkedin.com/pub/christian-mueller/11/551/642

On Thu, Aug 6, 2015 at 9:28 PM, anish.somadevan <ne...@gmail.com> wrote:

> Am having a similar issue and i get this error message,
>
> java.lang.ClassCastException: org.apache.xml.dtm.ref.DTMManagerDefault
> cannot be cast to org.apache.xml.dtm.DTMManager:
> java.lang.ClassCastException: org.apache.xml.dtm.ref.DTMManagerDefault
> cannot be cast to org.apache.xml.dtm.DTMManager
>         at org.apache.xml.dtm.DTMManager.newInstance(DTMManager.java:137)
> [xalan.jar:]
>         at org.apache.xpath.XPathContext.<init>(XPathContext.java:102)
> [xalan.jar:]
>         at org.apache.xpath.XPathContext.<init>(XPathContext.java:349)
> [xalan.jar:]
>         at
>
> org.apache.xpath.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:113)
>         at
> org.apache.xpath.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:99)
>
> This is how am trying to retrieve the value,
>
> <xpath>/CamelData/Provider/text()</xpath>
>
> Can you please let me know how to resolve this?
>
> Thanks,
> Anish
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-XPath-Parsing-a-part-of-message-Body-tp5749823p5770394.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

RE: Camel XPath....Parsing a part of message Body...

Posted by "anish.somadevan" <ne...@gmail.com>.
Am having a similar issue and i get this error message,

java.lang.ClassCastException: org.apache.xml.dtm.ref.DTMManagerDefault
cannot be cast to org.apache.xml.dtm.DTMManager:
java.lang.ClassCastException: org.apache.xml.dtm.ref.DTMManagerDefault
cannot be cast to org.apache.xml.dtm.DTMManager
	at org.apache.xml.dtm.DTMManager.newInstance(DTMManager.java:137)
[xalan.jar:]
	at org.apache.xpath.XPathContext.<init>(XPathContext.java:102) [xalan.jar:]
	at org.apache.xpath.XPathContext.<init>(XPathContext.java:349) [xalan.jar:]
	at
org.apache.xpath.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:113)
	at
org.apache.xpath.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:99)

This is how am trying to retrieve the value,

<xpath>/CamelData/Provider/text()</xpath>

Can you please let me know how to resolve this?

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-XPath-Parsing-a-part-of-message-Body-tp5749823p5770394.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Camel XPath....Parsing a part of message Body...

Posted by Ra...@cognizant.com.
Try following.

<from uri="jms:queue:Q.activemq1"/>
<setBody>
        <xpath>/Customer/Order/id/text()</xpath>
</setBody>
<setBody>
        <simple>Order with id ${in.body} received </simple>
</setBody>
 <to uri="jms:queue:Q.activemq2"/>



- Ravi
________________________________________
From: npa [npa.ccdb@gmail.com]
Sent: Saturday, April 05, 2014 12:15 AM
To: users@camel.apache.org
Subject: Camel XPath....Parsing a part of message Body...

I have a simple flow that reads from an activemq1 and parses an id from the
message and sends the id across to another activemq2.

Here is an example of message that gets written to activemq1:

<Customer>
  <Order>
     <id>123</id>
  </Order>
<Customer>

I need to parse out the id from the above message body and send the below
message to activemq2:

"Order with id{123} has been queued"

This is the flow that I cameup with, but it writes the complete request xml
to the queue, but not the message that I am looking for:

<from uri="jms:queue:Q.activemq1"/>
   <setBody>
        <xpath>"/Customer/Order/id/@value/text()"</xpath>
    </setBody>
 <to uri="jms:queue:Q.activemq2"/>

Anything wrong in the above



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-XPath-Parsing-a-part-of-message-Body-tp5749823.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.