【发布时间】:2013-08-28 18:11:08
【问题描述】:
正如标题所示,我有一个带有标题的路由,其中包含一些类似于以下 sn-p 的 xml 作为字符串;
<files>
<image_file1>image.png</image_file1>
<image_file2>image.png</image_file2>
</files>
我正在尝试使用以下内容通过 xpath 进行拆分。如下所示,当 xml 是正文的一部分时,一切运行良好:-
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");
我找到了使用以下方法的解决方案:-
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");
但出于学习目的仍想知道,是否有一种方法可以在不将标头移入正文然后再反转的情况下做到这一点?
【问题讨论】:
标签: xpath apache-camel