#xpath SpEL Function
从 3.0 版本开始,Spring Integration 提供内置的 #xpath
SpEL 函数,它会调用 XPathUtils.evaluate(…)
静态方法。此方法委托给 org.springframework.xml.xpath.XPathExpression
。以下列表显示了一些使用示例:
Spring Integration, since version 3.0, provides the built-in #xpath
SpEL function, which invokes the XPathUtils.evaluate(…)
static method.
This method delegates to an org.springframework.xml.xpath.XPathExpression
.
The following listing shows some usage examples:
<transformer expression="#xpath(payload, '/name')"/>
<filter expression="#xpath(payload, headers.xpath, 'boolean')"/>
<splitter expression="#xpath(payload, '//book', 'document_list')"/>
<router expression="#xpath(payload, '/person/@age', 'number')">
<mapping channel="output1" value="16"/>
<mapping channel="output2" value="45"/>
</router>
#xpath()
还支持第三个可选参数,用于转换 XPath 评估的结果。它可以是字符串常量(string
、boolean
、number
、node
、node_list
和 document_list
)或 org.springframework.xml.xpath.NodeMapper
实例。默认情况下,#xpath
SpEL 函数会返回 XPath 评估的 String
表示形式。
The #xpath()
also supports a third optional parameter for converting the result of the XPath evaluation.
It can be one of the String constants (string
, boolean
, number
, node
, node_list
and document_list
) or an org.springframework.xml.xpath.NodeMapper
instance.
By default, the #xpath
SpEL function returns a String
representation of the XPath evaluation.
为启用 |
To enable the |
有关详细信息,请参见“`Spring Expression Language (SpEL).
For more information, see "`Spring Expression Language (SpEL).