mule-user
mule-user

Reputation: 223

How can dataweaver ignore producing xmlns in mule

I am doing an xml to xml transformation in mule dataweave component. But the output produces " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" for every segment. I hope there is no issues with it but is there a way I can set in dataweave to stop producing these lines.

Example Output from 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

Upvotes: 1

Views: 3025

Answers (2)

mule-user
mule-user

Reputation: 223

Here is the solution I found for my problem.

Example code from data weaver

info:{
  field @(id: "!23" , value: payload.Response.Detail.Header.ID  ): null
}

Solution

info:{
  field @(id: "!23" , value: payload.Response.Detail.Header.ID  ): {}
} 

So as obvious from my answer I just replace the null part with {} , then it stops producing

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"

Upvotes: 2

Manik Magar
Manik Magar

Reputation: 1401

Did you try using skipNullOn attribute on output directive?

dataweave reference

Upvotes: 1

Related Questions