SlideShare une entreprise Scribd logo
1  sur  15
Using XSLT in Mule (For beginner )
We often use XSLT in our application to transform XML
payload from one form to another . Mule also supports XSLT
in it’s application with XSLT-Transformer component.
So, How can we use XSLT in Mule application??
.
Here I will show you how ……
Before we start we must see what an XSLT actually is :-
As per XSLT definition :-
XSLT (Extensible Stylesheet Language Transformations) is a language
for transforming XML documents into other XML documents, or other
formats such as HTML for web pages, plain text or into XSL Formatting
Objects, which may subsequently be converted to other formats, such
as PDF PostScript and PNG.
Source :- http://en.wikipedia.org/wiki/XSLT
So, XSLT can be use to transform one form of XML to another :-
Here you can see the XSLT is transforming the XML payload into another XML
So, let us try this example in our Mule application
Here we will be using XSLT for transforming the XML payload into another XML
like below :-
So let’s consider we have a following flow in our Mule application:-
As you can see we have used a Http inbound end point followed by a set payload
component and then XSLT transformer.
Here the set payload contain the XML that need to be transform
So set payload component contains the following payload :-
Our corresponding Mule flow will be as follows :-
<flow name="xsltFlow1" doc:name="xsltFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081"
path="test" doc:name="HTTP"/>
<set-payload
value="&lt;RootElement&gt;&lt;Name&gt;Anirban&lt;/Name&gt;&lt;Department&gt;ATS&lt;/D
epartment&gt;&lt;Designation&gt;SSE&lt;/Designation&gt;&lt;/RootElement&gt;"
doc:name="Set Payload"/>
<mulexml:xslt-transformer
maxIdleTransformers="2" maxActiveTransformers="5" outputEncoding="UTF-8"
doc:name="Transform from outer to inner" xsl-file="Transform.xslt"
encoding="UTF-8" returnClass="java.lang.String" />
</flow>
As you can see we are using XSLT file :- Transform.xslt
So, the file Transform.xslt
should be in our src/main/resource folder
The file Transform.xslt
Contains following code to transform :-
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes" />
<xsl:template match="/">
<NewRootElement>
<NewName>
<xsl:value-of select="RootElement/Name" />
</NewName>
<NewDepartment>
<xsl:value-of select="RootElement/Department" />
</NewDepartment>
<NewDesignation>
<xsl:value-of select="RootElement/Designation" />
</NewDesignation>
</NewRootElement>
</xsl:template>
</xsl:stylesheet>
To test the application we hit the url http://localhost:8081/test in our
browser and we get the following :-
And you can see the XML payload has been transferred to this new XML
Hope you enjoyed the simple yet an amazing trick in Mule
Using xslt in mule

Contenu connexe

Tendances

Tendances (13)

Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
File component in mule demo
File component in mule demoFile component in mule demo
File component in mule demo
 
Mule requesterdemo
Mule requesterdemoMule requesterdemo
Mule requesterdemo
 
Mule XSLT Transformer
Mule XSLT TransformerMule XSLT Transformer
Mule XSLT Transformer
 
Idempotent filter with simple file
Idempotent filter with simple fileIdempotent filter with simple file
Idempotent filter with simple file
 
Mule Message Properties Component
Mule Message Properties ComponentMule Message Properties Component
Mule Message Properties Component
 
Choice component in mule demo
Choice component in mule demoChoice component in mule demo
Choice component in mule demo
 
Message properties component in mule demo
Message properties component in mule demoMessage properties component in mule demo
Message properties component in mule demo
 
Mule esb transformers
Mule esb transformersMule esb transformers
Mule esb transformers
 
Json to json transformation in mule
Json to json transformation in muleJson to json transformation in mule
Json to json transformation in mule
 
Until successful component in mule
Until successful component in muleUntil successful component in mule
Until successful component in mule
 
File component in mule
File component in muleFile component in mule
File component in mule
 
Mule esb
Mule esbMule esb
Mule esb
 

Similaire à Using xslt in mule

Similaire à Using xslt in mule (20)

Xslt in mule
Xslt in muleXslt in mule
Xslt in mule
 
Xslt in mule
Xslt in muleXslt in mule
Xslt in mule
 
Xslt in mule
Xslt in muleXslt in mule
Xslt in mule
 
Xml transform
Xml transformXml transform
Xml transform
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
Xml to xml transformation
Xml to xml transformationXml to xml transformation
Xml to xml transformation
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
Transformation xmltoobjectesb
Transformation xmltoobjectesbTransformation xmltoobjectesb
Transformation xmltoobjectesb
 
Xml toobjectesbtransform
Xml toobjectesbtransformXml toobjectesbtransform
Xml toobjectesbtransform
 
Transformation xmltoobjectesb
Transformation xmltoobjectesbTransformation xmltoobjectesb
Transformation xmltoobjectesb
 
