SlideShare ist ein Scribd-Unternehmen logo
1 von 221
Extensible Stylesheet Language (XSL) Atul Kahate [email_address]
Agenda ,[object Object],[object Object],[object Object],[object Object]
Style Sheets Basics ,[object Object],[object Object],[object Object],[object Object]
Style Sheets ,[object Object],[object Object],[object Object]
Standards For XML Styling ,[object Object],[object Object],[object Object],[object Object]
CSS versus XSL ,[object Object],[object Object],XML  Document CSS Style Sheet XML  Document XSL Style Sheet HTML Document
CSS (Cascading Style Sheet) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Need for CSS ,[object Object],[object Object],[object Object],[object Object],[object Object]
CSS Terminology ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example of CSS Syntax ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
DTD and Stylesheet Example - 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
DTD and Stylesheet Example - 2 ,[object Object],[object Object],[object Object],[object Object]
DTD and Stylesheet Example - 3 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sample XML Document ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Corresponding CSS Document ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Output in Web Browser
Understanding CSS Example - 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Understanding CSS Example - 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Understanding CSS Example - 3 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Exercise ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Introduction to XSLT Concepts
Programming Language Classification ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Recursion ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Recursion Illustrated
Recursion and XSL: When? ,[object Object],[object Object]
XSL Terminologies XSL, XSLT, XSLFO, XPath, XPointer, Stylesheet, Template, …
XSL (XML Stylesheet Language) ,[object Object],[object Object],[object Object],[object Object],[object Object]
XPath ,[object Object],[object Object],[object Object]
XSLT Usage ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
XSLT Stylesheets ,[object Object],[object Object],[object Object],[object Object]
XSLT Processing Concept Input XML document XSLT Processor Output XML document XSLT Template XSLT Stylesheet
XSLT Basics
Simple XSLT Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Change to the XML ,[object Object]
Now look at the XSL ,[object Object],[object Object],[object Object],[object Object]
Question ,[object Object],[object Object]
Modified XSL ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Interesting Tricks – 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Answer ,[object Object],[object Object],[object Object]
Interesting Tricks – 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Answer ,[object Object],[object Object]
Interesting Tricks – 3 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Answer ,[object Object],[object Object],[object Object]
Interesting Tricks – 4 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Answer ,[object Object]
Template Basics
Usage of Templates ,[object Object],[object Object],[object Object],[object Object],[object Object]
Understanding <apply-templates> ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
How it Works? <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>  <?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;class.xsl&quot;?>  <class>  <student>Jack</student>  <student>Harry</student>  <student>Rebecca</student>  <teacher>Mr. Bean</teacher>  </class>  <?xml version=&quot;1.0&quot; ?>  <xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;>  <xsl:template match=&quot;student&quot;> Found a learner!  </xsl:template>  </xsl:stylesheet> Step 1: For all matching  student  tags, display output  Found a learner! Step 2: Come here and run the template recursively for all the  student  tags, displaying  Found a learner! Step 3: For all tags other than  student , there is no template in our XSL. Therefore, blindly output them, as they are!
Plain English Version ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Explanation ,[object Object],[object Object],[object Object],[object Object],[object Object]
Notes on the Result – 1 ,[object Object],[object Object],[object Object],[object Object],[object Object]
Notes on the Result – 2 ,[object Object],[object Object],[object Object]
Modified XML and XSL ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Output ,[object Object],[object Object],[object Object],[object Object]
Further Modifications ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Still More Changes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Output ,[object Object],[object Object]
Introducing apply-templates
Use of <apply-templates>  - Tricky ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Output ,[object Object],[object Object],[object Object],[object Object]
Suppressing Unwanted Output ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Controlling the Output the Way We Want
XSL Changed – 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Plain English Version ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Output of the second XSL ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Beware of this Problem! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Analysis ,[object Object],[object Object],[object Object]
Plain English Version ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What about this? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Output ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Another Variation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary ,[object Object],[object Object],[object Object],[object Object]
Another XSLT Example – 1  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Another XSLT Example – 2  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using Parameters in Templates
Using Parameters in Templates ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Calling Templates ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Code ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Attributes
Dealing with Attributes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Another Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A Detailed Example
discussionForumHome.xml ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
discussionForumHome.xsl ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
<xsl:template match = “/”> ,[object Object],[object Object],[object Object]
Understanding  <xsl:template-match>  - 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Understanding  <xsl:template-match>  - 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Understanding  <xsl:template-match>  - 3 ,[object Object],[object Object],[object Object],[object Object]
<xsl:apply-templates> - 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
<xsl:apply-templates> - 2 ,[object Object],[object Object],[object Object],[object Object],[object Object]
<xsl:apply-templates> - 3 ,[object Object],[object Object],[object Object]
<xsl:template match = “messageBoard”> ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary ,[object Object],[object Object],[object Object],[object Object],[object Object]
Comparing <xsl:template> to <xsl:apply-template> ,[object Object]
Another Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Explanation ,[object Object],[object Object],[object Object]
An Example for Conceptual Clarity ,[object Object],[object Object],[object Object],< xsl:template   match = &quot; customers &quot; > < ul > < xsl:apply-templates   select  = &quot; customer &quot; /> </ ul > </ xsl:template > < xsl:template   match  = &quot; customer &quot; >  <!– Loops over all  customer  instances   < li > < xsl:value-of   select  = &quot; name &quot; /> </ li > </ xsl:template > </ xsl:stylesheet >
Value-of select = ‘.’ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Another Example –  Can be Confusing! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Explanation ,[object Object],[object Object],[object Object],[object Object]
Modified Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Analysis ,[object Object],[object Object],[object Object]
Modified Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Another Version ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Modified Further ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Modified Further ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Yet Another Version –  Only middle name would get displayed after the complete name ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Controlling the Output Method ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
More XSLT Examples
First XSL Example: Hello World! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Second XSL example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Third XSL Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
XPath Basics
Nodes ,[object Object],[object Object],[object Object],[object Object],[object Object]
Sample XML Document ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
XPath View Root Comment This is a comment Element BOOK Attribute author Andrew Tanenbaum Attribute edition 3 Element REVIEW Text This is a wonderful book! Text Computer Networks
XPath Basics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
XPath Example ,[object Object],[object Object],[object Object],[object Object],[object Object]
XPath Examples – 1 If context node is the <book> element, an empty node-set would be returned. If the context node is <paragraph> number 1 in <section> 2 of <chapter> 2, the returned node-set would be the text node with value  First paragraph . Select all text node children of the context node. child::text() If context node is the <book> element, the node-set containing <title>, <chapters> and <appendices> nodes would be returned. Select all element node children of the context node. Children other than the element node are not selected. child::* If context is book, empty node-set would be returned. If context node is <section> element in chapter 2 with attribute number =“1”, a node-set containing four paragraph nodes would be returned. Select the <paragraph> child element nodes of the context node. child::paragraph Example Meaning Syntax
XPath Examples – 2 If context node is the <chapter> 1 element, a node-set containing two attribute nodes would be returned, representing the  number  and  title  attributes. Select all attribute nodes of the context node. attribute::* NA Select all attribute nodes with name  number  under the context node.  attribute::number NA Select all the child nodes of the context node. Note that this will return non-elements also. child::node() Example Meaning Syntax
XPath Examples – 3 NA Select the context node if it is the <paragraph> element. self:paragraph If the context node is <chapters>, an empty node-set would be returned. If the context node is a <section>, the result would be a node-set containing one <chapter> element which contains this <section> element. Select the <chapter> element nodes that are ancestors of the context node. If the context node is a <chapter> element, return that also. ancestor-or-self::chapter If the context node is <book> or <chapters> element, we would get a node-set consisting of six <paragraph> nodes.  If the context node is <section> 1 element for <chapter> 2, we would get a node-set consisting of four <paragraph> nodes. Select all <paragraph> elements that are descendants of the context node. descendant::paragraph Example Meaning Syntax
Unabbreviated relative location path Abbreviated relative location path Selection criteria child::BOOK BOOK Element nodes that are children of the context node. child::* * All element nodes that are children of the context node. child::text () text () All text node children of the context node. self::node () . Context node itself. parent::node () .. Parent of the context node. attribute::reviewer @reviewer Attribute  reviewer  of the context node. attribute::* @* All attributes of the context node. parent::node ()/attribute::reviewer [email_address] Attribute  reviewer  of the parent of the context node. child::AUTHOR [position () = 1] AUTHOR [1] First  AUTHOR  child node of the context node. child::AUTHOR [position () = last ()] AUTHOR [last ()] Last  AUTHOR  child node of the context node. child::REVIEW [attribute::reviewer = “Jui”] REVIEW [@reviewer = “Jui”] All  REVIEW  element children of the context node having a  reviewer  attribute with a value of  Jui . child::REVIEW [attribute::reviewer = “Jui’] [2] REVIEW [@reviewer = “Jui”] [2] Second  REVIEW  child of the context node having a  reviewer  attribute with a value of  Jui . child::REVIEW [position () = 2] [attribute::reviewer = “Jui’] REVIEW [2] [@reviewer = “Jui”]  Second  REVIEW  child of the context node if it has a  reviewer  attribute with a value of  Jui . child::*/child::AUTHOR */AUTHOR All grand-children element nodes of the context node that are also  AUTHOR  elements. child::BOOK[child::TITLE= “TCP/IP”] BOOK[TITLE = “TCP/IP”] BOOK  element children of the context node having one or more  TITLE  element children with string-value as  TCP/IP . child::BOOK/child::REVIEW/child::COMMENT [position () = 2] BOOK/REVIEW/COMMENT [2] Second child  COMMENT  element node of the  REVIEW  element node, which itself is the child of the  BOOK  element node. self::node()/descendant-or-self::node()/child:COMMENT .//COMMENT All  COMMENT  element nodes that are descendants of the context node.  Note that the // notation is a short-hand for the  descendant::  syntax.
Template Rules ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
<xsl:value-of> Element ,[object Object],[object Object],[object Object]
XSLT Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Exercise ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Solution ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Exercise ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Solution ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Exercise ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Solution ,[object Object],[object Object],[object Object],[object Object],[object Object]
Exercise ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Solution ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Concept of apply-templates
apply-templates ,[object Object],[object Object],[object Object]
Source XML (apply.xml) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Basic XSL Example (apply0.xml) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Explanation ,[object Object],[object Object]
XSL Example: 1 (apply1.xsl) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Explanation ,[object Object],[object Object],[object Object]
XSL Example: 2 (apply2.xsl) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Explanation ,[object Object],[object Object]
XSL Example: 3 (apply3.xsl) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
XSL Example: 4 (apply4.xsl) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
XSL Example: 6 (apply6.xsl)  - Tricky ,[object Object],[object Object],[object Object],[object Object]
XSL Example: 5 (apply5.xsl) –  Tricky! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Explanation ,[object Object],[object Object],[object Object]
Using the Mode Attribute
Using Mode ,[object Object],[object Object],[object Object],[object Object]
Mode Example, also uses CSS ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creating New Elements and Attributes
Creating Elements and Attributes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Corresponding XSL ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Explanation - 1 ,[object Object],[object Object],[object Object],[object Object],[object Object]
Explanation – 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Explanation – 3 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Explanation – 4 ,[object Object],[object Object],[object Object],[object Object]
Explanation – 5 ,[object Object],[object Object],[object Object],[object Object]
Explanation – 6 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)
5   xsl (formatting xml documents)

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
XSLT
XSLTXSLT
XSLT
 
