【发布时间】:2017-12-23 16:50:35
【问题描述】:
我使用 Spring Integration XML 路由器和xpath-expression
<int:chain input-channel="routerInputChannel">
<int-xml:xpath-router default-output-channel="routerOutputChannel">
<int-xml:xpath-expression expression="//actor[1]/text()"/>
<int-xml:mapping value="Christian Bale" channel="routerBaleChannel"/>
</int-xml:xpath-router>
</int:chain>
并期望此 XML 字符串作为 SI 消息负载
<root xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org">
<actors>
<actor id="1">Christian Bale</actor>
<actor id="2">Liam Neeson</actor>
<actor id="3">Michael Caine</actor>
</actors>
<foo:singers>
<foo:singer id="4">Tom Waits</foo:singer>
<foo:singer id="5">B.B. King</foo:singer>
<foo:singer id="6">Ray Charles</foo:singer>
</foo:singers>
</root>
将发送到routerBaleChannel,但由于某种原因它不起作用。
我在XPath Tester / Evaluator 尝试了消息和XPath 表达式,正如预期的那样,我得到了Christian Bale 字符串。
我调试了org.springframework.integration.xml.router.XPathRouter方法getChannelKeys,发现Jaxp13XPathExpressionFactory方法evaluate内部有问题:执行后原因不明
NodeList nodes = (NodeList) evaluate(node, XPathConstants.NODESET);
nodes.getLength() 返回空列表。
那么我的 XPath 路由器或 XPath 表达式配置有什么问题?
【问题讨论】:
标签: java spring xpath spring-integration