我定义了一个全局函数如下
<configuration doc:name="Configuration">
<expression-language autoResolveVariables="true">
<import class="java.text.SimpleDateFormat" />
<global-functions>
def convertDate(shiftDate){
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return dateFormat.format(shiftDate);
}
</global-functions>
</expression-language>
</configuration>但是当通过记录器打电话时,似乎什么都没有发生
<logger message="Convert Date #[convertDate(xpath://address/@timestamp)]" level="DEBUG" doc:name="Logger"/>xpath表达式xpath://address/@时间戳产生2014-10-29T15:23:07
但在我看到伐木者之前
xpath-分支:/address/@时间戳是: org.dom4j.tree.DefaultAttribute@6452310a属性:名称时间戳值"2014-10-29T15:23:07“
错误消息如下所示
org.mule.api.expression.InvalidExpressionException: [Error: unexpected end of statement]
[Near : {... convertDate(xpath://address/@payloadID) ....}]我在这里做错什么了?非常感谢。
发布于 2014-11-03 06:08:43
你把梅尔和老式的表情混在一起了。
这是旧风格:xpath://address/@payloadID
我是梅尔:xpath('//address/@payloadID').value
所以你需要使用:
<logger
message="Convert Date #[convertDate(xpath('//address/@payloadID').value)]"
level="DEBUG" />请参阅:http://www.mulesoft.org/documentation/display/current/Mule+Expression+Language+Tips#MuleExpressionLanguageTips-XPathSupport
https://stackoverflow.com/questions/26693943
复制相似问题