SlideShare a Scribd company logo
How to use DataWeave
component
14-05-2015
Abstract
• The main motto of this PPT is How to use
DataWeave in our applications.
Introduction
• The DataWeave language is a simple,
powerful tool to query and transform data
inside of Mule.
Example
.mflow
• <?xml version="1.0" encoding="UTF-8"?>
• <mule xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
• xmlns:spring="http://www.springframework.org/schema/beans"
• xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
• xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
• http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
• http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
• http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
• <flow name="dataweaveFlow">
• <file:inbound-endpoint path="D:csvcontact" responseTimeout="10000" doc:name="File"/>
• <logger message="flow started" level="INFO" doc:name="Logger"/>
• <dw:transform-message metadata:id="5e76ab87-23c8-4c36-9618-6620c53520f8" doc:name="Transform Message">
• <dw:set-payload><![CDATA[%dw 1.0
• %output application/json
• ---
• {
•
•
• Address: {
•
•
•
• Country: payload.Address.Country,
•
•
• State: payload.Address.State
• ,
•
• City: payload.Address.City
• }
• }]]></dw:set-payload>
• </dw:transform-message>
• <logger message="--Output--#[message.payloadAs(java.lang.String)]--" level="INFO" doc:name="Logger"/>
• </flow>
• </mule>
• Output:
• INFO 2016-05-06 12:38:07,038
[[dataweave].connector.file.mule.default.receiver.01]
org.mule.transport.file.FileMessageReceiver: Lock obtained on file:
D:csvcontactsample.xml
• INFO 2016-05-06 12:38:07,038 [[dataweave].dataweaveFlow.stage1.05]
org.mule.api.processor.LoggerMessageProcessor: flow started
• INFO 2016-05-06 12:38:07,038 [[dataweave].dataweaveFlow.stage1.05]
org.mule.api.processor.LoggerMessageProcessor: --Output--{
• "Address": {
• "Country": "India",
• "State": "AP",
• "City": "Dharmavaram"
• }
• }--
•
•
•
• Flow of execution:
1. The above flow is used to convert xml to JSON
using DataWeave
2. It will pick the .xml file from specific location and
will convert and display json response in console
3. Sample xml:
<Address>
<Country>India</Country>
<State>AP</State>
<City>Dharmavaram</City>
</Address>
References
• https://docs.mulesoft.com/mule-user-
guide/v/3.7/dataweave

More Related Content

PPTX
How to use data mapper transformer
PPTX
Database Component
PPTX
How to use wildcard filter
PPTX
How to use bean as datasource in database connector
PPTX
How to use data mapper transformer
PPTX
Database component in mule
PPTX
How to use message properties component
PPTX
Message properties component in Mule
How to use data mapper transformer
Database Component
How to use wildcard filter
How to use bean as datasource in database connector
How to use data mapper transformer
Database component in mule
How to use message properties component
Message properties component in Mule

What's hot (11)

PPTX
How to use message properties component
PPTX
PPTX
PPTX
Message properties component in mule
PPTX
Wildcard Filter
PPTX
Defining global exception strategies
PPTX
Collection aggregator
PPTX
Validate json schema
PPTX
Reference exception strategy
PPTX
Expression filter in Mule
PPTX
How to use expression filter
How to use message properties component
Message properties component in mule
Wildcard Filter
Defining global exception strategies
Collection aggregator
Validate json schema
Reference exception strategy
Expression filter in Mule
How to use expression filter
Ad

Viewers also liked (20)

PPTX
Bean as Datasource
PPTX
How to use IMAP endpoint
PPTX
PPTX
How to use jms outbound endpoint
PPTX
Dockerizing mule soft esb
PPTX
How to use poll scope
PPTX
Cloud hub deployment
PPTX
Integrate mule esb with microsoft office 365 share point
PPTX
Securing api with_o_auth2
PPTX
How to use processor chain
PPTX
How to use parse template
PPTX
How to read json message payload
PPTX
How to use attachment transformer
PPTX
How to use web service consumer
PPTX
How to use message enricher
PPTX
Specifying a default exception strategy
PPTX
Soap Component
PPTX
Mule esb with amazon s3 Integration
PPTX
Integration with dropbox using mule esb
Bean as Datasource
How to use IMAP endpoint
How to use jms outbound endpoint
Dockerizing mule soft esb
How to use poll scope
Cloud hub deployment
Integrate mule esb with microsoft office 365 share point
Securing api with_o_auth2
How to use processor chain
How to use parse template
How to read json message payload
How to use attachment transformer
How to use web service consumer
How to use message enricher
Specifying a default exception strategy
Soap Component
Mule esb with amazon s3 Integration
Integration with dropbox using mule esb
Ad

Similar to How to use data weave (20)

