DataWeave XML Reference

DataWeave 1.1 is compatible with Mule Runtime Engine 3.8. MuleSoft recommends against deployments to Mule 3.8. Standard Support for this version ended on November 16, 2018, and Mule 3.8 will reach its End of Life on November 16, 2021, when Extended Support ends.

Instead of using the Studio UI to add a DataWeave script to your Mule projects, you can write a Transform Message component in XML, either through the XML tab in Studio or with an external editor. In fact, certain advanced features (such as the mode attribute used for memory management) are only configurable through the XML.

Note that when you use the Studio UI to create and configure the element, the same XML configuration is created automatically in the XML editor.

DataWeave Dependencies

Namespace and Schema Location

Your Mule project must begin with the following dependencies:


    http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">

Note that these dependencies are automatically added when you drag and drop the corresponding element to your Studio canvas.

Maven Dependency Snippet

If you use Maven on your project, you must also include the following dependencies on your pom.xml Maven file:


Note that for Mule Runtime version 3.8.0, the artifactID is mule-plugin-weave_2.11, not mule-plugin-weave.


The <dw:transform-message> element is the top-level XML tag for the Transform Message component.

<dw:transform-message> Attributes Description


Defines the name of the element as it appears in the Studio canvas.


Refers to Deferred Execution. Accepted values: immediate or deferred. See DataWeave Memory Management.

Adding DataWeave Scripts to the Transform Component

You can either type your DataWeave code into your XML using CDATA within a Transformation element, or you can reference an external .dwl file.

This example that writes a DataWeave script inline within a <dw:set-payload> transformation element:

<dw:transform-message doc:name="Transform Message" mode="immediate">
        %dw 1.0
        %output application/json
  </dw:set-payload >

Here is same example, calling an external .dwl file:

<dw:transform-message doc:name="Transform Message" mode="immediate">
  <dw:set-payload resource="transform.dwl" />

The default location for these files is in the src/main/resources folder in your project.


You can pass DataWeave scripts through these child elements to <dw:transform-message>: <dw:set-payload/>, <dw:set-variable/>, or <dw:set-session-variable/>.

   <dw:set-payload resource="classpath:path/transform.dwl"/>
   <dw:set-variable variableName="myVariable"
   <dw:set-session-variable variableName="mySessionVariable"

The child elements contain many of the same attributes.

Attributes Description


Point to a .dwl file containing a DataWeave transformation script. These values are solved statically. For example, using <dw:set-payload resource="myscript-${env}.dwl"/> generates this error in the Transform Message UI: Unexpected end of input, expected header or content.


When the desired output is a variable, this defines what to name that variable. Not applicable on dw:set-payload.

Handling Multiple Outputs

A single Transform Message element contain several different components that provide content for the output Mule message. Each of the outputs must be defined in a separate .dwl file, as shown in Transformations. For example, one file might define the payload contents, another an outbound property, another a session variable. Each will be part of the same output Mule message.

You do this by adding multiple child elements inside the dw:transform-message component.

Input definitions

<dw:input-payload/> can specify optional parameters about the input, for example:

Attributes of <dw:input-payload> Description


Expected mime type of the input. If you do not provide this attribute, DataWeave will try to read the payload mime type from the metadata.


Points to a file containing a sample input, which is useful at design time when constructing the transformation through the UI. See [Providing Input Sample Data].

<dw:transform-message doc:name="Transform Message">
  <dw:input-payload mimeType="application/xml"
    <![CDATA[%dw 1.0
      %output application/java
        // YOUR DW SCRIPT

Reader Configuration

<dw:reader-property/> settings can tell the reader how to parse the input.

<dw:input-payload doc:sample="list_csv.csv" mimeType="text/csv" >
  <dw:reader-property name="separator" value="|"/>
  <dw:reader-property name="header" value="false"/>

Reader properties depend on the type of the input. For a detailed list of the available properties for each type, see DataWeave Formats.

Full XML Sample

Below is a full Transform Message component described via XML

<dw:transform-message doc:name="Transform Message" mode="immediate">
  <dw:input-payload mimeType="text/csv" doc:sample="sample_data/content.csv">
    <dw:reader-property name="separator" value="|"/>
    <dw:reader-property name="header" value="false"/>
  <dw:set-variable variableName="myVariable">
      %dw 1.0
      %output application/json
  </dw:set-variable >

Memory Management

The mode attribute of the Transform component (dw:transform-message) can be configured to wait to execute the transformation of a large payload until a stream is available for it. You can also set the maximum size of system memory usage for the transformation. For details, see DataWeave Memory Management.

Was this article helpful? Thanks for your feedback!
View on GitHub