Xml schema
Xml schemaXml schema
Xml schema
 
Xml schema
Xml schemaXml schema
Xml schema
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 
Introduction to XSLT
Introduction to XSLTIntroduction to XSLT
Introduction to XSLT
 
Xslt
XsltXslt
Xslt
 
XMLT
XMLTXMLT
XMLT
 
XML Schema
XML SchemaXML Schema
XML Schema
 
Learning XSLT
Learning XSLTLearning XSLT
Learning XSLT
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Introduction to xml schema
Introduction to xml schemaIntroduction to xml schema
Introduction to xml schema
 
Xml 215-presentation
Xml 215-presentationXml 215-presentation
Xml 215-presentation
 
XML
XMLXML
XML
 
XSLT. Basic.
XSLT. Basic.XSLT. Basic.
XSLT. Basic.
 
Introduction to xml
Introduction to xmlIntroduction to xml
Introduction to xml
 
XSD
XSDXSD
XSD
 
02 xml schema
02 xml schema02 xml schema
02 xml schema
 
Xsd
XsdXsd
Xsd
 
Xsd examples
Xsd examplesXsd examples
Xsd examples
 

Andere mochten auch

1 introduction to xml
1   introduction to xml1   introduction to xml
1 introduction to xmlgauravashq
 
3 xml namespaces and xml schema
3   xml namespaces and xml schema3   xml namespaces and xml schema
3 xml namespaces and xml schemagauravashq
 
