In my case, I have two payloads: domDRC and domPayload (2nd payload).
I have to iterate over the layer (child node) and update the DTOStep value of DTOCoverage and DTORateArea in domPayload based on values in layer of domDRC payload with InclFlag equal to "Y".
Logic:
nodes = domDRC.getRootElement().selectNodes("/Envelope/Body/rateResponse/RateResult/Layers/Layer","LayerNum");
for (Node node : nodes) {
if (node.valueOf("InclFlag") == 'Y') {
if ( (int) node.valueOf("LayerPremNonAuto") > 0) {
// NonAuto Layer
//add the DTOStep in CEL DTOCoverage of 2 nd payload
//add the DTOStep in DTORateArea of 2 nd payload and DTORateArea attributes values(AreaName, Description, FullTermAmt, FinalPremiumAmt, WrittenPremiumAmt)
}
if ( (int) node.valueOf("LayerPremAuto") > 0) {
// Auto Layer
//add the DTOStep in CEL DTOCoverage of 2 nd payload
//add the DTOStep in DTORateArea of 2 nd payload and DTORateArea attributes values(AreaName, Description, FullTermAmt, FinalPremiumAmt, WrittenPremiumAmt)
}
}
}
Entire XPR code : https://github.com/Manikandan99/java-code-to-dataweave-2/blob/main/auto_split_update_DtoSteps.xpr
DomDRC Payload (input): https://github.com/Manikandan99/java-code-to-dataweave-2/blob/main/domDRC_payload.xml
Dom payload (2nd payload) (input): https://github.com/Manikandan99/java-code-to-dataweave-2/blob/main/dom_payload(2nd).xml
Expected output : https://github.com/Manikandan99/java-code-to-dataweave-2/blob/main/Expected_updated_dtosteps.xml
Logic of xpr : https://github.com/Manikandan99/java-code-to-dataweave-2/blob/main/logic_of_auto_split_xpr.txt
I tried dataweave : https://github.com/Manikandan99/java-code-to-dataweave-2/blob/main/transform_DOM_payload.dwl
experts please go through the links.
In mule 3, I've used expression to transform the dom payload. while doing migration, due to unavailability of expression component in mule 4. I wanna go with dataweave 2.0. I've attached the dataweave tried but i couldn't solve the iteration over the domDRC and get the values from Layer node in domDRC payload, then update to it dom payload DTOSTEPS.
please help me on this and thanks in advance.
Any ideas on how to convert the auto_split xpr to dataweave 2.0?