SlideShare uma empresa Scribd logo
1 de 21
 An XML transformation language is
a programming language designed
specifically to transform
an input XML document into an output
document which satisfies some specific goal.
 There are two special cases of
transformation:
 XML to XML: the output document is an XML
document.
 XML to Data: the output document is a byte
stream.
 XSLT
- XSLT is a language for transforming
XML documents into XHTML documents or
to other XML documents.
 XPATH
- XPath is a language for navigating in XML
documents.
 XQUERY
- XQuery was designed to query XML data.
 XSLT stands for XSL Transformations
 XSLT is the most important part of XSL
 XSL stands for
EXtensible Stylesheet Language.
 XSL describes how the XML document should
be displayed
 XSLT transforms an XML document into
another XML document
 XSLT uses XPath to navigate in XML
documents
 XSLT is a W3C Recommendation
 The root element that declares the document
to be an XSL style sheet is <xsl:stylesheet>
or <xsl:transform>.
 <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Tr
ansform">
 Or
 <xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Tr
ansform">
 XPath is used to navigate through elements and
attributes in an XML document.
 XPath is a syntax for defining parts of an XML
document
 XPath uses path expressions to navigate in XML
documents
 XPath contains a library of standard functions
 XPath is a major element in XSLT
 XPath is a W3C recommendation
 XPath uses path expressions to select nodes or
node-sets in an XML document.
 The <xsl:template> element is used to build
templates.
 The match attribute is used to associate a
template with an XML element. The match
attribute can also be used to define a
template for the entire XML document. The
value of the match attribute is an XPath
expression (i.e. match="/" defines the whole
document).
 The <xsl:value-of> Element
 The <xsl:value-of> element can be used to
extract the value of an XML element and add
it to the Output stream of the transformation
 The <xsl:for-each> Element
 The XSL <xsl:for-each> element can be used
to select every XML element of a specified
node-set:
 Example:
 We want to transform the following XML document ("cdcatalog.xml") into HTML:
 <?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>USA</country>
<company>Columbia</company>
<price>20.90</price>
<year>1986</year>
</cd>
</catalog>
Save it as cdcatalog.xml
 Then you create an XSL Style Sheet ("cdcatalog.xsl") with a transformation template:
 <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Add the XSL style sheet reference to your XML document ("cdcatalog.xml"):
 <?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>USA</country>
<company>Columbia</company>
<price>20.90</price>
<year>1986</year>
</cd>
</catalog>
 XQuery is designed to query XML data - not
just XML files, but anything that can appear
as XML, including databases.
 XQuery is the language for querying XML data
 XQuery for XML is like SQL for databases
 XQuery is built on XPath expressions
 XQuery is supported by all major databases
 XQuery is a W3C Recommendation
 XQuery is a language for finding and
extracting elements and attributes from XML
documents.
 Functions
 XQuery uses functions to extract data from
XML documents.
 The doc() function is used to open the
"books.xml" file:
 doc("books.xml")
 Path Expressions
 XQuery uses path expressions to navigate
through elements in an XML document.
 The following path expression is used to
select all the title elements in the "books.xml"
file:
 doc("books.xml")/bookstore/book/title
 (/bookstore selects the bookstore element,
/book selects all the book elements under the
bookstore element, and /title selects all the
title elements under each book element)
 doc("books.xml")/bookstore/book[price>30]/
title
 The expression above will select all the title
elements under the book elements that are
under the bookstore element that have a
price element with a value that is higher than
30.
 XLink is short for XML Linking Language
 XLink is used to create hyperlinks in XML
documents
 Any element in an XML document can behave as
a link
 XLink supports simple links (like HTML) and
extended links (for linking multiple resources
together)
 With XLink, the links can be defined outside the
linked files
 XLink is a W3C Recommendation
 <?xml version="1.0" encoding="UTF-8"?>
<homepages
xmlns:xlink="http://www.w3.org/1999/xlink">
<homepage xlink:type="simple"
xlink:href="http://www.w3schools.com">Visit
W3Schools</homepage>
<homepage xlink:type="simple"
xlink:href="http://www.w3.org">Visit
W3C</homepage>
</homepages>
 http://www.w3schools.com
 http://en.wikipedia.org/wiki/XML_transforma
tion_language

