Trying to convert the below dataweave from 1.0 to 2.0, but everything I've tried gives the following errors like
SkipNullon shows error
Usage of Namespacing is not accepted,
@PostalCode[0..4] is not valid and
can't access the value inside insuredInfo using insuredPrimaryAddr.
Dataweave 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:
%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
Any ideas please on how to write the same in dataweave 2.0?