SlideShare a Scribd company logo
1
XML –P5
Mrs.C.Santhiya
Assistant
Professor/IT
TCE,Madurai
What is XSL?
• XSL is a language that allows one to describe a browser
how to process an XML file.
• XSL can convert an XML file into another XML with
different format.
• XSL can convert an XML file into a non-XML file.
2
Purpose
• The most common type of XSL processing is to convert XML file
into HTML file which can be displayed by browsers. We will
focus on this use of XSL.
• XSL is the bridge between XML and HTML.
• We can use XSL to have different HTML formats for
the same data represented in XML.
• Separating data (contents) from style tags (display
commands).
3
ex
4
Declaration
• <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
• <xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5
• <xsl:apply-templates>
• <xsl:apply-templates match=“expression”>
• <xsl:template>
• <xsl:value of select=“expression”>
• <xsl:for each select=“expression”>
• <xsl:sort select=“expression”>
• <xsl:output>
• <xsl:copy>
6
Match attribute
• <xsl:template match="/">
• <xsl:template match=“/”>
….
</xsl:template>
7
xsl:for-each
• <xsl:value-of select="catalog/cd/title"/>
• <xsl:value-of select=“name”/>
• <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>
8
xsl:sort
• <xsl:for-each select="catalog/cd">
<xsl:sort select="artist"/>
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
9
xsl:if
• <xsl:for-each select="catalog/cd">
<xsl:if test="price &gt; 10">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
<td><xsl:value-of select="price"/></td>
</tr>
</xsl:if>
</xsl:for-each>
10
xsl:choose
• <xsl:choose>
  <xsl:when test="expression">
    ... some output ...
  </xsl:when>
  <xsl:otherwise>
    ... some output ....
  </xsl:otherwise>
</xsl:choose>
11
EX
• <xsl:for-each select="catalog/cd">
    <tr>
      <td><xsl:value-of select="title"/></td>
      <xsl:choose>
        <xsl:when test="price &gt; 10">
          <td bgcolor="#ff00ff">
          <xsl:value-of select="artist"/></td>
        </xsl:when>
        <xsl:otherwise>
          <td><xsl:value-of select="artist"/></td>
        </xsl:otherwise>
      </xsl:choose>
    </tr>
    </xsl:for-each>
12
• <xsl:template match="title">
•   Title: <span style="color:#ff0000">
•   <xsl:value-of select="."/></span>
•   <br />
• </xsl:template>
13
XSl:copy
• Copying:
• xsl:copy, copies the current node
• xsl:apply-templates, processes the children of the current node
• ex. <xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
• <xsl:template match="title">
• <xsl:copy>
• <xsl:apply-templates/>
• </xsl:copy>
• </xsl:template>
• </xsl:stylesheet>
• xsl:copy-of element, can copy the entire subtree of each node that the
template selects
– ex. <xsl:template match="title“>
– <xsl:copy-of select="*"/>
– </xsl:template>
14
Example of Turning XML into HTML
• <?xml version="1.0"?>
• <?xml-stylesheet type="text/xsl" href="FitnessCenter.xsl"?>
• <FitnessCenter>
•         <Member level="platinum">
•                 <Name>Jeff</Name>
•                 <Phone type="home">555-1234</Phone>
•                 <Phone type="work">555-4321</Phone>
•                 <FavoriteColor>lightgrey</FavoriteColor>
•         </Member>
• </FitnessCenter>
15
HTML Document in an XSL Template
<?xml version="1.0"?>
<xsl:output method="html"/>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>Welcome</TITLE>
</HEAD>
<BODY>
Welcome!
</BODY>
</HTML>
</xsl:template>
16
Extracting
• <?xml version="1.0"?>
• <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
• version="1.0">
•
• <xsl:output method="html"/>
• <xsl:template match="/">
• <HTML>
• <HEAD>
• <TITLE>Welcome</TITLE>
• </HEAD>
• <BODY bgcolor="{/FitnessCenter/Member/FavoriteColor}">
• Welcome <xsl:value-of select="/FitnessCenter/Member/Name"/>!
• </BODY>
• </HTML>
• </xsl:template>
• </xsl:stylesheet>
17
validity
• <Body bgcolor="<xsl:value-of
select='/FitnessCenter/Member/FavoriteColor'/>">
• <Body
bgcolor="{/FitnessCenter/Member/Fav
oriteColor}">
18
• <?xml version="1.0"?>
• <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
• version="1.0">
• <xsl:output method="html"/>
• <xsl:template match="/">
• <HTML>
• <HEAD>
• <TITLE>Welcome</TITLE>
• </HEAD>
• <BODY bgcolor="{/FitnessCenter/Member/FavoriteColor}">
• Welcome <xsl:value-of select="/FitnessCenter/Member/Name"/>!
• <BR/>
• Your home phone number is:
• <xsl:value-of select="/FitnessCenter/Member/Phone[@type='home']"/>
• </BODY>
• </HTML>
• </xsl:template>
• </xsl:stylesheet> 19
Ad