Mais conteúdo relacionado

Mais procurados (20)

Xml schema
Xml schemaXml schema
Xml schema
 
Xml
XmlXml
Xml
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
XSLT
XSLTXSLT
XSLT
 
DTD
DTDDTD
DTD
 
Xml Presentation-3
Xml Presentation-3Xml Presentation-3
Xml Presentation-3
 
X FILES
X FILESX FILES
X FILES
 
02 well formed and valid documents
02 well formed and valid documents02 well formed and valid documents
02 well formed and valid documents
 
Xhtml
XhtmlXhtml
Xhtml
 
XML
XMLXML
XML
 
XML Schema
XML SchemaXML Schema
XML Schema
 
Xpath
XpathXpath
Xpath
 
XML-Extensible Markup Language
XML-Extensible Markup Language XML-Extensible Markup Language
XML-Extensible Markup Language
 
Xml
XmlXml
Xml
 
XML DTD and Schema
XML DTD and SchemaXML DTD and Schema
XML DTD and Schema
 
Xml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web TechnologyXml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web Technology
 
Xml
XmlXml
Xml
 
fundamentals of XML
fundamentals of XMLfundamentals of XML
fundamentals of XML
 
XQuery
XQueryXQuery
XQuery
 

Destaque

Lebowski Publishers - Najaar 2014
Lebowski Publishers - Najaar 2014Lebowski Publishers - Najaar 2014
Lebowski Publishers - Najaar 2014Xanne Liebregts
 
Question Four
Question FourQuestion Four
Question Fourbethxl
 
Bao cao jua ki
Bao cao jua kiBao cao jua ki
Bao cao jua kiTuan Huy
 
Biotechnology august2013-130926012214-phpapp02
Biotechnology august2013-130926012214-phpapp02Biotechnology august2013-130926012214-phpapp02
Biotechnology august2013-130926012214-phpapp02Supa Buoy
 
about Pangkalpinang in English
about Pangkalpinang in Englishabout Pangkalpinang in English
about Pangkalpinang in EnglishSelvhiee Rd
 
Visita al cole de una ilustradora
Visita al cole de una ilustradoraVisita al cole de una ilustradora
Visita al cole de una ilustradora1ciclo2013-14
 
Elsevier: CSUN Alt Text Project
Elsevier: CSUN Alt Text ProjectElsevier: CSUN Alt Text Project
Elsevier: CSUN Alt Text ProjectTripp Narup
 
Bar charts for questtionnaire
Bar charts for questtionnaireBar charts for questtionnaire
Bar charts for questtionnairedanielr97
 
Energia eva georgana 4rtA
Energia eva georgana 4rtAEnergia eva georgana 4rtA
Energia eva georgana 4rtAevaelfk
 
Module thong ke truy cap va footer
Module thong ke truy cap va footerModule thong ke truy cap va footer
Module thong ke truy cap va footerTuan Huy
 
Designing & Managing Product
Designing & Managing ProductDesigning & Managing Product
Designing & Managing Productshilmihnisa Nisa
 
Representation
RepresentationRepresentation
Representationbethxl
 
What can my school of talk do for you
What can my school of talk do for youWhat can my school of talk do for you
What can my school of talk do for youNiki Skene
 
GIL_2012_Africa_BU_Presentation_on_Mega_Trends_Africa_Telecoms_and_IT_by_Chan...
GIL_2012_Africa_BU_Presentation_on_Mega_Trends_Africa_Telecoms_and_IT_by_Chan...GIL_2012_Africa_BU_Presentation_on_Mega_Trends_Africa_Telecoms_and_IT_by_Chan...
GIL_2012_Africa_BU_Presentation_on_Mega_Trends_Africa_Telecoms_and_IT_by_Chan...Chantel Lindeman
 

Destaque (18)

Lebowski Publishers - Najaar 2014
Lebowski Publishers - Najaar 2014Lebowski Publishers - Najaar 2014
Lebowski Publishers - Najaar 2014
 
Question Four
Question FourQuestion Four
Question Four
 
Bao cao jua ki
Bao cao jua kiBao cao jua ki
Bao cao jua ki
 
Mypp
MyppMypp
Mypp
 
