I have the following set as my input payload and I want to output to be a well-structured XML-file also as seen below: I have no control over the input payload. I am new to the Mule DataWeave Transformations and Mule in general. Please note these are just arbitrary values for all names and attributes. What I have tried so far is using the pluck () and map () methods provided by Mule, but with no success. Any pointers in the right direction would be greatly appreciated.
Input:
[{head={vars=[subject, instructorCode, instructoreName]}, results={bindings=[{subject={type=uri, value=www.google.com/subject-1-Details}, instructorName={type=literal, value=John Smith}, instructorCode={type=literal, value=JOS}}, {subject={type=uri, value=www.google.com/subject-2-Details}, instructorName{type=literal, value=Jane Smith}, instructorCode={type=literal, value=JAS}}]}},{head={vars=[department, departmentCode, departmentName]}, results={bindings=[{department={type=uri, value=www.google.com/department-1-details}, departmentName={type=literal, value=Computer Science}, departmentCode={type=literal, value=CS}},{department=(type=uri, value=www.google.com/department-2-details}, departmentName={type=literal, value = English}, departmentCode={type=literal, value=EL}}]}}]
Output:
<?xml version="1.0" encoding="UTF-8"?>
<CustomMessage xmlns="knowledge.publish.google.com">
<CustomKLMessage>
<CustomMessageHeader>
<msgId>12353</msgId>
<requestDateTime<2019-12-20T16:04:19.099-05:00</requestDateTime>
<requestorID>XYZ123</requestorID>
<locale>en_US</locale>
</CustomMessageHeader>
<elements>
<element>
<name>subject</name>
<values>
<value>JOS||John Smith</value>
<value>JAS||Jane Smith</value>
<value>NIP||Nilay Patel</value>
</values>
</element>
<element>
<name>department</name>
<values>
<value>CS||Computer Science</value>
<value>EL||English Language</value>
</values>
</element>
</elements>
</CustomKLMessage>
</CustomMessage>