Transformation xmltoobjectesb
Transformation xmltoobjectesbTransformation xmltoobjectesb
Transformation xmltoobjectesb
 
Transformation xmltoobjectesb
Transformation xmltoobjectesbTransformation xmltoobjectesb
Transformation xmltoobjectesb
 
XSLT
XSLTXSLT
XSLT
 
XML Transformations With PHP
XML Transformations With PHPXML Transformations With PHP
XML Transformations With PHP
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformer
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformer
 

Plus de Rajkattamuri (20)

Github plugin setup in anypointstudio
Github plugin setup in anypointstudioGithub plugin setup in anypointstudio
Github plugin setup in anypointstudio
 
For each component in mule
For each component in muleFor each component in mule
For each component in mule
 
Filter expression in mule
Filter expression in muleFilter expression in mule
Filter expression in mule
 
Database component in mule
Database component in muleDatabase component in mule
Database component in mule
 
Choice component in mule
Choice component in mule Choice component in mule
Choice component in mule
 
WebServices
WebServicesWebServices
WebServices
 
Java Basics in Mule
Java Basics in MuleJava Basics in Mule
Java Basics in Mule
 
WebServices Basic Overview
WebServices Basic OverviewWebServices Basic Overview
WebServices Basic Overview
 
Java For Begineers
Java For BegineersJava For Begineers
Java For Begineers
 
Java Basics
Java BasicsJava Basics
Java Basics
 
WebServices Basics
WebServices BasicsWebServices Basics
WebServices Basics
 
Core java
Core javaCore java
Core java
 
WebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIWebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDI
 
Web services soap
Web services soapWeb services soap
Web services soap
 
Web services wsdl
Web services wsdlWeb services wsdl
Web services wsdl
 
Web services uddi
Web services uddiWeb services uddi
Web services uddi
 
Maven
MavenMaven
Maven
 
Mule esb dataweave
Mule esb dataweaveMule esb dataweave
Mule esb dataweave
 
Mule with drools
Mule with drools Mule with drools
Mule with drools
 
Mule with quartz
Mule with quartz Mule with quartz
Mule with quartz
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

Using xslt in mule

  • 1. Using XSLT in Mule (For beginner )
  • 2. We often use XSLT in our application to transform XML payload from one form to another . Mule also supports XSLT in it’s application with XSLT-Transformer component.
  • 3. So, How can we use XSLT in Mule application?? .
  • 4. Here I will show you how ……
  • 5. Before we start we must see what an XSLT actually is :- As per XSLT definition :- XSLT (Extensible Stylesheet Language Transformations) is a language for transforming XML documents into other XML documents, or other formats such as HTML for web pages, plain text or into XSL Formatting Objects, which may subsequently be converted to other formats, such as PDF PostScript and PNG. Source :- http://en.wikipedia.org/wiki/XSLT
  • 6. So, XSLT can be use to transform one form of XML to another :- Here you can see the XSLT is transforming the XML payload into another XML
  • 7. So, let us try this example in our Mule application Here we will be using XSLT for transforming the XML payload into another XML like below :-
  • 8. So let’s consider we have a following flow in our Mule application:- As you can see we have used a Http inbound end point followed by a set payload component and then XSLT transformer. Here the set payload contain the XML that need to be transform
  • 9. So set payload component contains the following payload :-
  • 10. Our corresponding Mule flow will be as follows :- <flow name="xsltFlow1" doc:name="xsltFlow1"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="test" doc:name="HTTP"/> <set-payload value="&lt;RootElement&gt;&lt;Name&gt;Anirban&lt;/Name&gt;&lt;Department&gt;ATS&lt;/D epartment&gt;&lt;Designation&gt;SSE&lt;/Designation&gt;&lt;/RootElement&gt;" doc:name="Set Payload"/> <mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" outputEncoding="UTF-8" doc:name="Transform from outer to inner" xsl-file="Transform.xslt" encoding="UTF-8" returnClass="java.lang.String" /> </flow> As you can see we are using XSLT file :- Transform.xslt
  • 11. So, the file Transform.xslt should be in our src/main/resource folder
  • 12. The file Transform.xslt Contains following code to transform :- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes" /> <xsl:template match="/"> <NewRootElement> <NewName> <xsl:value-of select="RootElement/Name" /> </NewName> <NewDepartment> <xsl:value-of select="RootElement/Department" /> </NewDepartment> <NewDesignation> <xsl:value-of select="RootElement/Designation" /> </NewDesignation> </NewRootElement> </xsl:template> </xsl:stylesheet>
  • 13. To test the application we hit the url http://localhost:8081/test in our browser and we get the following :- And you can see the XML payload has been transferred to this new XML
  • 14. Hope you enjoyed the simple yet an amazing trick in Mule