Biotechnology august2013-130926012214-phpapp02
Biotechnology august2013-130926012214-phpapp02Biotechnology august2013-130926012214-phpapp02
Biotechnology august2013-130926012214-phpapp02
 
North east
North eastNorth east
North east
 
Clase de ed
Clase de edClase de ed
Clase de ed
 
about Pangkalpinang in English
about Pangkalpinang in Englishabout Pangkalpinang in English
about Pangkalpinang in English
 
Visita al cole de una ilustradora
Visita al cole de una ilustradoraVisita al cole de una ilustradora
Visita al cole de una ilustradora
 
Elsevier: CSUN Alt Text Project
Elsevier: CSUN Alt Text ProjectElsevier: CSUN Alt Text Project
Elsevier: CSUN Alt Text Project
 
Hosting
HostingHosting
Hosting
 
Bar charts for questtionnaire
Bar charts for questtionnaireBar charts for questtionnaire
Bar charts for questtionnaire
 
Energia eva georgana 4rtA
Energia eva georgana 4rtAEnergia eva georgana 4rtA
Energia eva georgana 4rtA
 
Module thong ke truy cap va footer
Module thong ke truy cap va footerModule thong ke truy cap va footer
Module thong ke truy cap va footer
 
Designing & Managing Product
Designing & Managing ProductDesigning & Managing Product
Designing & Managing Product
 
Representation
RepresentationRepresentation
Representation
 
What can my school of talk do for you
What can my school of talk do for youWhat can my school of talk do for you
What can my school of talk do for you
 
GIL_2012_Africa_BU_Presentation_on_Mega_Trends_Africa_Telecoms_and_IT_by_Chan...
GIL_2012_Africa_BU_Presentation_on_Mega_Trends_Africa_Telecoms_and_IT_by_Chan...GIL_2012_Africa_BU_Presentation_on_Mega_Trends_Africa_Telecoms_and_IT_by_Chan...
GIL_2012_Africa_BU_Presentation_on_Mega_Trends_Africa_Telecoms_and_IT_by_Chan...
 

Semelhante a Xml transformation language

Semelhante a Xml transformation language (20)

Xslt
XsltXslt
Xslt
 
Xslt
XsltXslt
Xslt
 
Introduction to XSLT
Introduction to XSLTIntroduction to XSLT
Introduction to XSLT
 
XPATH_XSLT-1.pptx
XPATH_XSLT-1.pptxXPATH_XSLT-1.pptx
XPATH_XSLT-1.pptx
 
Xslt
XsltXslt
Xslt
 
Integrative Programming and Technology Chapter 4- Dr. J. VijiPriya
Integrative Programming and Technology Chapter 4- Dr. J. VijiPriyaIntegrative Programming and Technology Chapter 4- Dr. J. VijiPriya
Integrative Programming and Technology Chapter 4- Dr. J. VijiPriya
 
Overview of XSL, XPath and XSL-FO
Overview of XSL, XPath and XSL-FOOverview of XSL, XPath and XSL-FO
Overview of XSL, XPath and XSL-FO
 
Session 4
Session 4Session 4
Session 4
 
Xml 2
Xml  2 Xml  2
Xml 2
 
Chapter 18
Chapter 18Chapter 18
Chapter 18
 
Xml
XmlXml
Xml
 
Xml nisha dwivedi
Xml nisha dwivediXml nisha dwivedi
Xml nisha dwivedi
 
Xml 215-presentation
Xml 215-presentationXml 215-presentation
Xml 215-presentation
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 
Rendering XML Documents
Rendering XML DocumentsRendering XML Documents
Rendering XML Documents
 
Introduction of xml and xslt
Introduction of xml and xsltIntroduction of xml and xslt
Introduction of xml and xslt
 
XML/XSLT
XML/XSLTXML/XSLT
XML/XSLT
 
Xslt attributes
Xslt attributesXslt attributes
Xslt attributes
 
transforming xml using xsl and xslt
transforming xml using xsl and xslttransforming xml using xsl and xslt
transforming xml using xsl and xslt
 
Xml session
Xml sessionXml session
Xml session
 

