SlideShare a Scribd company logo
1 of 10
Mule Concepts
DataWeave III
• Below are the 6 directives, which are used as the key
aspects of the transformation.
– DataWeave version :
• Example : %dw 1.0
– Output type :
• Example : %output application/xml
– Input type :
• Example : %input payload application/xml
– Namespaces :
• Used to import into the transform
• Example : %namespace ns0http://mulesoft.org/tshirt-service/
– Constants :
• Constants which can be referenced through the body.
• Example : %var conversionRate=13.15
– Functions :
• Functions which can be called through the body.
• Example : %var toUser = (user) → {firstName: user.name, lastName:
user.lastName}
DataWeave – Header Directives
• Version Directive :
– Specify the version of the DataWeave syntax that is used to
interpret the transformation using the version directive.
– Example : %dw 1.0
• Namespace Directive :
– Use this directive to specify an alias for a URI, which is
specified after the alias.
– The directive is relevant only when either the input or the
output is of type XML.
– Example : %namespace mes
http://www.mulesoft.com/anypoint/SOA/message/v1.0
DataWeave – Header Directives
• Output Directive:
– Specify the transformation output type in the following
format:
<content>/<type>
– Only one output type can be specified.
– The structure of this output is further specified in the
DataWeave body.
– Example : %output application/xml
DataWeave – Header Directives
• Output Directive:
– Below are the valid types :
• application/java
• application/csv
• text/csv
• application/json
• text/json
• application/xml
• text/xml
• text/plain
• application/dw
DataWeave – Header Directives
• Input Directive :
– Optionally specify an input source and its input type in the
following format:
<content>/<type>
– Example : %input payload application/xml
– It is not necessary to declare input directives for any of the
components of the Mule Message that arrive at the DataWeave
transformer (payload, flow variables, and input/outbound
properties), nor for any system variables.
– You likely will not need this feature as any data arriving inside
the incoming Mule message gets implicitly recognized as input
based on the accompanying metadata that passes along with it
through the flow components.
– As a result, the data can be referenced and acted upon easily
enough anywhere within the DataWeave body without a need
to include them in the header.
DataWeave – Header Directives
• Input Directive:
– Below are the valid types :
• application/java
• application/csv
• text/csv
• application/json
• text/json
• application/xml
• text/xml
• application/dw
DataWeave – Header Directives
• Define Constant Directive :
– You can define a constant in the header, and reference it
(or its child elements, if any exist) in the DataWeave
body.
– Example :
%dw 1.0
%var conversionRate=13.15
%output application/json
---
{
price_dollars: payload.price,
price_localCurrency: payload.price * conversionRate
}
DataWeave – Header Directives
• Define Function Directive :
– You can define a function in the header, you can then call it
in any part of the DataWeave body, including arguments.
– Example 1:
%dw 1.0
%output application/json
%var toUser = (user) -> {firstName: user.name, lastName:
user.lastName}
---
{
user: toUser(payload)
}
DataWeave – Header Directives
• Define Function Directive :
– A function directive can be defined via %var as in the
Example 1, in previous slide , or via %function.
– Example 2:
%dw 1.0
%output application/json
%function toUser(user){firstName: user.name, lastName:
user.lastName}
---
{
user: toUser(payload)
}
DataWeave – Header Directives

More Related Content

What's hot

Data weave documentation
Data weave documentationData weave documentation
Data weave documentationSindhu VL
 
Mule dataweave
Mule dataweaveMule dataweave
Mule dataweaveSon Nguyen
 
Data weave component
Data weave componentData weave component
Data weave componentSindhu VL
 
Mule scopes foreach_scope
Mule scopes foreach_scopeMule scopes foreach_scope
Mule scopes foreach_scopekunal vishe
 
MuleSoft ESB - CSV File to Database
MuleSoft ESB - CSV File to DatabaseMuleSoft ESB - CSV File to Database
MuleSoft ESB - CSV File to Databaseakashdprajapati
 
MuleSoft DataWeave data transformation language
MuleSoft DataWeave data transformation languageMuleSoft DataWeave data transformation language
MuleSoft DataWeave data transformation languagefganora
 
Mule with data weave
Mule with data weaveMule with data weave
Mule with data weaveSon Nguyen
 
