dataweaver 如何忽略在 mule 中生成 xmlns
How can dataweaver ignore producing xmlns in mule
我正在 mule dataweave 组件中进行 xml 到 xml 的转换。
但是输出会为每个段生成“xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"。
我希望它没有问题,但是我可以在 dataweave 中设置停止生成这些行的方法。
Dataweave 的示例输出:
<host>
<event xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
id="app"
time-event-applied="2015-08-10T15:14:40"
user-id="user:admin"
is-billable="N"
entity="UNIT"
entity-id="CHRS1501720"
xsi:nil="true"/>
<additional-info>
<field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
id="X"
value="449"
xsi:nil="true"/>
<field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
id="Y"
value="9431719"
xsi:nil="true"/>
<field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
id="Z"
value="004"
xsi:nil="true"/>
</additional-info>
</host>
TIA
这是我为我的问题找到的解决方案。
data weaver 中的示例代码
info:{
field @(id: "!23" , value: payload.Response.Detail.Header.ID ): null
}
解决方案
info:{
field @(id: "!23" , value: payload.Response.Detail.Header.ID ): {}
}
从我的回答可以看出,我只是用 {} 替换了 null 部分,然后它停止生成
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"
您是否尝试在输出指令中使用 skipNullOn 属性?
我正在 mule dataweave 组件中进行 xml 到 xml 的转换。 但是输出会为每个段生成“xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"。 我希望它没有问题,但是我可以在 dataweave 中设置停止生成这些行的方法。
Dataweave 的示例输出:
<host>
<event xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
id="app"
time-event-applied="2015-08-10T15:14:40"
user-id="user:admin"
is-billable="N"
entity="UNIT"
entity-id="CHRS1501720"
xsi:nil="true"/>
<additional-info>
<field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
id="X"
value="449"
xsi:nil="true"/>
<field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
id="Y"
value="9431719"
xsi:nil="true"/>
<field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
id="Z"
value="004"
xsi:nil="true"/>
</additional-info>
</host>
TIA
这是我为我的问题找到的解决方案。
data weaver 中的示例代码
info:{
field @(id: "!23" , value: payload.Response.Detail.Header.ID ): null
}
解决方案
info:{
field @(id: "!23" , value: payload.Response.Detail.Header.ID ): {}
}
从我的回答可以看出,我只是用 {} 替换了 null 部分,然后它停止生成
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"
您是否尝试在输出指令中使用 skipNullOn 属性?