首页 文章

dataweaver如何忽略在mule中生成xmlns

提问于
浏览
0

我在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

2 回答

  • 1

    这是我为我的问题找到的解决方案 .

    数据编织器的示例代码

    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"
    
  • 0

    您是否尝试在输出指令中使用skipNullOn属性?

    dataweave reference

相关问题