PDF
DataWeave and Error Handling Meetup at SF Tower Sept 24th
PPTX
PPTX
mule introduction to dataweave
PPTX
#11 DataWeave Extension Library using Visual Studio Code
PDF
Dataweave_library_extension.pdf
PPTX
Mule soft meetup_charlotte_4__draft_v2.0
PPTX
Mule soft meetup__official__feb-27_2021
PPTX
Data weave in mule
PPTX
Dataweave in studio
PPTX
DataWeave Extension Library
PPTX
Data weave in Mule
PPTX
Dataweave Basic
PDF
Data weave
PDF
Pune Mule Meetups July 2019
PPTX
Dataweave
PPTX
Data weave
PPTX
Data weave
PPTX
Data weave
PPTX
Data weave
PPTX
Dataweave nagarjuna
DataWeave and Error Handling Meetup at SF Tower Sept 24th
mule introduction to dataweave
#11 DataWeave Extension Library using Visual Studio Code
Dataweave_library_extension.pdf
Mule soft meetup_charlotte_4__draft_v2.0
Mule soft meetup__official__feb-27_2021
Data weave in mule
Dataweave in studio
DataWeave Extension Library
Data weave in Mule
Dataweave Basic
Data weave
Pune Mule Meetups July 2019
Dataweave
Data weave
Data weave
Data weave
Data weave
Dataweave nagarjuna

More from sivachandra mandalapu (16)

PPTX
Mock component in munit
PPTX
Jms selector
PPTX
PPTX
Object store
PPTX
How to use SFTP
PPTX
How to use secure property placeholder
PPTX
PPTX
Property place holder
PPTX
Deployment options for mule applications
PPTX
Setting up organization with api access
PPTX
API gateway setup
PPTX
PPTX
Synchronous communication using jms back channel
PPTX
PPTX
Rest Component
PPTX
Integration of mule esb with microsoft azure
Mock component in munit
Jms selector
Object store
How to use SFTP
How to use secure property placeholder
Property place holder
Deployment options for mule applications
Setting up organization with api access
API gateway setup
Synchronous communication using jms back channel
Rest Component
Integration of mule esb with microsoft azure

Recently uploaded (20)

PPTX
Institutional Correction lecture only . . .
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Lesson notes of climatology university.
PDF
Complications of Minimal Access Surgery at WLH
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Pre independence Education in Inndia.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
master seminar digital applications in india
PPTX
Cell Structure & Organelles in detailed.
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Institutional Correction lecture only . . .
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Pharma ospi slides which help in ospi learning
Lesson notes of climatology university.
Complications of Minimal Access Surgery at WLH
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Pre independence Education in Inndia.pdf
VCE English Exam - Section C Student Revision Booklet
Microbial diseases, their pathogenesis and prophylaxis
master seminar digital applications in india
Cell Structure & Organelles in detailed.
Module 4: Burden of Disease Tutorial Slides S2 2025
Final Presentation General Medicine 03-08-2024.pptx
Anesthesia in Laparoscopic Surgery in India
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Chapter 2 Heredity, Prenatal Development, and Birth.pdf

How to use data weave

  • 1. How to use DataWeave component 14-05-2015
  • 2. Abstract • The main motto of this PPT is How to use DataWeave in our applications.
  • 3. Introduction • The DataWeave language is a simple, powerful tool to query and transform data inside of Mule.
  • 5. .mflow • <?xml version="1.0" encoding="UTF-8"?> • <mule xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" • xmlns:spring="http://www.springframework.org/schema/beans" • xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" • xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd • http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd • http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd • http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd"> • <flow name="dataweaveFlow"> • <file:inbound-endpoint path="D:csvcontact" responseTimeout="10000" doc:name="File"/> • <logger message="flow started" level="INFO" doc:name="Logger"/> • <dw:transform-message metadata:id="5e76ab87-23c8-4c36-9618-6620c53520f8" doc:name="Transform Message"> • <dw:set-payload><![CDATA[%dw 1.0 • %output application/json • --- • { • • • Address: { • • • • Country: payload.Address.Country, • • • State: payload.Address.State • , • • City: payload.Address.City • } • }]]></dw:set-payload> • </dw:transform-message> • <logger message="--Output--#[message.payloadAs(java.lang.String)]--" level="INFO" doc:name="Logger"/> • </flow> • </mule>
  • 6. • Output: • INFO 2016-05-06 12:38:07,038 [[dataweave].connector.file.mule.default.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: D:csvcontactsample.xml • INFO 2016-05-06 12:38:07,038 [[dataweave].dataweaveFlow.stage1.05] org.mule.api.processor.LoggerMessageProcessor: flow started • INFO 2016-05-06 12:38:07,038 [[dataweave].dataweaveFlow.stage1.05] org.mule.api.processor.LoggerMessageProcessor: --Output--{ • "Address": { • "Country": "India", • "State": "AP", • "City": "Dharmavaram" • } • }-- • • •
  • 7. • Flow of execution: 1. The above flow is used to convert xml to JSON using DataWeave 2. It will pick the .xml file from specific location and will convert and display json response in console 3. Sample xml: <Address> <Country>India</Country> <State>AP</State> <City>Dharmavaram</City> </Address>