SlideShare a Scribd company logo
1 of 27
Transforming XML Document 
by: Vijay Kumar Verma (VJY)
Objective 
What is XSL? 
What is XSLT? 
XSLT Elements 
Example
α Extensible Stylesheet Language. 
α A Formatting language. 
α Vocabulary for describing the formatting 
(i.e. layout) What of a document is XSL? 
via "Formatting 
Objects“ 
α Consist of Three part 
 XSLT 
 Xpath 
 XSL-FO
XML 
(content) 
XSL 
(presentation) 
How it Works? 
XSL Parser 
(Transformation engine) 
XML, PDF, XHTML
α Here’s a simple XML document: 
<?xml version="1.0"?> 
<library> 
Simple Xpath 
<book> 
<title edition=“2”>XML</title> 
<author>Gregory Brill</author> 
</book> 
<book> 
<title edition=“1”>Java and 
XML</title> 
<author>Brett McLaughlin</author> 
</book> 
</library > 
Xpath Expressions 
/library 
/library/book 
/library/book/title 
/library/book/title/@edition 
/library/book/title/[@edition=2] 
/library/book[1] 
//book[2] 
/library/* 
/library/book[1]/title/text()
Simple Xpath 
α Here’s a simple XML document: 
<?xml version="1.0"?> 
<library> 
<book> 
<title edition=“2”>XML</title> 
<author>Gregory Brill</author> 
</book> 
<book> 
<title edition=“1”>Java and 
XML</title> 
<author>Brett McLaughlin</author> 
</book> 
</library > 
Xpath Expressions 
/library 
/library/book 
/library/book/title 
/library/book/title/@edition 
/library/book/title/[@edition=2] 
/library/book[1] 
//book[2] 
/library/* 
/library/book[1]/title/text()
α Here’s a simple XML document: 
<?xml version="1.0"?> 
<library> 
<book> 
<title edition=“2”>XML</title> 
<author>Gregory Brill</author> 
</book> 
<book> 
<title edition=“1”>Java and 
XML</title> 
<author>Brett McLaughlin</author> 
</book> 
</library > 
Xpath Expressions 
/library 
/library/book 
/library/book/title 
/library/book/title/@edition 
/library/book/title/[@edition=2] 
/library/book[1] 
//book[2] 
/library/* 
/library/book[1]/title/text() 
Simple Xpath
α Here’s a simple XML document: 
<?xml version="1.0"?> 
<library> 
<book> 
<title edition=“2”>XML</title> 
<author>Gregory Brill</author> 
</book> 
<book> 
<title edition=“1”>Java and 
XML</title> 
<author>Brett McLaughlin</author> 
</book> 
</library > 
Xpath Expressions 
/library 
/library/book 
/library/book/title 
/library/book/title/@edition 
/library/book/title/[@edition=2] 
/library/book[1] 
//book[2] 
/library/* 
/library/book[1]/title/text() 
Simple Xpath
α Here’s a simple XML document: 
<?xml version="1.0"?> 
<library> 
<book> 
<title edition=“2”>XML</title> 
<author>Gregory Brill</author> 
</book> 
<book> 
<title edition=“1”>Java and 
XML</title> 
<author>Brett McLaughlin</author> 
</book> 
</library > 
Xpath Expressions 
/library 
/library/book 
/library/book/title 
/library/book/title/@edition 
/library/book/title/[@edition=2] 
/library/book[1] 
//book[2] 
/library/* 
predicate 
/library/book[1]/title/text() 
Simple Xpath
α Here’s a simple XML document: 
<?xml version="1.0"?> 
<library> 
<book> 
<title edition=“2”>XML</title> 
<author>Gregory Brill</author> 
</book> 
<book> 
<title edition=“1”>Java and 
XML</title> 
<author>Brett McLaughlin</author> 
</book> 
</library > 
Xpath Expressions 
/library 
/library/book 
/library/book/title 
/library/book/title/@edition 
/library/book/title/[@edition=2] 
/library/book[1] 
//book[2] 
/library/* 
/library/book[1]/title/text() 
Simple Xpath
α Here’s a simple XML document: 
<?xml version="1.0"?> 
<library> 
<book> 
<title edition=“2”>XML</title> 
<author>Gregory Brill</author> 
</book> 
<book> 
<title edition=“1”>Java and 
XML</title> 
<author>Brett McLaughlin</author> 
</book> 
</library > 
Xpath Expressions 
/library 
/library/book 
/library/book/title 
/library/book/title/@edition 
/library/book/title/[@edition=2] 
/library/book[1] 
//book[2] 
/library/* 
/library/book[1]/title/text() 
Simple Xpath
α Here’s a simple XML document: 
<?xml version="1.0"?> 
<library> 
<book> 
<title edition=“2”>XML</title> 
<author>Gregory Brill</author> 
</book> 
<book> 
<title edition=“1”>Java and 
XML</title> 
<author>Brett McLaughlin</author> 
</book> 
</library > 
Xpath Expressions 
/library 
/library/book 
/library/book/title 
/library/book/title/@edition 
/library/book/title/[@edition=2] 
/library/book[1] 
//book[2] 
/library/* 
/library/book[1]/title/text() 
Simple Xpath
α Here’s a simple XML document: 
<?xml version="1.0"?> 
<library> 
<book> 
<title edition=“2”>XML</title> 
<author>Gregory Brill</author> 
</book> 
<book> 
<title edition=“1”>Java and 
XML</title> 
<author>Brett McLaughlin</author> 
</book> 
</library > 
Xpath Expressions 
/library 
/library/book 
/library/book/title 
/library/book/title/@edition 
/library/book/title/[@edition=2] 
/library/book[1] 
//book[2] 
/library/* 
/library/book[1]/title/text() 
Simple Xpath
α Extensible Stylesheet Language 
Transformations 
α XSLT1.0 accepted in 1999 as W3C standard 
α XSLT2.0 just reached recommendation level 
What is XSLT? 
in January 2007. 
α XSLT is designed for use as part of XSL, 
which is a stylesheet language for XML. 
α Use XML Syntax. 
α Can be used like a stylesheet or embedded 
in a programming language.
<xsl:stylesheet version=“1.0” 
xmlns:xsl=“http://www.w3.org/1999/XSL/Transform”> 
<xsl:import/> 
<xsl:include/> 
<xsl:strip-space/> 
<xsl:preserve-space/> 
<xsl:output/> 
<xsl:key/> 
<xsl:decimal-format/> 
<xsl:namespace-alias/> 
<xsl:attribute-set>...</xsl:attribute-set> 
<xsl:variable>...</xsl:variable> 
<xsl:param>...</xsl:param> 
<xsl:template match=“...”> 
Syntax and structure 
... 
</xsl:template> 
<xsl:template name=“...”> 
... 
</xsl:template 
</xsl:stylesheet>
Example
α Text Editor (Notepad++) 
α Web browser 
α Mind  
Requirement
<?xml version='1.0' encoding='utf-8'?> 
<?xml-stylesheet href=bird.xsl" type="text/xsl"?> 
<zoo> 
XML File 
<bird> 
<name>Peacock</name> 
<size>Large</size> 
</bird> 
<bird> 
<name>Sparrow</name> 
<size>Small</size> 
</bird> 
<bird> 
<name>peagion</name> 
<size>medium</size> 
</bird> 
</zoo>
<?xml version='1.0'?> 
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:template match="/"> 
<html> 
XSL File 
<head> 
<title>Bird in Zoo</title> 
</head> 
<body> 
<xsl:for-each select="zoo/bird"> 
<ol> 
<li><xsl:value-of select="name"/></li> 
<li><xsl:value-of select="size"/></li> 
</ol> 
</xsl:for-each> 
</body> 
</html> 
</xsl:template> 
</xsl:stylesheet>
Output 
Without XSL After Using XSL
 <xsl:for-each select="//book"> 
loops through every book element, everywhere in the 
document 
 <xsl:value-of select="title"/> 
chooses the content of the title element at the 
current location 
Summary of XSL file 
 <xsl:for-each select="//book"> 
<xsl:value-of select="title"/> 
</xsl:for-each> 
chooses the content of the title element for each 
book in the XML document
<?xml version='1.0'?> 
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:template match="//bird"> 
<html> 
<head> 
<title>Bird in Zoo</title> 
</head> 
<body> 
Another XSL File 
<xsl:if test="name='peagion'"> 
<h1>Size of peagion: <xsl:value-of select="size" 
/></h1> 
</xsl:if> 
</body> 
</html> 
</xsl:template> 
</xsl:stylesheet>
Output 
Without XSL
<?xml version='1.0'?> 
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:template match="//bird"> 
<html> 
<head> 
<title>Bird in Zoo</title> 
</head> 
<body> 
Choose, when, <xsl:choose> 
otherwise 
<xsl:when test="name='peagion'"> 
<h1>Symbol of peace.</h1> 
</xsl:when> 
<xsl:when test="name='Peacock'"> 
<h1>National Bird</h1> 
</xsl:when> 
<xsl:otherwise> 
<h1>Simple Bird</h1> 
</xsl:otherwise> 
</xsl:choose> 
</body></html></xsl:template></xsl:stylesheet>
Output
XML XSLT
XML XSLT

More Related Content

What's hot (20)

Introduction to XSLT
Introduction to XSLTIntroduction to XSLT
Introduction to XSLT
 
5 xsl (formatting xml documents)
5   xsl (formatting xml documents)5   xsl (formatting xml documents)
5 xsl (formatting xml documents)
 
XSLT
XSLTXSLT
XSLT
 
XSLT presentation
XSLT presentationXSLT presentation
XSLT presentation
 
Querring xml with xpath
Querring xml with xpath Querring xml with xpath
Querring xml with xpath
 
XSLT
XSLTXSLT
XSLT
 
Learning XSLT
Learning XSLTLearning XSLT
Learning XSLT
 
XSLT and XPath - without the pain!
XSLT and XPath - without the pain!XSLT and XPath - without the pain!
XSLT and XPath - without the pain!
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Displaying XML Documents Using CSS and XSL
Displaying XML Documents Using CSS and XSLDisplaying XML Documents Using CSS and XSL
Displaying XML Documents Using CSS and XSL
 
Xml Lecture Notes
Xml Lecture NotesXml Lecture Notes
Xml Lecture Notes
 
Xslt
XsltXslt
Xslt
 
Xml p5 Lecture Notes
Xml p5 Lecture NotesXml p5 Lecture Notes
Xml p5 Lecture Notes
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Xml 215-presentation
Xml 215-presentationXml 215-presentation
Xml 215-presentation
 
C:\fakepath\xsl final
C:\fakepath\xsl finalC:\fakepath\xsl final
C:\fakepath\xsl final
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Xml
XmlXml
Xml
 
Introduction to xml
Introduction to xmlIntroduction to xml
Introduction to xml
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 

Viewers also liked

XSLT 2010-03-03
XSLT 2010-03-03XSLT 2010-03-03
XSLT 2010-03-03kmiyako
 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xsltKumar
 
Introduction to XSLT SPSBE07
Introduction to XSLT SPSBE07Introduction to XSLT SPSBE07
Introduction to XSLT SPSBE07Elio Struyf
 
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. VijiPriyaVijiPriya Jeyamani
 
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-FOSuite Solutions
 

Viewers also liked (9)

XSLT 2010-03-03
XSLT 2010-03-03XSLT 2010-03-03
XSLT 2010-03-03
 
Xslt
XsltXslt
Xslt
 
4 xslt
4   xslt4   xslt
4 xslt
 
XSLT for Web Developers
XSLT for Web DevelopersXSLT for Web Developers
XSLT for Web Developers
 
Xslt
XsltXslt
Xslt
 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xslt
 
Introduction to XSLT SPSBE07
Introduction to XSLT SPSBE07Introduction to XSLT SPSBE07
Introduction to XSLT SPSBE07
 
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
 

Similar to XML XSLT

The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld BookNet Canada
 
Xml nisha dwivedi
Xml nisha dwivediXml nisha dwivedi
Xml nisha dwivediNIIT
 
Xml transformation language
Xml transformation languageXml transformation language
Xml transformation languagereshmavasudev
 
Service Oriented Architecture - Unit II
Service Oriented Architecture - Unit IIService Oriented Architecture - Unit II
Service Oriented Architecture - Unit IIRoselin Mary S
 
"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slides"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slidesRussell Ward
 
Notes from the Library Juice Academy courses on XPath, XSLT, and XQuery: Univ...
Notes from the Library Juice Academy courses on XPath, XSLT, and XQuery: Univ...Notes from the Library Juice Academy courses on XPath, XSLT, and XQuery: Univ...
Notes from the Library Juice Academy courses on XPath, XSLT, and XQuery: Univ...Allison Jai O'Dell
 
Introduction of xml and xslt
Introduction of xml and xsltIntroduction of xml and xslt
Introduction of xml and xsltTUSHAR VARSHNEY
 
eXtensible Markup Language (XML)
eXtensible Markup Language (XML)eXtensible Markup Language (XML)
eXtensible Markup Language (XML)Serhii Kartashov
 
XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft ...
XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft ...XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft ...
XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft ...BookNet Canada
 
IWMW 2001: XML and XSLT
IWMW 2001: XML and XSLT IWMW 2001: XML and XSLT
IWMW 2001: XML and XSLT IWMW
 
Extensible Stylesheet Language
Extensible Stylesheet LanguageExtensible Stylesheet Language
Extensible Stylesheet LanguageJussi Pohjolainen
 

Similar to XML XSLT (20)

The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
 
Xml nisha dwivedi
Xml nisha dwivediXml nisha dwivedi
Xml nisha dwivedi
 
Xml 215-presentation
Xml 215-presentationXml 215-presentation
Xml 215-presentation
 
XML
XMLXML
XML
 
Xml transformation language
Xml transformation languageXml transformation language
Xml transformation language
 
Xsl xslt
Xsl  xsltXsl  xslt
Xsl xslt
 
Xslt
XsltXslt
Xslt
 
Service Oriented Architecture - Unit II
Service Oriented Architecture - Unit IIService Oriented Architecture - Unit II
Service Oriented Architecture - Unit II
 
"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slides"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slides
 
Notes from the Library Juice Academy courses on XPath, XSLT, and XQuery: Univ...
Notes from the Library Juice Academy courses on XPath, XSLT, and XQuery: Univ...Notes from the Library Juice Academy courses on XPath, XSLT, and XQuery: Univ...
Notes from the Library Juice Academy courses on XPath, XSLT, and XQuery: Univ...
 
Chapter4
Chapter4Chapter4
Chapter4
 
Introduction of xml and xslt
Introduction of xml and xsltIntroduction of xml and xslt
Introduction of xml and xslt
 
XSL - XML STYLE SHEET
XSL - XML STYLE SHEETXSL - XML STYLE SHEET
XSL - XML STYLE SHEET
 
XSL- XSLT.pdf
XSL- XSLT.pdfXSL- XSLT.pdf
XSL- XSLT.pdf
 
eXtensible Markup Language (XML)
eXtensible Markup Language (XML)eXtensible Markup Language (XML)
eXtensible Markup Language (XML)
 
XPATH_XSLT-1.pptx
XPATH_XSLT-1.pptxXPATH_XSLT-1.pptx
XPATH_XSLT-1.pptx
 
Xml 2
Xml  2 Xml  2
Xml 2
 
XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft ...
XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft ...XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft ...
XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft ...
 
IWMW 2001: XML and XSLT
IWMW 2001: XML and XSLT IWMW 2001: XML and XSLT
IWMW 2001: XML and XSLT
 
Extensible Stylesheet Language
Extensible Stylesheet LanguageExtensible Stylesheet Language
Extensible Stylesheet Language
 

More from Vijay Kumar Verma

More from Vijay Kumar Verma (10)

Oo methodology
Oo methodologyOo methodology
Oo methodology
 
XML_schema_Structure
XML_schema_StructureXML_schema_Structure
XML_schema_Structure
 
Introduction to Java Script
Introduction to Java ScriptIntroduction to Java Script
Introduction to Java Script
 
Php introduction and configuration
Php introduction and configurationPhp introduction and configuration
Php introduction and configuration
 
Security threats ecom
Security threats ecomSecurity threats ecom
Security threats ecom
 
Dwm temporal measure
Dwm temporal measureDwm temporal measure
Dwm temporal measure
 
Html+css web layout 2
Html+css web layout 2Html+css web layout 2
Html+css web layout 2
 
Open gl configuration_march2014
Open gl configuration_march2014Open gl configuration_march2014
Open gl configuration_march2014
 
Aos distibutted system
Aos distibutted systemAos distibutted system
Aos distibutted system
 
Html+css web layout
Html+css web layoutHtml+css web layout
Html+css web layout
 

Recently uploaded

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 

Recently uploaded (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 

XML XSLT

  • 1. Transforming XML Document by: Vijay Kumar Verma (VJY)
  • 2. Objective What is XSL? What is XSLT? XSLT Elements Example
  • 3. α Extensible Stylesheet Language. α A Formatting language. α Vocabulary for describing the formatting (i.e. layout) What of a document is XSL? via "Formatting Objects“ α Consist of Three part  XSLT  Xpath  XSL-FO
  • 4. XML (content) XSL (presentation) How it Works? XSL Parser (Transformation engine) XML, PDF, XHTML
  • 5. α Here’s a simple XML document: <?xml version="1.0"?> <library> Simple Xpath <book> <title edition=“2”>XML</title> <author>Gregory Brill</author> </book> <book> <title edition=“1”>Java and XML</title> <author>Brett McLaughlin</author> </book> </library > Xpath Expressions /library /library/book /library/book/title /library/book/title/@edition /library/book/title/[@edition=2] /library/book[1] //book[2] /library/* /library/book[1]/title/text()
  • 6. Simple Xpath α Here’s a simple XML document: <?xml version="1.0"?> <library> <book> <title edition=“2”>XML</title> <author>Gregory Brill</author> </book> <book> <title edition=“1”>Java and XML</title> <author>Brett McLaughlin</author> </book> </library > Xpath Expressions /library /library/book /library/book/title /library/book/title/@edition /library/book/title/[@edition=2] /library/book[1] //book[2] /library/* /library/book[1]/title/text()
  • 7. α Here’s a simple XML document: <?xml version="1.0"?> <library> <book> <title edition=“2”>XML</title> <author>Gregory Brill</author> </book> <book> <title edition=“1”>Java and XML</title> <author>Brett McLaughlin</author> </book> </library > Xpath Expressions /library /library/book /library/book/title /library/book/title/@edition /library/book/title/[@edition=2] /library/book[1] //book[2] /library/* /library/book[1]/title/text() Simple Xpath
  • 8. α Here’s a simple XML document: <?xml version="1.0"?> <library> <book> <title edition=“2”>XML</title> <author>Gregory Brill</author> </book> <book> <title edition=“1”>Java and XML</title> <author>Brett McLaughlin</author> </book> </library > Xpath Expressions /library /library/book /library/book/title /library/book/title/@edition /library/book/title/[@edition=2] /library/book[1] //book[2] /library/* /library/book[1]/title/text() Simple Xpath
  • 9. α Here’s a simple XML document: <?xml version="1.0"?> <library> <book> <title edition=“2”>XML</title> <author>Gregory Brill</author> </book> <book> <title edition=“1”>Java and XML</title> <author>Brett McLaughlin</author> </book> </library > Xpath Expressions /library /library/book /library/book/title /library/book/title/@edition /library/book/title/[@edition=2] /library/book[1] //book[2] /library/* predicate /library/book[1]/title/text() Simple Xpath
  • 10. α Here’s a simple XML document: <?xml version="1.0"?> <library> <book> <title edition=“2”>XML</title> <author>Gregory Brill</author> </book> <book> <title edition=“1”>Java and XML</title> <author>Brett McLaughlin</author> </book> </library > Xpath Expressions /library /library/book /library/book/title /library/book/title/@edition /library/book/title/[@edition=2] /library/book[1] //book[2] /library/* /library/book[1]/title/text() Simple Xpath
  • 11. α Here’s a simple XML document: <?xml version="1.0"?> <library> <book> <title edition=“2”>XML</title> <author>Gregory Brill</author> </book> <book> <title edition=“1”>Java and XML</title> <author>Brett McLaughlin</author> </book> </library > Xpath Expressions /library /library/book /library/book/title /library/book/title/@edition /library/book/title/[@edition=2] /library/book[1] //book[2] /library/* /library/book[1]/title/text() Simple Xpath
  • 12. α Here’s a simple XML document: <?xml version="1.0"?> <library> <book> <title edition=“2”>XML</title> <author>Gregory Brill</author> </book> <book> <title edition=“1”>Java and XML</title> <author>Brett McLaughlin</author> </book> </library > Xpath Expressions /library /library/book /library/book/title /library/book/title/@edition /library/book/title/[@edition=2] /library/book[1] //book[2] /library/* /library/book[1]/title/text() Simple Xpath
  • 13. α Here’s a simple XML document: <?xml version="1.0"?> <library> <book> <title edition=“2”>XML</title> <author>Gregory Brill</author> </book> <book> <title edition=“1”>Java and XML</title> <author>Brett McLaughlin</author> </book> </library > Xpath Expressions /library /library/book /library/book/title /library/book/title/@edition /library/book/title/[@edition=2] /library/book[1] //book[2] /library/* /library/book[1]/title/text() Simple Xpath
  • 14. α Extensible Stylesheet Language Transformations α XSLT1.0 accepted in 1999 as W3C standard α XSLT2.0 just reached recommendation level What is XSLT? in January 2007. α XSLT is designed for use as part of XSL, which is a stylesheet language for XML. α Use XML Syntax. α Can be used like a stylesheet or embedded in a programming language.
  • 15. <xsl:stylesheet version=“1.0” xmlns:xsl=“http://www.w3.org/1999/XSL/Transform”> <xsl:import/> <xsl:include/> <xsl:strip-space/> <xsl:preserve-space/> <xsl:output/> <xsl:key/> <xsl:decimal-format/> <xsl:namespace-alias/> <xsl:attribute-set>...</xsl:attribute-set> <xsl:variable>...</xsl:variable> <xsl:param>...</xsl:param> <xsl:template match=“...”> Syntax and structure ... </xsl:template> <xsl:template name=“...”> ... </xsl:template </xsl:stylesheet>
  • 17. α Text Editor (Notepad++) α Web browser α Mind  Requirement
  • 18. <?xml version='1.0' encoding='utf-8'?> <?xml-stylesheet href=bird.xsl" type="text/xsl"?> <zoo> XML File <bird> <name>Peacock</name> <size>Large</size> </bird> <bird> <name>Sparrow</name> <size>Small</size> </bird> <bird> <name>peagion</name> <size>medium</size> </bird> </zoo>
  • 19. <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> XSL File <head> <title>Bird in Zoo</title> </head> <body> <xsl:for-each select="zoo/bird"> <ol> <li><xsl:value-of select="name"/></li> <li><xsl:value-of select="size"/></li> </ol> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>
  • 20. Output Without XSL After Using XSL
  • 21.  <xsl:for-each select="//book"> loops through every book element, everywhere in the document  <xsl:value-of select="title"/> chooses the content of the title element at the current location Summary of XSL file  <xsl:for-each select="//book"> <xsl:value-of select="title"/> </xsl:for-each> chooses the content of the title element for each book in the XML document
  • 22. <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="//bird"> <html> <head> <title>Bird in Zoo</title> </head> <body> Another XSL File <xsl:if test="name='peagion'"> <h1>Size of peagion: <xsl:value-of select="size" /></h1> </xsl:if> </body> </html> </xsl:template> </xsl:stylesheet>
  • 24. <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="//bird"> <html> <head> <title>Bird in Zoo</title> </head> <body> Choose, when, <xsl:choose> otherwise <xsl:when test="name='peagion'"> <h1>Symbol of peace.</h1> </xsl:when> <xsl:when test="name='Peacock'"> <h1>National Bird</h1> </xsl:when> <xsl:otherwise> <h1>Simple Bird</h1> </xsl:otherwise> </xsl:choose> </body></html></xsl:template></xsl:stylesheet>