4 xml namespaces and xml schema
4   xml namespaces and xml schema4   xml namespaces and xml schema
4 xml namespaces and xml schemagauravashq
 
2 dtd - validating xml documents
2   dtd - validating xml documents2   dtd - validating xml documents
2 dtd - validating xml documentsgauravashq
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentationAdhoura Academy
 
Chlorophyll plus guarana - Presentation
Chlorophyll plus guarana - PresentationChlorophyll plus guarana - Presentation
Chlorophyll plus guarana - PresentationJeevanseva, Hyderabad
 
HTML, CSS and Java Scripts Basics
HTML, CSS and Java Scripts BasicsHTML, CSS and Java Scripts Basics
HTML, CSS and Java Scripts BasicsSun Technlogies
 
Node.js and The Internet of Things
Node.js and The Internet of ThingsNode.js and The Internet of Things
Node.js and The Internet of ThingsLosant
 

Andere mochten auch (20)

AK css
AK cssAK css
AK css
 
Ajax
AjaxAjax
Ajax
 
1 introduction to xml
1   introduction to xml1   introduction to xml
1 introduction to xml
 
Spring.pdf
Spring.pdfSpring.pdf
Spring.pdf
 
9 c plants and photosynthesis
9 c plants and photosynthesis9 c plants and photosynthesis
9 c plants and photosynthesis
 
