I'm getting CSV file as input and want to tranform to XML format. It is creating empty xml records, when I'm getting few empty csv rows or records in input csv file. How to ignore empty records to process and/or records to create in output xml file.
Using Mule Runtime 4.2.1
CSV Input:
Type,AdminAlias,OriginatorID,OriginatorName,TransactionCode,TotalPaymentAmount,TotalClaimsCount,CreatedDateTime,FileDateTime,SourceDocumentType,ReceivedFileName,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
HEADER,GPS,,,,,,2020-04-02T10:55:56,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Type,ActionCode,Status,StatusMessage,RecipientName,ClaimPayeeType,LH1ParticipantUniqueID,ParticipantExternalId,ParticipantEmployeeNumber,FirstName,MiddleName,LastName,SSN,DOB,ProviderID,ProviderName,AddressLine1,AddressLine2,AddressLine3,AddressLine4,City,StateCode,ZipCode,CountryCode,ExternalClaimNumber,ClaimAmount,Claim Type,PaidDate,ReceiptReceived,ClaimOnHold,ServiceStartDate,ServiceEndDate,ExpenseCategory,ExpenseType,ServiceCode,ServiceCodeType,ClaimDescription,KeyName,KeyValue,,,,,,,,,,,,,,,,
CLAIM,I,P,,,,,,,DONALD,,HUGHES,123456789,1990-12-02,123456789,ASSOCIATED OMS AND IMPLANT CEN,,,,,,,,,22007635202,52.80,,,TRUE,FALSE,2000-03-06,2000-03-06,Medical Expenses,Other Medical,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
DataWeave script:
%dw 2.0
output application/xml skipNullOn="everywhere"
ns ns0 http://www.lighthouse1.com/LH1OnDemand/ClaimsExchange/2008/10/01/ //writeDeclaration = false //skipNullOn = "elements"
---
{
ns0#LH1StandardClaimsExchange @(TotalPaymentAmount: sum(payload.bodyRecords.ClaimAmount filter ($!="")), AdminAlias: payload.header.AdminAlias , TotalClaimsCount: sizeOf(payload.bodyRecords.ClaimAmount) as String , CreatedDateTime: payload.header.CreatedDateTime): {
(payload.bodyRecords filter ($ !=null and $ !='') map ((bodyRecord , indexOfBodyRecord) -> {
Claim @(Status: bodyRecord.Status , ActionCode: bodyRecord.ActionCode): {
Participant @(FirstName: bodyRecord.FirstName , LastName: bodyRecord.LastName , SSN: bodyRecord.SSN as String , DOB: bodyRecord.DOB as String): '',
Provider @(ProviderID: bodyRecord.ProviderID , ProviderName: bodyRecord.ProviderName): {
MailingAddress @(AddressLine1: bodyRecord.AddressLine1 , City: bodyRecord.City , StateCode: bodyRecord.StateCode , ZipCode: bodyRecord.ZipCode , CountryCode: bodyRecord.CountryCode): ''
},
ClaimDetail @(ExternalClaimNumber: bodyRecord.ExternalClaimNumber , ClaimAmount: bodyRecord.ClaimAmount , ReceiptReceived: bodyRecord.ReceiptReceived as String , ClaimOnHold: bodyRecord.ClaimOnHold as String , ServiceStartDate: bodyRecord.ServiceStartDate as String , ServiceEndDate: bodyRecord.ServiceEndDate as String , ExpenseCategory: bodyRecord.ExpenseCategory , ExpenseType: bodyRecord.ExpenseType): ''
}
}))
}
}
CSV input
XML output