camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Babak Vahdat <babak.vah...@swissonline.ch>
Subject Re: @XPath evaluation
Date Tue, 28 Aug 2012 13:13:04 GMT
@Willem,

The new test being added *could* behave as "false-positive", because it
lacks the call to:

  assertMockEndpointsSatisfied();

Babak


Willem.Jiang wrote
> 
> setHeader() should be able to take the XPath expression.
> I just add unit test in the camel trunk to show it.
> 
>  setHeader("foo").xpath("/personFile/text()").  
> 
> --  
> Willem Jiang
> 
> FuseSource
> Web: http://www.fusesource.com (http://www.fusesource.com/)
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
> (English)
>           http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang  
> Weibo: willemjiang
> 
> 
> 
> 
> 
> On Monday, August 27, 2012 at 6:53 PM, Joe San wrote:
> 
>> I managed to get that working.
>>  
>> I have another question on the route configuration:
>>  
>> Assuming the following xml snippet:
>>  
>> <pss:info>
>> <personFile>098765432.txt</personFile>
>> <address>
>> <street>xyz</street>
>> <city>Frankfurt</city>
>> </address>
>> <persons>
>> <person>
>> <name>joe</name>
>> <age>32</age>
>> <country>Germany</country>
>> </person>
>>  
>> <person>
>> <name>sam</name>
>> <age>32</age>
>> <country>Germany</country>
>> </person>
>> </persons>
>> </pss:info>
>>  
>> The task was to get the List of Person which I managed to extract using
>> xpath. I would also want to get the fileName value and set that as a
>> header
>> in my Exchange. My route definition is as below:
>>  
>> from("file://C:/folders/inbox?noop=true")
>>  
>> .setFileNameHeader(ns.xpath("/SOAP:Envelope/SOAP:Body/pss:info/personFile/text()"))
>> .split(ns.xpath("//SOAP:Envelope/SOAP:Body/pss:info/persons"))
>> .bean(new PersonProcessor())
>> .to("file://C:/folders/inbox");
>>  
>> But I get the following error message shown:
>>  
>> The method setFileNameHeader(XPathExpression) is undefined for the type
>> RouteDefinition
>>  
>> The setHeader also seems to be wrong.
>>  
>> Regards,
>> Jothi
>>  
>> On Fri, Aug 24, 2012 at 9:35 PM, Christian Müller <
>> christian.mueller@ (mailto:christian.mueller@)> wrote:
>>  
>> > Yes, should be possible.
>> >  
>> > Sent from a mobile device
>> > Am 24.08.2012 13:56 schrieb "Joe San" &lt;codeintheopen@
>> (mailto:codeintheopen@)&gt;:
>> >  
>> > > The most common language to use is XPath, which allows you to
>> evaluate
>> > > XPath
>> > > expressions on the message body. For example, suppose the message
>> >  
>> >  
>> > contains
>> > > the following
>> > > XML document:
>> > >  
>> > > <order customerId="123">
>> > > <status>in progress</status>
>> > > </order>
>> > >  
>> > > By using XPath expressions, you can extract parts of the document and
>> > bind
>> > > them to
>> > > parameters, like this:
>> > >  
>> > > public void updateStatus(@XPath("/order/@customerId") Integer
>> customerId,
>> > > @XPath("/order/status/text()") String status) {
>> > > ....
>> > > ....
>> > > }
>> > >  
>> > > The above snippet is from the Camel in Action book. Can I use the
>> @XPath
>> > to
>> > > evaluate to a List < Person >?
>> > >  
>> > > My xml would look like this:
>> > >  
>> > > <info>
>> > > <address>
>> > > <street>xyz</street>
>> > > <city>Frankfurt</city>
>> > > </address>
>> > >  
>> > > <person>
>> > > <name>joe</name>
>> > > <age>32</age>
>> > > <country>Germany</country>
>> > > </person>
>> > >  
>> > > <person>
>> > > <name>sam</name>
>> > > <age>32</age>
>> > > <country>Germany</country>
>> > > </person>
>> > >  
>> > > </info>
>> > >  
>> > > The XPath should evaluate the fetch the List of Person objects!
>> > >  
>> > > Regards,
>> > > Jothi
>> >  
>>
> 




--
View this message in context: http://camel.465427.n5.nabble.com/XPath-evaluation-tp5718002p5718195.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message