<root>
<risk>
<Category>02</Category>
<NCD>
<CoverCode>B05</CoverCode>
<CI>
<CD>3</CD>
</CI>
</NCD>
</risk>
</root>
我需要检查2个条件以从上面获得所需的有效载荷。我正在使用如下的转换来检查2个条件。我希望只有当Category为02且CoverCode为B05时才能得到CD的值。
%dw 1.0
%output application/xml skipNullOn="everywhere"
%namespace soapenv http://schemas.xmlsoap.org/soap/envelope/
---
{
soapenv#Envelope: {
soapenv#Body: {
component:{
coverageClassCode:payload.root.risk.NCD.CI.CD when payload.root.risk.Category == '02' && payload.root.risk.NCD.CoverCode == 'B05' otherwise "" ,
blockedDr:"N"
}
}
}
}
感谢您的帮助。
答案 0 :(得分:1)
只需将&&
更改为and
-
%dw 1.0
%output application/xml skipNullOn="everywhere"
%namespace soapenv http://schemas.xmlsoap.org/soap/envelope/
---
{
soapenv#Envelope:{
soapenv#body:{
component:{
coverageClassCode:payload.root.risk.NCD.CI.CD when payload.root.risk.Category == '02' and payload.root.risk.NCD.CoverCode == 'B05' otherwise "",
//payload.root.risk.NCD.CI.CD when payload.root.risk.Category == '02' && payload.root.risk.NCD.CoverCode == 'B05' otherwise "" ,
blockedDr:"N"
}
}
}
}