You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Dale King <da...@gmail.com> on 2013/10/08 22:43:01 UTC

Re: setHeader("FOO", xpath("/foo/bar/@value")) is of type net.sf.saxon.dom.DOMNodeList - not String, ideas?

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 <cw...@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 <cw...@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

Re: setHeader("FOO", xpath("/foo/bar/@value")) is of type net.sf.saxon.dom.DOMNodeList - not String, ideas?

Posted by Willem jiang <wi...@gmail.com>.
Hi,

I just Filled a JIRA[1] for it and the patch is on the way.

[1]https://issues.apache.org/jira/browse/CAMEL-6841  

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Wednesday, October 9, 2013 at 4:43 AM, Dale King wrote:

> 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 (mailto: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 (mailto: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