More Related Content

What's hot (20)

Transforming xml with XSLT
Transforming  xml with XSLTTransforming  xml with XSLT
Transforming xml with XSLT
Malintha Adikari
 
Introduction to XSLT
Introduction to XSLTIntroduction to XSLT
Introduction to XSLT
Mahmoud Allam
 
Dom date and objects and event handling
Dom date and objects and event handlingDom date and objects and event handling
Dom date and objects and event handling
smitha273566
 
Unit iv xml
Unit iv xmlUnit iv xml
Unit iv xml
smitha273566
 
Xml
XmlXml
Xml
Santosh Pandey
 
Xsd
XsdXsd
Xsd
prathap kumar
 
Xml schema
Xml schemaXml schema
Xml schema
Akshaya Akshaya
 
Html (1)
Html (1)Html (1)
Html (1)
smitha273566
 
Xml schema
Xml schemaXml schema
Xml schema
Harry Potter
 
XML and XSLT
XML and XSLTXML and XSLT
XML and XSLT
Andrew Savory
 
Xsd examples
Xsd examplesXsd examples
Xsd examples
Bình Trọng Án
 
transforming xml using xsl and xslt
transforming xml using xsl and xslttransforming xml using xsl and xslt
transforming xml using xsl and xslt
Hemant Suthar
 
XSLT
XSLTXSLT
XSLT
rpoplai
 
Xslt by asfak mahamud
Xslt by asfak mahamudXslt by asfak mahamud
Xslt by asfak mahamud
Asfak Mahamud
 
XML/XSLT
XML/XSLTXML/XSLT
XML/XSLT
thinkahead.net
 
02 xml schema
02 xml schema02 xml schema
02 xml schema
Baskarkncet
 
Xml basics
Xml basicsXml basics
Xml basics
Kumar
 
HTML and XML Difference FAQs
HTML and XML Difference FAQsHTML and XML Difference FAQs
HTML and XML Difference FAQs
Umar Ali
 
Basics and different xml files used in android
Basics and different xml files used in androidBasics and different xml files used in android
Basics and different xml files used in android
Mahmudul Hasan
 
Introduction to xml schema
Introduction to xml schemaIntroduction to xml schema
Introduction to xml schema
Abhishek Kesharwani
 

Similar to Xml p5 Lecture Notes (20)

XSLT.ppt
XSLT.pptXSLT.ppt
XSLT.ppt
KGSCSEPSGCT
 
Xslt
XsltXslt
Xslt
Mahara Jothi
 
Xslt
XsltXslt
Xslt
Manav Prasad
 
Service Oriented Architecture - Unit II
Service Oriented Architecture - Unit IIService Oriented Architecture - Unit II
Service Oriented Architecture - Unit II
Roselin Mary S
 
XSLT presentation
XSLT presentationXSLT presentation
XSLT presentation
Miguel Angel Teheran Garcia
 
Service Oriented Architecture- UNIT 2- XSL
Service Oriented Architecture- UNIT 2- XSLService Oriented Architecture- UNIT 2- XSL
Service Oriented Architecture- UNIT 2- XSL
Roselin Mary S
 
Xml part5
Xml part5Xml part5
Xml part5
NOHA AW
 
Xslt
XsltXslt
Xslt
xavier john
 
Xslt
XsltXslt
Xslt
prathap kumar
 
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
VijiPriya Jeyamani
 
Xsl xslt
Xsl  xsltXsl  xslt
Xsl xslt
Dr.Saranya K.G
 
Xml 2
Xml  2 Xml  2
Xml 2
pavishkumarsingh
 
Introduction of xml and xslt
Introduction of xml and xsltIntroduction of xml and xslt
Introduction of xml and xslt
TUSHAR VARSHNEY
 
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
 
26xslt
26xslt26xslt
26xslt
Adil Jafri
 
"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slides"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slides
Russell Ward
 
XML XSLT
XML XSLTXML XSLT
XML XSLT
Vijay Kumar Verma
 
eXtensible Markup Language (XML)
eXtensible Markup Language (XML)eXtensible Markup Language (XML)
eXtensible Markup Language (XML)
Serhii Kartashov
 
