Can I use a message translator with an xpath expression?

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

Can I use a message translator with an xpath expression?

LavanyaKC
Hi

I am not getting any output running the following xml file,

<route xmlns="http://activemq.apache.org/camel/schema/spring" id="null_1">
    <from uri="file:///c:/temp1?noop=true" id="File_2"/>
    <transform id="MessageTranslator_0">
        <xpath>/Students/Student</xpath>
    </transform>
    <convertBodyTo type="java.lang.String" id="ConvertBodyTo_0">
    </convertBodyTo>
    <to uri="file:///c:/temp1/MsgtrnsDebug" id="File_0"/>
</route>

It works fine with other expressions like simple. Can we use xpath to translate a message?

Thanks,
Lavanya.
Reply | Threaded
Open this post in threaded view
|

Re: Can I use a message translator with an xpath expression?

Claus Ibsen-2
Hi

Yeah xpath can be a pain in the ....
There is an option you can set on the xpath to force it to use a
certain result type. I think its resultType="java.lang.String".
That might help a bit.

As transform evalulates any expression it ought to be possible to set
the result of the xpath evaluation.

Otherwise you can try the enable the tracer to see the message as its routed
http://camel.apache.org/tracer.html

On Thu, May 7, 2009 at 10:35 AM, LavanyaKC <[hidden email]> wrote:

>
> Hi
>
> I am not getting any output running the following xml file,
>
> <route xmlns="http://activemq.apache.org/camel/schema/spring" id="null_1">
>    <from uri="file:///c:/temp1?noop=true" id="File_2"/>
>    <transform id="MessageTranslator_0">
>        <xpath>/Students/Student</xpath>
>    </transform>
>    <convertBodyTo type="java.lang.String" id="ConvertBodyTo_0">
>    </convertBodyTo>
>    <to uri="file:///c:/temp1/MsgtrnsDebug" id="File_0"/>
> </route>
>
> It works fine with other expressions like simple. Can we use xpath to
> translate a message?
>
> Thanks,
> Lavanya.
> --
> View this message in context: http://www.nabble.com/Can-I-use-a-message-translator-with-an-xpath-expression--tp23422445p23422445.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Interview with me:
http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
Reply | Threaded
Open this post in threaded view
|

Re: Can I use a message translator with an xpath expression?

LavanyaKC
Thanks Claus.

I tried with
<convertBodyTo type="java.lang.String" /> 

which still did not solve the problem.

Lavanya.

Claus Ibsen-2 wrote
Hi

Yeah xpath can be a pain in the ....
There is an option you can set on the xpath to force it to use a
certain result type. I think its resultType="java.lang.String".
That might help a bit.

As transform evalulates any expression it ought to be possible to set
the result of the xpath evaluation.

Otherwise you can try the enable the tracer to see the message as its routed
http://camel.apache.org/tracer.html

On Thu, May 7, 2009 at 10:35 AM, LavanyaKC <ckonda@progress.com> wrote:
>
> Hi
>
> I am not getting any output running the following xml file,
>
> <route xmlns="http://activemq.apache.org/camel/schema/spring" id="null_1">
>    <from uri="file:///c:/temp1?noop=true" id="File_2"/>
>    <transform id="MessageTranslator_0">
>        <xpath>/Students/Student</xpath>
>    </transform>
>    <convertBodyTo type="java.lang.String" id="ConvertBodyTo_0">
>    </convertBodyTo>
>    <to uri="file:///c:/temp1/MsgtrnsDebug" id="File_0"/>
> </route>
>
> It works fine with other expressions like simple. Can we use xpath to
> translate a message?
>
> Thanks,
> Lavanya.
> --
> View this message in context: http://www.nabble.com/Can-I-use-a-message-translator-with-an-xpath-expression--tp23422445p23422445.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Interview with me:
http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
Reply | Threaded
Open this post in threaded view
|

Re: Can I use a message translator with an xpath expression?

Claus Ibsen-2
Hi

