What does Camel Splitter actually do with XML Document when splitting with xpath?

柔情痞子 提交于 2019-12-25 03:15:23

问题


I have a document with an order and a number of lines. I need to break the order into lines so I have a camel splitter set to xpath with the order line as it's value. This works fine.

However, what I get going forward is an element for the order line, which is what I want, but when converting it I need information from the order element - but if I try to get the parent element via xpath following the split, this doesn't work.

Does Camel create copies of the nodes returned by the xpath expression, or return a list of nodes within the parent document? If the former, can I make it the latter? If the latter, any ideas why a "../*" expression would return nothing?

Thanks!

Screwtape.


回答1:


Look at the split options that are available when using a Tokenizer: http://camel.apache.org/splitter.html

You have four different modes (i, w, u, t) and the 'w' one is keeping the ancestor context. In such case, the parent node (=the thing you apparently need) will be repeated in each sub-message

Default:

<m:order><id>123</id><date>2014-02-25</date></m:order>

'w' mode:

<m:orders>
  <m:order><id>123</id><date>2014-02-25</date>...</m:order>
</m:orders>


来源:https://stackoverflow.com/questions/51400343/what-does-camel-splitter-actually-do-with-xml-document-when-splitting-with-xpath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!