3 xml namespaces and xml schema
3   xml namespaces and xml schema3   xml namespaces and xml schema
3 xml namespaces and xml schema
 
5 xml parsing
5   xml parsing5   xml parsing
5 xml parsing
 
6 xml parsing
6   xml parsing6   xml parsing
6 xml parsing
 
4 xml namespaces and xml schema
4   xml namespaces and xml schema4   xml namespaces and xml schema
4 xml namespaces and xml schema
 
2 dtd - validating xml documents
2   dtd - validating xml documents2   dtd - validating xml documents
2 dtd - validating xml documents
 
chlorophyll
chlorophyllchlorophyll
chlorophyll
 
CHLOROPLAST AND CHLOROPHYLL
CHLOROPLAST AND CHLOROPHYLLCHLOROPLAST AND CHLOROPHYLL
CHLOROPLAST AND CHLOROPHYLL
 
chlorophyll
chlorophyllchlorophyll
chlorophyll
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
 
Chlorophyll plus guarana - Presentation
Chlorophyll plus guarana - PresentationChlorophyll plus guarana - Presentation
Chlorophyll plus guarana - Presentation
 
Chlorophyll
ChlorophyllChlorophyll
Chlorophyll
 
Java script
Java scriptJava script
Java script
 
Java script
Java scriptJava script
Java script
 
HTML, CSS and Java Scripts Basics
HTML, CSS and Java Scripts BasicsHTML, CSS and Java Scripts Basics
HTML, CSS and Java Scripts Basics
 
Node.js and The Internet of Things
Node.js and The Internet of ThingsNode.js and The Internet of Things
Node.js and The Internet of Things
 

Ähnlich wie 5 xsl (formatting xml documents) (20)

Xml
XmlXml
Xml
 
Rendering XML Documents
Rendering XML DocumentsRendering XML Documents
Rendering XML Documents
 
XML Transformations With PHP
XML Transformations With PHPXML Transformations With PHP
XML Transformations With PHP
 
Inroduction to XSLT with PHP4
Inroduction to XSLT with PHP4Inroduction to XSLT with PHP4
Inroduction to XSLT with PHP4
 