What do you expect as output from the xpath expression?
Its a NodeList if for instance the xml contains multiple students.

Can you post an example? What you send IN and what your expect as OUT ?


On Thu, May 7, 2009 at 11:37 AM, LavanyaKC <[hidden email]> wrote:

>
> Thanks Claus.
>
> I tried with
> <convertBodyTo type="java.lang.String" />
>
> which still did not solve the problem.
>
> Lavanya.
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> Yeah xpath can be a pain in the ....
>> There is an option you can set on the xpath to force it to use a
>> certain result type. I think its resultType="java.lang.String".
>> That might help a bit.
>>
>> As transform evalulates any expression it ought to be possible to set
>> the result of the xpath evaluation.
>>
>> Otherwise you can try the enable the tracer to see the message as its
>> routed
>> http://camel.apache.org/tracer.html
>>
>> On Thu, May 7, 2009 at 10:35 AM, LavanyaKC <[hidden email]> wrote:
>>>
>>> Hi
>>>
>>> I am not getting any output running the following xml file,
>>>
>>> <route xmlns="http://activemq.apache.org/camel/schema/spring"
>>> id="null_1">
>>>    <from uri="file:///c:/temp1?noop=true" id="File_2"/>
>>>    <transform id="MessageTranslator_0">
>>>        <xpath>/Students/Student</xpath>
>>>    </transform>
>>>    <convertBodyTo type="java.lang.String" id="ConvertBodyTo_0">
>>>    </convertBodyTo>
>>>    <to uri="file:///c:/temp1/MsgtrnsDebug" id="File_0"/>
>>> </route>
>>>
>>> It works fine with other expressions like simple. Can we use xpath to
>>> translate a message?
>>>
>>> Thanks,
>>> Lavanya.
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Can-I-use-a-message-translator-with-an-xpath-expression--tp23422445p23422445.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>> Apache Camel Reference Card:
>> http://refcardz.dzone.com/refcardz/enterprise-integration
>> Interview with me:
>> http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Can-I-use-a-message-translator-with-an-xpath-expression--tp23422445p23423271.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Interview with me:
http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
Reply | Threaded
Open this post in threaded view
|

Re: Can I use a message translator with an xpath expression?

LavanyaKC
Thanks Claus.

It worked fine with convertBodyTo. It applies the xpath and the output is coming in the out folder.
I did something wrong with the destination file endpoint settings earlier.

Lavanya.

Claus Ibsen-2 wrote
Hi

What do you expect as output from the xpath expression?
Its a NodeList if for instance the xml contains multiple students.

Can you post an example? What you send IN and what your expect as OUT ?


On Thu, May 7, 2009 at 11:37 AM, LavanyaKC <ckonda@progress.com> wrote:
>
> Thanks Claus.
>
> I tried with
> <convertBodyTo type="java.lang.String" />
>
> which still did not solve the problem.
>
> Lavanya.
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> Yeah xpath can be a pain in the ....
>> There is an option you can set on the xpath to force it to use a
>> certain result type. I think its resultType="java.lang.String".
>> That might help a bit.
>>
>> As transform evalulates any expression it ought to be possible to set
>> the result of the xpath evaluation.
>>
>> Otherwise you can try the enable the tracer to see the message as its
>> routed
>> http://camel.apache.org/tracer.html
>>
>> On Thu, May 7, 2009 at 10:35 AM, LavanyaKC <ckonda@progress.com> wrote:
>>>
>>> Hi
>>>
>>> I am not getting any output running the following xml file,
>>>
>>> <route xmlns="http://activemq.apache.org/camel/schema/spring"
>>> id="null_1">
>>>    <from uri="file:///c:/temp1?noop=true" id="File_2"/>
>>>    <transform id="MessageTranslator_0">
>>>        <xpath>/Students/Student</xpath>
>>>    </transform>
>>>    <convertBodyTo type="java.lang.String" id="ConvertBodyTo_0">
>>>    </convertBodyTo>
>>>    <to uri="file:///c:/temp1/MsgtrnsDebug" id="File_0"/>
>>> </route>
>>>
>>> It works fine with other expressions like simple. Can we use xpath to
>>> translate a message?
>>>
>>> Thanks,
>>> Lavanya.
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Can-I-use-a-message-translator-with-an-xpath-expression--tp23422445p23422445.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>> Apache Camel Reference Card:
>> http://refcardz.dzone.com/refcardz/enterprise-integration
>> Interview with me:
>> http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Can-I-use-a-message-translator-with-an-xpath-expression--tp23422445p23423271.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Interview with me:
http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
Reply | Threaded
Open this post in threaded view
|