Introduction to dataweave
Introduction to dataweaveIntroduction to dataweave
Introduction to dataweaveSwati Deshpande
 
Routing in mule
Routing in muleRouting in mule
Routing in mulevasanthii9
 
Mule tcat server - Server profiles
Mule tcat server - Server profilesMule tcat server - Server profiles
Mule tcat server - Server profilesShanky Gupta
 
Mule Custom Aggregator
Mule Custom AggregatorMule Custom Aggregator
Mule Custom AggregatorAnkush Sharma
 
Mule XSLT Transformer
Mule XSLT TransformerMule XSLT Transformer
Mule XSLT TransformerAnkush Sharma
 

What's hot (19)

Data weave documentation
Data weave documentationData weave documentation
Data weave documentation
 
Mule dataweave
Mule dataweaveMule dataweave
Mule dataweave
 
Data weave component
Data weave componentData weave component
Data weave component
 
Mule scopes foreach_scope
Mule scopes foreach_scopeMule scopes foreach_scope
Mule scopes foreach_scope
 
Mule mel 2
Mule mel 2Mule mel 2
Mule mel 2
 
Dataweave
DataweaveDataweave
Dataweave
 
MuleSoft ESB - CSV File to Database
MuleSoft ESB - CSV File to DatabaseMuleSoft ESB - CSV File to Database
MuleSoft ESB - CSV File to Database
 
MuleSoft DataWeave data transformation language
MuleSoft DataWeave data transformation languageMuleSoft DataWeave data transformation language
MuleSoft DataWeave data transformation language
 
Mule with data weave
Mule with data weaveMule with data weave
Mule with data weave
 
Message state
Message stateMessage state
Message state
 
Introduction to dataweave
Introduction to dataweaveIntroduction to dataweave
Introduction to dataweave
 
xslt in mule
xslt in mulexslt in mule
xslt in mule
 
Passing java arrays in oracle stored procedure from mule esb flow
Passing java arrays in oracle stored procedure from mule esb flowPassing java arrays in oracle stored procedure from mule esb flow
Passing java arrays in oracle stored procedure from mule esb flow
 
Routing in mule
Routing in muleRouting in mule
Routing in mule
 
Mule esb
Mule esbMule esb
Mule esb
 
Mule tcat server - Server profiles
Mule tcat server - Server profilesMule tcat server - Server profiles
Mule tcat server - Server profiles
 
Mule mel 1
Mule mel 1Mule mel 1
Mule mel 1
 
Mule Custom Aggregator
Mule Custom AggregatorMule Custom Aggregator
Mule Custom Aggregator
 
Mule XSLT Transformer
Mule XSLT TransformerMule XSLT Transformer
Mule XSLT Transformer
 

Similar to DataWeave Concepts and Directives

Data weave (MuleSoft)
Data weave (MuleSoft)Data weave (MuleSoft)
Data weave (MuleSoft)Nandu List5
 
Data weave
Data weave Data weave
Data weave Phaniu
 
Data weave
Data weaveData weave
Data weavemanavp
 
Data weave reference documentation
Data weave reference documentationData weave reference documentation
Data weave reference documentationD.Rajesh Kumar
 
Data weave documentation
Data weave documentationData weave documentation
Data weave documentationKhadhar Koneti
 
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...Jitendra Bafna
 
Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200harika thamishetti
 
MuleSoft Meetup Mumbai Mule 4 Presentation Slide
MuleSoft Meetup Mumbai Mule 4 Presentation SlideMuleSoft Meetup Mumbai Mule 4 Presentation Slide
MuleSoft Meetup Mumbai Mule 4 Presentation SlideManish Kumar Yadav
 
Data weave
Data weave Data weave
Data weave Khan625
 

Similar to DataWeave Concepts and Directives (20)

Data weave (MuleSoft)
Data weave (MuleSoft)Data weave (MuleSoft)
Data weave (MuleSoft)
 
Data weave
Data weave Data weave
Data weave
 
Data weave
Data weave Data weave
Data weave
 
Data weave
Data weave Data weave
Data weave
 
Data weave
Data weave Data weave
Data weave
 
Dataweave
Dataweave Dataweave
Dataweave
 
Data weave
Data weaveData weave
Data weave
 
Data weave in Mule
Data weave in MuleData weave in Mule
Data weave in Mule
 
