camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dale King <dalewk...@gmail.com>
Subject Re: setHeader("FOO", xpath("/foo/bar/@value")) is of type net.sf.saxon.dom.DOMNodeList - not String, ideas?
Date Tue, 08 Oct 2013 20:43:01 GMT
Yeah, was doing it off the top of my head. I knew there was a 2-arg version
of xpath, but I guess that is only in the fluent API. It should support it
in the xpath support method as well.


On Tue, Oct 8, 2013 at 4:35 PM, Chris <cwolf.algo@gmail.com> wrote:

> Dale,
>
> Thanks for the help - I thought there was an optional 2nd arg for type,
> but my Eclipse code completion didn't list it.  I put it in anyway
> and got:
>
> The method xpath(String) in the type BuilderSupport is not applicable for
> the arguments (String, Class<String>)
>
> ...then I tried the single arg version of setHeader, chained to the xpath:
>
> .setHeader("FOOBAR").xpath("**string(/task/clientId/@value)"**,
> String.class)
>
> This worked.  I guess that's what you meant, but it solved my issue -
> thanks for the help.
>
> Chris
>
>
> On 10/8/2013 4:28 PM, Dale King wrote:
>
>> Try
>>
>> .setHeader("FOO", xpath("/foo/bar/@value", String.class))
>>
>> xpath assumes that it will return a node list. You have to tell it if
>> that is not the case. I have a similar issue with an xpath with a count
>> expression and it throws an exception because it cannot convert from number
>> to node list.
>>
>> On Oct 8, 2013, at 4:23 PM, Chris <cwolf.algo@gmail.com> wrote:
>>
>>
>>> If my in msg body is:
>>>
>>> <foo>
>>>   <bar value="hello"/>
>>> </foo>
>>>
>>> ...then, when doing:
>>>
>>> .setHeader("FOO", xpath("/foo/bar/@value"))
>>>
>>> I expect the header named "FOO" to have String value of "hello",
>>> instead, I see: net.sf.saxon.dom.DOMNodeList@**74184b3b
>>>
>>> Is there any way to make this work?
>>>
>>> Thanks,
>>>
>>> Chris
>>>
>>>
>>


-- 
Dale King

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