我正在尝试在数据编织器中创建 XML 时实现默认命名空间。我在数据编织器文档和早期帖子中进行了思考。对此没有任何线索。我们如何声明默认命名空间。
https://docs.mulesoft.com/mule-user-guide/v/3.7/dataweave-tutorial
我的输入将来自 DB - 链表。输出是 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
}
}))
}
}
电流输出为
<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>
预期输出为
<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>