XSL- XSLT.pdf
XSL- XSLT.pdfXSL- XSLT.pdf
XSL- XSLT.pdf
KGSCSEPSGCT
 
Xml
XmlXml
Xml
Sudharsan S
 
Ad

More from Santhiya Grace (8)

Xml p4 Lecture Notes
Xml p4  Lecture NotesXml p4  Lecture Notes
Xml p4 Lecture Notes
Santhiya Grace
 
Xml p3 -Lecture Notes
Xml p3 -Lecture NotesXml p3 -Lecture Notes
Xml p3 -Lecture Notes
Santhiya Grace
 
Php Lecture Notes
Php Lecture NotesPhp Lecture Notes
Php Lecture Notes
Santhiya Grace
 
Ajax Lecture Notes
Ajax Lecture NotesAjax Lecture Notes
Ajax Lecture Notes
Santhiya Grace
 
Events Lecture Notes
Events Lecture NotesEvents Lecture Notes
Events Lecture Notes
Santhiya Grace
 
Css lecture notes
Css lecture notesCss lecture notes
Css lecture notes
Santhiya Grace
 
Software Quality Assurance
Software Quality AssuranceSoftware Quality Assurance
Software Quality Assurance
Santhiya Grace
 
Software Quality Assurance class 1
Software Quality Assurance  class 1Software Quality Assurance  class 1
Software Quality Assurance class 1
Santhiya Grace
 
Ad

Recently uploaded (20)

Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdfDavid Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry
 
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
 
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Journal of Soft Computing in Civil Engineering
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Nanometer Metal-Organic-Framework Literature Comparison
Nanometer Metal-Organic-Framework  Literature ComparisonNanometer Metal-Organic-Framework  Literature Comparison
Nanometer Metal-Organic-Framework Literature Comparison
Chris Harding
 
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
 
Modeling the Influence of Environmental Factors on Concrete Evaporation Rate
Modeling the Influence of Environmental Factors on Concrete Evaporation RateModeling the Influence of Environmental Factors on Concrete Evaporation Rate
Modeling the Influence of Environmental Factors on Concrete Evaporation Rate
Journal of Soft Computing in Civil Engineering
 
introduction technology technology tec.pptx
introduction technology technology tec.pptxintroduction technology technology tec.pptx
introduction technology technology tec.pptx
Iftikhar70
 
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
ijflsjournal087
 
acid base ppt and their specific application in food
acid base ppt and their specific application in foodacid base ppt and their specific application in food
acid base ppt and their specific application in food
Fatehatun Noor
 
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Journal of Soft Computing in Civil Engineering
 
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic AlgorithmDesign Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Journal of Soft Computing in Civil Engineering
 
Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
 
Autodesk Fusion 2025 Tutorial: User Interface
Autodesk Fusion 2025 Tutorial: User InterfaceAutodesk Fusion 2025 Tutorial: User Interface
Autodesk Fusion 2025 Tutorial: User Interface
Atif Razi
 
Design of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdfDesign of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdf
Kamel Farid
 
Uses of drones in civil construction.pdf
Uses of drones in civil construction.pdfUses of drones in civil construction.pdf
Uses of drones in civil construction.pdf
surajsen1729
 
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
PawachMetharattanara
 
hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .
NABLAS株式会社
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdfDavid Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry
 
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Nanometer Metal-Organic-Framework Literature Comparison
Nanometer Metal-Organic-Framework  Literature ComparisonNanometer Metal-Organic-Framework  Literature Comparison
Nanometer Metal-Organic-Framework Literature Comparison
Chris Harding
 
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
 
introduction technology technology tec.pptx
introduction technology technology tec.pptxintroduction technology technology tec.pptx
introduction technology technology tec.pptx
Iftikhar70
 
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
ijflsjournal087
 
acid base ppt and their specific application in food
acid base ppt and their specific application in foodacid base ppt and their specific application in food
acid base ppt and their specific application in food
Fatehatun Noor
 
Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
 
Autodesk Fusion 2025 Tutorial: User Interface
Autodesk Fusion 2025 Tutorial: User InterfaceAutodesk Fusion 2025 Tutorial: User Interface
Autodesk Fusion 2025 Tutorial: User Interface
Atif Razi
 
Design of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdfDesign of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdf
Kamel Farid
 
Uses of drones in civil construction.pdf
Uses of drones in civil construction.pdfUses of drones in civil construction.pdf
Uses of drones in civil construction.pdf
surajsen1729
 
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
PawachMetharattanara
 
hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .
NABLAS株式会社
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 

Xml p5 Lecture Notes

  翻译: