Reputation: 2163
I have been trying to map a List into an XML with lastest Mule Datamapper (3.5.1). Problem I met is:
Given this List essentially is a resultset from DB query, so every Map inside this List has same amount of k:v pairs. And one of them is called "Contact_Name", which could be either a String value or an empty String, mapped into xml side as <contactName>JohnDoe</contactName>
Could someone guide me about how should I validate this "Contact_name" and if it's an empty string then make sure in the xml side I won't have an empty node like <contactName/>
?
The xpath towards java map seems tricky and there is lack of such documentations from Mule.
edit: could anyone advise if rules or mapping conditions help? Especially the condition
in the mapping structure editor, I couldnt find any doc explaining what syntax should I use there.
Thanks all
Upvotes: 0
Views: 566
Reputation: 11606
If you use the 'script' view in the data mapper viewer, you can use expressions to check if the input argument is null or empty. Fore example:
if(input.Contact_Name != null) output.contactname = input.Contact_Name
Upvotes: 2