Último

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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 Processorsdebabhi2
 
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?Igalia
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
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...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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 FresherRemote DBA Services
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
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 businesspanagenda
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Último (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
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?
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Xml transformation language

  • 1.
  • 2.  An XML transformation language is a programming language designed specifically to transform an input XML document into an output document which satisfies some specific goal.  There are two special cases of transformation:  XML to XML: the output document is an XML document.  XML to Data: the output document is a byte stream.
  • 3.  XSLT - XSLT is a language for transforming XML documents into XHTML documents or to other XML documents.  XPATH - XPath is a language for navigating in XML documents.  XQUERY - XQuery was designed to query XML data.
  • 4.  XSLT stands for XSL Transformations  XSLT is the most important part of XSL  XSL stands for EXtensible Stylesheet Language.  XSL describes how the XML document should be displayed  XSLT transforms an XML document into another XML document  XSLT uses XPath to navigate in XML documents  XSLT is a W3C Recommendation
  • 5.  The root element that declares the document to be an XSL style sheet is <xsl:stylesheet> or <xsl:transform>.  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Tr ansform">  Or  <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Tr ansform">
  • 6.  XPath is used to navigate through elements and attributes in an XML document.  XPath is a syntax for defining parts of an XML document  XPath uses path expressions to navigate in XML documents  XPath contains a library of standard functions  XPath is a major element in XSLT  XPath is a W3C recommendation  XPath uses path expressions to select nodes or node-sets in an XML document.
  • 7.
  • 8.
  • 9.  The <xsl:template> element is used to build templates.  The match attribute is used to associate a template with an XML element. The match attribute can also be used to define a template for the entire XML document. The value of the match attribute is an XPath expression (i.e. match="/" defines the whole document).
  • 10.  The <xsl:value-of> Element  The <xsl:value-of> element can be used to extract the value of an XML element and add it to the Output stream of the transformation  The <xsl:for-each> Element  The XSL <xsl:for-each> element can be used to select every XML element of a specified node-set:
  • 11.  Example:  We want to transform the following XML document ("cdcatalog.xml") into HTML:  <?xml version="1.0" encoding="UTF-8"?> <catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year> </cd> <cd> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> <country>USA</country> <company>Columbia</company> <price>20.90</price> <year>1986</year> </cd> </catalog> Save it as cdcatalog.xml
  • 12.  Then you create an XSL Style Sheet ("cdcatalog.xsl") with a transformation template:  <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Title</th> <th>Artist</th> </tr> <xsl:for-each select="catalog/cd"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="artist"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
  • 13. Add the XSL style sheet reference to your XML document ("cdcatalog.xml"):  <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?> <catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year> </cd> <cd> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> <country>USA</country> <company>Columbia</company> <price>20.90</price> <year>1986</year> </cd> </catalog>
  • 14.
  • 15.  XQuery is designed to query XML data - not just XML files, but anything that can appear as XML, including databases.  XQuery is the language for querying XML data  XQuery for XML is like SQL for databases  XQuery is built on XPath expressions  XQuery is supported by all major databases  XQuery is a W3C Recommendation  XQuery is a language for finding and extracting elements and attributes from XML documents.
  • 16.  Functions  XQuery uses functions to extract data from XML documents.  The doc() function is used to open the "books.xml" file:  doc("books.xml")
  • 17.  Path Expressions  XQuery uses path expressions to navigate through elements in an XML document.  The following path expression is used to select all the title elements in the "books.xml" file:  doc("books.xml")/bookstore/book/title  (/bookstore selects the bookstore element, /book selects all the book elements under the bookstore element, and /title selects all the title elements under each book element)
  • 18.  doc("books.xml")/bookstore/book[price>30]/ title  The expression above will select all the title elements under the book elements that are under the bookstore element that have a price element with a value that is higher than 30.
  • 19.  XLink is short for XML Linking Language  XLink is used to create hyperlinks in XML documents  Any element in an XML document can behave as a link  XLink supports simple links (like HTML) and extended links (for linking multiple resources together)  With XLink, the links can be defined outside the linked files  XLink is a W3C Recommendation
  • 20.  <?xml version="1.0" encoding="UTF-8"?> <homepages xmlns:xlink="http://www.w3.org/1999/xlink"> <homepage xlink:type="simple" xlink:href="http://www.w3schools.com">Visit W3Schools</homepage> <homepage xlink:type="simple" xlink:href="http://www.w3.org">Visit W3C</homepage> </homepages>