Re: Can I use a message translator with an xpath expression?

Claus Ibsen-2
On Thu, May 7, 2009 at 2:04 PM, LavanyaKC <[hidden email]> wrote:
>
> Thanks Claus.
>
> It worked fine with convertBodyTo. It applies the xpath and the output is
> coming in the out folder.
> I did something wrong with the destination file endpoint settings earlier.
Glad it worked for you as the XML and Xpath can be tricky once in a while.


>
> Lavanya.
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> What do you expect as output from the xpath expression?
>> Its a NodeList if for instance the xml contains multiple students.
>>
>> Can you post an example? What you send IN and what your expect as OUT ?
>>
>>
>> On Thu, May 7, 2009 at 11:37 AM, LavanyaKC <[hidden email]> wrote:
>>>
>>> Thanks Claus.
>>>
>>> I tried with
>>> <convertBodyTo type="java.lang.String" />
>>>
>>> which still did not solve the problem.
>>>
>>> Lavanya.
>>>
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> Hi
>>>>
>>>> Yeah xpath can be a pain in the ....
>>>> There is an option you can set on the xpath to force it to use a
>>>> certain result type. I think its resultType="java.lang.String".
>>>> That might help a bit.
>>>>
>>>> As transform evalulates any expression it ought to be possible to set
>>>> the result of the xpath evaluation.
>>>>
>>>> Otherwise you can try the enable the tracer to see the message as its
>>>> routed
>>>> http://camel.apache.org/tracer.html
>>>>
>>>> On Thu, May 7, 2009 at 10:35 AM, LavanyaKC <[hidden email]> wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> I am not getting any output running the following xml file,
>>>>>
>>>>> <route xmlns="http://activemq.apache.org/camel/schema/spring"
>>>>> id="null_1">
>>>>>    <from uri="file:///c:/temp1?noop=true" id="File_2"/>
>>>>>    <transform id="MessageTranslator_0">
>>>>>        <xpath>/Students/Student</xpath>
>>>>>    </transform>
>>>>>    <convertBodyTo type="java.lang.String" id="ConvertBodyTo_0">
>>>>>    </convertBodyTo>
>>>>>    <to uri="file:///c:/temp1/MsgtrnsDebug" id="File_0"/>
>>>>> </route>
>>>>>
>>>>> It works fine with other expressions like simple. Can we use xpath to
>>>>> translate a message?
>>>>>
>>>>> Thanks,
>>>>> Lavanya.
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Can-I-use-a-message-translator-with-an-xpath-expression--tp23422445p23422445.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> Apache Camel Committer
>>>>
>>>> Open Source Integration: http://fusesource.com
>>>> Blog: http://davsclaus.blogspot.com/
>>>> Twitter: http://twitter.com/davsclaus
>>>> Apache Camel Reference Card:
>>>> http://refcardz.dzone.com/refcardz/enterprise-integration
>>>> Interview with me:
>>>> http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Can-I-use-a-message-translator-with-an-xpath-expression--tp23422445p23423271.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>> Apache Camel Reference Card:
>> http://refcardz.dzone.com/refcardz/enterprise-integration
>> Interview with me:
>> http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Can-I-use-a-message-translator-with-an-xpath-expression--tp23422445p23425375.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Interview with me:
http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress