In Camel how can i split a route using xpath on a header -


as title suggests, have route header contains xml similar following snippet string;

<files>   <image_file1>image.png</image_file1>   <image_file2>image.png</image_file2> </files> 

what i'm trying do split via xpath using following. following suggests when xml part of body, runs fine:-

from(myincomingqueue)     .convertbodyto(string.class, "utf-8")     .split(xpath("//*[local-name()='files']/*"))         .setheader("filepropertytoretrieve", xpath("local-name(//*)").stringresult())         .to(myfiledownloadqueue) .routeid("common-con-attachment_router-id"); 

i found solution using following:-

from(myincomingqueue)     .setbody(header("myheaderwithxml"))     .convertbodyto(string.class, "utf-8")     .split(xpath("//*[local-name()='files']/*"))         .setheader("filepropertytoretrieve", xpath("local-name(//*)").stringresult())         .setbody(header("cameloriginalbody"))         .to(myfiledownloadqueue) .routeid("common-con-attachment_router-id"); 

but still know learning purposes, if there way without moving header body , reversing afterwards?

yes if read docs xpath at: http://camel.apache.org/xpath - see section using xpath on headers

something alike

  .split(xpath("//*[local-name()='files']/*", "myheaderwithxml")) 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -