如何在mule中使用xpath3检查NaN值。
我试图这样做,但没有得到正确的结果
Query queryRef = mDatabase.child("user-tickets").child(userId);
FirebaseRecyclerAdapter<Ticket, TicketViewHolder> adapter = new FirebaseRecyclerAdapter<Ticket, TicketViewHolder>(
Ticket.class,
R.layout.item_ticket,
TicketViewHolder.class,
queryRef
) {
@Override
protected void populateViewHolder(TicketViewHolder viewHolder, Ticket model, int position) {
//want to get Id here for this record
}
};
但没有工作
如何检查mule中的NaN值?
答案 0 :(得分:0)
尝试使用是或 的实例,例如<?xml version="1.0" encoding="UTF-8"?>
<data>
<total>100</total>
</data>
基于进一步测试,使用以下示例:
#[xpath3('//total',payload,'NUMBER').isNaN() ? 0 : xpath3('//total',payload,'NUMBER')]
我们可以使用 isNaN()方法,因为有效负载是 java.lang.Double 。因此,我们可以使用以下MEL:<flow name="simpleFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<logger message="#[xpath3('//total',payload,'NUMBER').isNaN() ? 0 : xpath3('//total',payload,'NUMBER')]" level="INFO" doc:name="Logger"/>
</flow>
可以通过以下简单流程进行测试:
<data><total>hundred</total></data>
为了测试目的,使用非数字更改总计字段的值,例如:Error: /Users/ali/cream/myApp/platforms/android/gradlew: Command failed with exit code 1 Error output:
Exception in thread "main" java.lang.RuntimeException: java.util.zip.ZipException: zip file is empty
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:78)
at org.gradle.wrapper.Install.createDist(Install.java:47)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.util.zip.ZipException: zip file is empty
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:215)
at java.util.zip.ZipFile.<init>(ZipFile.java:145)
at java.util.zip.ZipFile.<init>(ZipFile.java:159)
at org.gradle.wrapper.Install.unzip(Install.java:160)
at org.gradle.wrapper.Install.access$400(Install.java:29)
at org.gradle.wrapper.Install$1.call(Install.java:70)
at org.gradle.wrapper.Install$1.call(Install.java:47)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
... 3 more