Rendering XML Document
Rendering XML DocumentRendering XML Document
Rendering XML Document
 
Xml
XmlXml
Xml
 
Xslt
XsltXslt
Xslt
 
Xml Overview
Xml OverviewXml Overview
Xml Overview
 
Xml
XmlXml
Xml
 
uptu web technology unit 2 Xml2
uptu web technology unit 2 Xml2uptu web technology unit 2 Xml2
uptu web technology unit 2 Xml2
 
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
 
Xslt
XsltXslt
Xslt
 
Xml
XmlXml
Xml
 
Xml
XmlXml
Xml
 
Xml 1
Xml 1Xml 1
Xml 1
 
Session 4
Session 4Session 4
Session 4
 
Processing XML with Java
Processing XML with JavaProcessing XML with Java
Processing XML with Java
 
xml.pptx
xml.pptxxml.pptx
xml.pptx
 
Xml
XmlXml
Xml
 

Mehr von gauravashq

1 electronic data interchange (edi)
1   electronic data interchange (edi)1   electronic data interchange (edi)
1 electronic data interchange (edi)gauravashq
 
AK 5 JSF 21 july 2008
AK 5 JSF   21 july 2008AK 5 JSF   21 july 2008
AK 5 JSF 21 july 2008gauravashq
 
AK 3 web services using apache axis
AK 3   web services using apache axisAK 3   web services using apache axis
AK 3 web services using apache axisgauravashq
 

Mehr von gauravashq (9)

Spring
SpringSpring
Spring
 
Spring
SpringSpring
Spring
 
Spring
SpringSpring
Spring
 
4 xslt
4   xslt4   xslt
4 xslt
 
1 electronic data interchange (edi)
1   electronic data interchange (edi)1   electronic data interchange (edi)
1 electronic data interchange (edi)
 
AK 5 JSF 21 july 2008
AK 5 JSF   21 july 2008AK 5 JSF   21 july 2008
AK 5 JSF 21 july 2008
 
AK 4 JSF
AK 4 JSFAK 4 JSF
AK 4 JSF
 
AK 3 web services using apache axis
AK 3   web services using apache axisAK 3   web services using apache axis
AK 3 web services using apache axis
 
AK html
AK  htmlAK  html
AK html
 

Kürzlich hochgeladen

AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
The Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsThe Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsRommel Regala
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxJanEmmanBrigoli
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxRosabel UA
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 

Kürzlich hochgeladen (20)

AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
The Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsThe Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World Politics
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptx
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 