Data weave reference documentation
Data weave reference documentationData weave reference documentation
Data weave reference documentation
 
Data weave in mule
Data weave in muleData weave in mule
Data weave in mule
 
Data weave documentation
Data weave documentationData weave documentation
Data weave documentation
 
Dataweave nagarjuna
Dataweave nagarjunaDataweave nagarjuna
Dataweave nagarjuna
 
Dataweave Basic
Dataweave BasicDataweave Basic
Dataweave Basic
 
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
 
Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200
 
MuleSoft Meetup Mumbai Mule 4 Presentation Slide
MuleSoft Meetup Mumbai Mule 4 Presentation SlideMuleSoft Meetup Mumbai Mule 4 Presentation Slide
MuleSoft Meetup Mumbai Mule 4 Presentation Slide
 
Data weave
Data weave Data weave
Data weave
 
Data weave
Data weave Data weave
Data weave
 
Data weave
Data weave Data weave
Data weave
 
Data weave
Data weave Data weave
Data weave
 

More from kunal vishe

Mule data weave_8
Mule data weave_8Mule data weave_8
Mule data weave_8kunal vishe
 
Mule data weave_4
Mule data weave_4Mule data weave_4
Mule data weave_4kunal vishe
 
Mule scopes request_response_scope
Mule scopes request_response_scopeMule scopes request_response_scope
Mule scopes request_response_scopekunal vishe
 
Mule scopes async_scope
Mule scopes async_scopeMule scopes async_scope
Mule scopes async_scopekunal vishe
 
Mule debugging logging_configuration_in_mule
Mule debugging logging_configuration_in_muleMule debugging logging_configuration_in_mule
Mule debugging logging_configuration_in_mulekunal vishe
 
Mule debugging logging_in_mule
Mule debugging logging_in_muleMule debugging logging_in_mule
Mule debugging logging_in_mulekunal vishe
 
Mule error handling_rollback exception strategy
Mule error handling_rollback exception strategyMule error handling_rollback exception strategy
Mule error handling_rollback exception strategykunal vishe
 
Mule error handling_choice exception strategy
Mule error handling_choice exception strategyMule error handling_choice exception strategy
Mule error handling_choice exception strategykunal vishe
 
Mule concepts exception strategies
Mule concepts exception strategiesMule concepts exception strategies
Mule concepts exception strategieskunal vishe
 
Mule concepts filters scopes_routers
Mule concepts filters scopes_routersMule concepts filters scopes_routers
Mule concepts filters scopes_routerskunal vishe
 
Mule concepts transformers
Mule concepts transformersMule concepts transformers
Mule concepts transformerskunal vishe
 
Mule concepts components
Mule concepts componentsMule concepts components
Mule concepts componentskunal vishe
 
Mule concepts connectors
Mule concepts connectorsMule concepts connectors
Mule concepts connectorskunal vishe
 
Mule concepts elements in a mule flow
Mule concepts elements in a mule flowMule concepts elements in a mule flow
Mule concepts elements in a mule flowkunal vishe
 
Mule concepts flows
Mule concepts flowsMule concepts flows
Mule concepts flowskunal vishe
 

More from kunal vishe (20)

Mule data weave_8
Mule data weave_8Mule data weave_8
Mule data weave_8
 
Mule data weave_4
Mule data weave_4Mule data weave_4
Mule data weave_4
 
Mule mel 4_tips
Mule mel 4_tipsMule mel 4_tips
Mule mel 4_tips
 
Mule mel 3
Mule mel 3Mule mel 3
Mule mel 3
 
Mule scopes request_response_scope
Mule scopes request_response_scopeMule scopes request_response_scope
Mule scopes request_response_scope
 
Mule scopes async_scope
Mule scopes async_scopeMule scopes async_scope
Mule scopes async_scope
 
Mule scopes 2
Mule scopes 2Mule scopes 2
Mule scopes 2
 
Mule scopes 1
Mule scopes 1Mule scopes 1
Mule scopes 1
 
Mule debugging logging_configuration_in_mule
Mule debugging logging_configuration_in_muleMule debugging logging_configuration_in_mule
Mule debugging logging_configuration_in_mule
 
Mule debugging logging_in_mule
Mule debugging logging_in_muleMule debugging logging_in_mule
Mule debugging logging_in_mule
 
