我将以下内容设置为输入有效负载,并且我希望输出为结构良好的XML文件,如下所示:我无法控制输入有效负载。我是Mule DataWeave Transformations和Mule的新手。请注意,这些只是所有名称和属性的任意值。到目前为止,我一直在尝试使用Mule提供的pluck()和map()方法,但没有成功。任何朝着正确方向的指针将不胜感激。
输入:
[{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}}]}}]
输出:
<?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>
JSON无效,请发布正确的JSON。
如果此错误是从源头来的,则可能需要对python pandas数据进行一些整理才能将其设置为正确的格式。祝你好运。