5 xsl (formatting xml documents)

  • 1. Extensible Stylesheet Language (XSL) Atul Kahate [email_address]
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. Output in Web Browser
  • 17.
  • 18.
  • 19.
  • 20.
  • 22.
  • 23.
  • 25.
  • 26. XSL Terminologies XSL, XSLT, XSLFO, XPath, XPointer, Stylesheet, Template, …
  • 27.
  • 28.
  • 29.
  • 30.
  • 31. XSLT Processing Concept Input XML document XSLT Processor Output XML document XSLT Template XSLT Stylesheet
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 47.
  • 48.
  • 49. How it Works? <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;class.xsl&quot;?> <class> <student>Jack</student> <student>Harry</student> <student>Rebecca</student> <teacher>Mr. Bean</teacher> </class> <?xml version=&quot;1.0&quot; ?> <xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;> <xsl:template match=&quot;student&quot;> Found a learner! </xsl:template> </xsl:stylesheet> Step 1: For all matching student tags, display output Found a learner! Step 2: Come here and run the template recursively for all the student tags, displaying Found a learner! Step 3: For all tags other than student , there is no template in our XSL. Therefore, blindly output them, as they are!
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 60.
  • 61.
  • 62.
  • 63. Controlling the Output the Way We Want
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76. Using Parameters in Templates
  • 77.
  • 78.
  • 79.
  • 81.
  • 82.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 111.
  • 112.
  • 113.
  • 115.
  • 116.
  • 117. XPath View Root Comment This is a comment Element BOOK Attribute author Andrew Tanenbaum Attribute edition 3 Element REVIEW Text This is a wonderful book! Text Computer Networks
  • 118.
  • 119.
  • 120. XPath Examples – 1 If context node is the <book> element, an empty node-set would be returned. If the context node is <paragraph> number 1 in <section> 2 of <chapter> 2, the returned node-set would be the text node with value First paragraph . Select all text node children of the context node. child::text() If context node is the <book> element, the node-set containing <title>, <chapters> and <appendices> nodes would be returned. Select all element node children of the context node. Children other than the element node are not selected. child::* If context is book, empty node-set would be returned. If context node is <section> element in chapter 2 with attribute number =“1”, a node-set containing four paragraph nodes would be returned. Select the <paragraph> child element nodes of the context node. child::paragraph Example Meaning Syntax
  • 121. XPath Examples – 2 If context node is the <chapter> 1 element, a node-set containing two attribute nodes would be returned, representing the number and title attributes. Select all attribute nodes of the context node. attribute::* NA Select all attribute nodes with name number under the context node. attribute::number NA Select all the child nodes of the context node. Note that this will return non-elements also. child::node() Example Meaning Syntax
  • 122. XPath Examples – 3 NA Select the context node if it is the <paragraph> element. self:paragraph If the context node is <chapters>, an empty node-set would be returned. If the context node is a <section>, the result would be a node-set containing one <chapter> element which contains this <section> element. Select the <chapter> element nodes that are ancestors of the context node. If the context node is a <chapter> element, return that also. ancestor-or-self::chapter If the context node is <book> or <chapters> element, we would get a node-set consisting of six <paragraph> nodes. If the context node is <section> 1 element for <chapter> 2, we would get a node-set consisting of four <paragraph> nodes. Select all <paragraph> elements that are descendants of the context node. descendant::paragraph Example Meaning Syntax
  • 123. Unabbreviated relative location path Abbreviated relative location path Selection criteria child::BOOK BOOK Element nodes that are children of the context node. child::* * All element nodes that are children of the context node. child::text () text () All text node children of the context node. self::node () . Context node itself. parent::node () .. Parent of the context node. attribute::reviewer @reviewer Attribute reviewer of the context node. attribute::* @* All attributes of the context node. parent::node ()/attribute::reviewer [email_address] Attribute reviewer of the parent of the context node. child::AUTHOR [position () = 1] AUTHOR [1] First AUTHOR child node of the context node. child::AUTHOR [position () = last ()] AUTHOR [last ()] Last AUTHOR child node of the context node. child::REVIEW [attribute::reviewer = “Jui”] REVIEW [@reviewer = “Jui”] All REVIEW element children of the context node having a reviewer attribute with a value of Jui . child::REVIEW [attribute::reviewer = “Jui’] [2] REVIEW [@reviewer = “Jui”] [2] Second REVIEW child of the context node having a reviewer attribute with a value of Jui . child::REVIEW [position () = 2] [attribute::reviewer = “Jui’] REVIEW [2] [@reviewer = “Jui”] Second REVIEW child of the context node if it has a reviewer attribute with a value of Jui . child::*/child::AUTHOR */AUTHOR All grand-children element nodes of the context node that are also AUTHOR elements. child::BOOK[child::TITLE= “TCP/IP”] BOOK[TITLE = “TCP/IP”] BOOK element children of the context node having one or more TITLE element children with string-value as TCP/IP . child::BOOK/child::REVIEW/child::COMMENT [position () = 2] BOOK/REVIEW/COMMENT [2] Second child COMMENT element node of the REVIEW element node, which itself is the child of the BOOK element node. self::node()/descendant-or-self::node()/child:COMMENT .//COMMENT All COMMENT element nodes that are descendants of the context node. Note that the // notation is a short-hand for the descendant:: syntax.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130.
  • 131.
  • 132.
  • 133.
  • 134.
  • 136.
  • 137.
  • 138.
  • 139.
  • 140.
  • 141.
  • 142.
  • 143.
  • 144.
  • 145.
  • 146.
  • 147.
  • 148.
  • 149. Using the Mode Attribute
  • 150.
  • 151.
  • 152. Creating New Elements and Attributes
  • 153.
  • 154.
  • 155.
  • 156.
  • 157.
  • 158.
  • 159.
  • 160.