[英]dataweave 1.0 to 2.0 migration in mule
Trying to convert the below dataweave from 1.0 to 2.0 , but everything I've tried gives the following errors like尝试将以下dataweave 从 1.0 转换为 2.0 ,但我尝试过的所有操作都会出现以下错误,例如
SkipNullon shows error
SkipNullon 显示错误
Usage of Namespacing is not accepted,
不接受使用命名空间,
@PostalCode[0..4] is not valid and
@PostalCode[0..4] 无效并且
can't access the value inside insuredInfo using insuredPrimaryAddr.
无法使用参保PrimaryAddr 访问参保信息中的值。
Dataweave 1.0:数据编织 1.0:
%dw 1.0
%output application/xml skipNullOn="everywhere"
%var insuredInfo = payload.DTOApplication.DTOInsured
%var insuredPrimaryAddr = insuredInfo.*PartyInfo[?($.@PartyTypeCd == "InsuredParty")].*Addr[?($.@AddrTypeCd == "InsuredPrimaryBusAddr")][0]
%namespace ns0 http://decisionresearch.com/RateMaker
---
ns0#rate:{
ns0#code:insuredPrimaryAddr,
ns0#ZipCode: payload..Addr[?($.@AddrTypeCd == "InsuredPrimaryBusAddr")][0].@PostalCode[0..4] default ""
}
I tried Dataweave 2.0:我尝试了 Dataweave 2.0:
%dw 2.0
output application/xml skipNullOn="everywhere"
var insuredInfo = payload.DTOApplication.DTOInsured
var insuredPrimaryAddr = insuredInfo.*PartyInfo[?($.@PartyTypeCd == "InsuredParty")].*Addr[?($.@AddrTypeCd == "InsuredPrimaryBusAddr")][0]
namespace ns0 http://decisionresearch.com/RateMaker
---
ns0#rate:{
ns0#code:insuredPrimaryAddr,
ns0#ZipCode: payload..Addr[?($.@AddrTypeCd == "InsuredPrimaryBusAddr")][0].@PostalCode[0..4] default ""
}
payload: https://github.com/Manikandan99/rate-dtostep/blob/master/response.xml有效载荷: https://github.com/Manikandan99/rate-dtostep/blob/master/response.xml
Any ideas please on how to write the same in dataweave 2.0?关于如何在 dataweave 2.0 中编写相同内容的任何想法?
In dataweave 2.0 we use to
operator for array indexing.在 dataweave 2.0 中,我们使用
to
运算符进行数组索引。
%dw 2.0
output application/xml skipNullOn="everywhere"
var insuredInfo = payload.DTOApplication.DTOInsured
var insuredPrimaryAddr = insuredInfo.*PartyInfo[?($.@PartyTypeCd == "InsuredParty")].*Addr[?($.@AddrTypeCd == "InsuredPrimaryBusAddr")][0]
ns ns0 http://decisionresearch.com/RateMaker
---
ns0#rate:{
ns0#code:insuredPrimaryAddr,
ns0#ZipCode: payload..Addr[?($.@AddrTypeCd == "InsuredPrimaryBusAddr")][0].@PostalCode[0 to 4] default ""
}
Output Output
<?xml version='1.0' encoding='windows-1252'?>
<ns0:rate xmlns:ns0="http://decisionresearch.com/RateMaker">
<ns0:ZipCode>80003</ns0:ZipCode>
</ns0:rate>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.