Mule error handling_rollback exception strategy
Mule error handling_rollback exception strategyMule error handling_rollback exception strategy
Mule error handling_rollback exception strategy
 
Mule message
Mule messageMule message
Mule message
 
Mule error handling_choice exception strategy
Mule error handling_choice exception strategyMule error handling_choice exception strategy
Mule error handling_choice exception strategy
 
Mule concepts exception strategies
Mule concepts exception strategiesMule concepts exception strategies
Mule concepts exception strategies
 
Mule concepts filters scopes_routers
Mule concepts filters scopes_routersMule concepts filters scopes_routers
Mule concepts filters scopes_routers
 
Mule concepts transformers
Mule concepts transformersMule concepts transformers
Mule concepts transformers
 
Mule concepts components
Mule concepts componentsMule concepts components
Mule concepts components
 
Mule concepts connectors
Mule concepts connectorsMule concepts connectors
Mule concepts connectors
 
Mule concepts elements in a mule flow
Mule concepts elements in a mule flowMule concepts elements in a mule flow
Mule concepts elements in a mule flow
 
Mule concepts flows
Mule concepts flowsMule concepts flows
Mule concepts flows
 

Recently uploaded

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 

DataWeave Concepts and Directives

  • 2. • Below are the 6 directives, which are used as the key aspects of the transformation. – DataWeave version : • Example : %dw 1.0 – Output type : • Example : %output application/xml – Input type : • Example : %input payload application/xml – Namespaces : • Used to import into the transform • Example : %namespace ns0http://mulesoft.org/tshirt-service/ – Constants : • Constants which can be referenced through the body. • Example : %var conversionRate=13.15 – Functions : • Functions which can be called through the body. • Example : %var toUser = (user) → {firstName: user.name, lastName: user.lastName} DataWeave – Header Directives
  • 3. • Version Directive : – Specify the version of the DataWeave syntax that is used to interpret the transformation using the version directive. – Example : %dw 1.0 • Namespace Directive : – Use this directive to specify an alias for a URI, which is specified after the alias. – The directive is relevant only when either the input or the output is of type XML. – Example : %namespace mes http://www.mulesoft.com/anypoint/SOA/message/v1.0 DataWeave – Header Directives
  • 4. • Output Directive: – Specify the transformation output type in the following format: <content>/<type> – Only one output type can be specified. – The structure of this output is further specified in the DataWeave body. – Example : %output application/xml DataWeave – Header Directives
  • 5. • Output Directive: – Below are the valid types : • application/java • application/csv • text/csv • application/json • text/json • application/xml • text/xml • text/plain • application/dw DataWeave – Header Directives
  • 6. • Input Directive : – Optionally specify an input source and its input type in the following format: <content>/<type> – Example : %input payload application/xml – It is not necessary to declare input directives for any of the components of the Mule Message that arrive at the DataWeave transformer (payload, flow variables, and input/outbound properties), nor for any system variables. – You likely will not need this feature as any data arriving inside the incoming Mule message gets implicitly recognized as input based on the accompanying metadata that passes along with it through the flow components. – As a result, the data can be referenced and acted upon easily enough anywhere within the DataWeave body without a need to include them in the header. DataWeave – Header Directives
  • 7. • Input Directive: – Below are the valid types : • application/java • application/csv • text/csv • application/json • text/json • application/xml • text/xml • application/dw DataWeave – Header Directives
  • 8. • Define Constant Directive : – You can define a constant in the header, and reference it (or its child elements, if any exist) in the DataWeave body. – Example : %dw 1.0 %var conversionRate=13.15 %output application/json --- { price_dollars: payload.price, price_localCurrency: payload.price * conversionRate } DataWeave – Header Directives
  • 9. • Define Function Directive : – You can define a function in the header, you can then call it in any part of the DataWeave body, including arguments. – Example 1: %dw 1.0 %output application/json %var toUser = (user) -> {firstName: user.name, lastName: user.lastName} --- { user: toUser(payload) } DataWeave – Header Directives
  • 10. • Define Function Directive : – A function directive can be defined via %var as in the Example 1, in previous slide , or via %function. – Example 2: %dw 1.0 %output application/json %function toUser(user){firstName: user.name, lastName: user.lastName} --- { user: toUser(payload) } DataWeave – Header Directives