Search code examples
xmlmuledataweavemulesoftmule-esb

How to define multiple namespace in xml header tag in dwl 2.0 in mulesoft?


Success

How to include two namespace in dwl 2.0?


Solution

  • You mean just use two XML namespaces in an XML output?

    %dw 2.0
    output application/xml
    ns orders http://www.acme.com/shemas/Orders
    ns stores http://www.acme.com/shemas/Stores
    ---
    root:
        orders#orders: {
            stores#shipNodeId: "SF01",
            stores#shipNodeId @(shipsVia:"LA01"): "NY03"
        }
    

    Output:

    <?xml version='1.0' encoding='UTF-8'?>
    <root>
      <orders:orders xmlns:orders="http://www.acme.com/shemas/Orders">
        <stores:shipNodeId xmlns:stores="http://www.acme.com/shemas/Stores">SF01</stores:shipNodeId>
        <stores:shipNodeId xmlns:stores="http://www.acme.com/shemas/Stores" shipsVia="LA01">NY03</stores:shipNodeId>
      </orders:orders>
    </root>
    

    Taken from the cookbook in the docs: https://docs.mulesoft.com/mule-runtime/4.3/dataweave-cookbook-include-xml-namespaces