I am trying implement the default namespace while creating XML in the data weaver. I went thought below data weaver documentation and earlier posts. Could not get any clue on this. How can we declare default namespace.
https://docs.mulesoft.com/mule-user-guide/v/3.7/dataweave-tutorial
My input will be from DB - linked list. Output is XML.
%dw 1.0
%namespace ns0 urn:abc:def:Components
%output application/xml
---
{
ns0#University: {
college: payload.college[0],
(payload map ((payload01 , indexOfPayload01) -> {
dept: {
deptName: payload01.dept,
Noofstudents: payload01."No of students" as :number
}
}))
}
}
Current output is
<ns0:University xmlns:ns0="urn:abc:def:Components">
<college>abc</college> <!-- this is simple tag/ It will not repeat -->
<dept> <!-- This is complex tag -->
<dept Name>IT</dept Name>
<No of students>5</No of students>
</dept>
<dept>
<dept Name>IT</dept Name>
<No of students>5</No of students>
</dept>
<dept>
<dept Name>IT</dept Name>
<No of students>5</No of students>
</dept>
</ns0:University>
Expected output is
<University xmlns="urn:abc:def:Components">
<college>abc</college> <!-- this is simple tag/ It will not repeat -->
<dept> <!-- This is complex tag -->
<dept Name>IT</dept Name>
<No of students>5</No of students>
</dept>
<dept>
<dept Name>IT</dept Name>
<No of students>5</No of students>
</dept>
<dept>
<dept Name>IT</dept Name>
<No of students>5</No of students>
</dept>
<University>