SlideShare a Scribd company logo
1 of 32
Download to read offline
IT6801
SERVICE ORIENTED
ARCHITECTURE
-
UNIT I INTRODUCTION TO XML
XML document structure – Well formed and valid
documents – Namespaces – DTD – XML Schema
– X-Files.
XML and XSLT
With XSLT
One can transform
an XML document into HTML.
Displaying XML with XSLT
• XSLT means eXtensible Stylesheet Language Transformations
• XSLT is the recommended style sheet language for XML.
• XSLT is far more sophisticated than CSS.
• With XSLT, one can
– Add/remove elements and attributes to or from the output file.
– Rearrange and sort elements,
– Perform tests and make decisions about which elements to hide and
display, and a lot more.
XSLT Example
• XSLT uses XPath to find information in an XML document.
<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
  <food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>Two of our famous Belgian Waffles with plenty 
of real maple syrup</description>
<calories>650</calories>
  </food>
  <food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>Light Belgian waffles covered with 
              strawberries and whipped cream</description>
<calories>900</calories>
  </food>
  <food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<desription> Light Belgian waffles covered with an 
assortment of fresh berries and whipped cream 
</description>
<calories>900</calories>
  </food>
  <food>
<name>French Toast</name>
<price>$4.50</price>
<description>Thick slices made from bread</description>
<calories>600</calories>
  </food>
  <food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description> Two eggs, bacon or sausage, toast, and
 our ever-popular hash browns </description>
<calories>950</calories>
  </food>
</breakfast_menu>
XSLT Example
• XSLT uses XPath to find information in an XML document.
<?xml version="1.0" encoding="UTF-8"?>
<html xsl:version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<body style="font-family:Arial;font-size:12pt;
              background-color:#EEEEEE">
<xsl:for-each select="breakfast_menu/food">
  <div style="background-color:teal;color:white;padding:4px">
    <span style="font-weight:bold"><xsl:value-of select="name"/> - 
</span>
    <xsl:value-of select="price"/>
  </div>
 
 
XSLT Example
• XSLT uses XPath to find information in an XML document.
 
 <div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
    <p>
    <xsl:value-of select="description"/>
    <span style="font-style:italic"> 
      (<xsl:value-of select="calories"/> calories per serving)
    </span>
    </p>
  </div>
</xsl:for-each>
</body>
</html>
Displaying XML with XSLT
• This is displayed in a browser:
X-Files
XPath
Xpointer
XLink
Xpath
(XML Path language)
A language with a standard syntax
for finding information in an XML document
Introduction
• What is XPath?
– XPath is a syntax for defining parts of an XML document
– XPath uses path expressions to navigate in XML documents
– XPath contains a library of standard functions
– XPath is a major element in XSLT
– XPath is also used in XQuery, XPointer and XLink
– XPath is a W3C recommendation
• XPath was created
– To reduce the amount of time to find the elements and attributes
desired by an author
XPath Path Expressions
• XPath uses path expressions
– To select nodes or node-sets in an XML document.
• XPath expressions can be used in
– JavaScript,
– Java,
– XML Schema,
– PHP,
– Python,
– C and C++, and lots of other languages.
XPath Standard Functions
• XPath includes over 100 built-in functions.
• There are functions for
– String values,
– Numeric values,
– Date and time comparison,
– Node and QName manipulation,
– Sequence manipulation,
– Boolean values, and more.
XPath is Used in XSLT
• XPath was designed to be used by
– XSLT,
– XPointer and
– Other XML parsing software.
• Without XPath knowledge
– You will not be able to create XSLT documents.
XPath Terminology - Nodes
• XML documents are treated as trees of nodes.
• Topmost element of the tree is called the root element.
• In XPath, there are seven kinds of nodes:
– Element, attribute, text, namespace, processing-instruction, comment,
and document nodes.
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
  <book>
    <title lang="en">Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
  </book>
</bookstore>
Example of nodes in this XML document:
<bookstore> (root element node)
<author>J K. Rowling</author> (element node)
lang="en" (attribute node)
Atomic values are nodes with no children or parent.
Example of atomic values:
J K. Rowling
"en"
Items are atomic values or nodes.
Relationship of Nodes
• Parent - Each element and attribute has one parent.
• Children - Element nodes may have zero, one or more children.
• Siblings - Nodes that have the same parent.
• Ancestors - A node's parent, parent's parent, etc.
• Descendants - A node's children, children's children, etc.
• In this example; 
– book element is the parent of the title, author, year, and price
– title, author, year, and price elements are all children of  book element
– title, author, year, and price elements are all siblings
– ancestors of title element are book element and  bookstore element:
<bookstore>
  <book>
  <title>Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
 </book>
</bookstore>
Descendants of bookstore element 
are the book, title, author, year, 
and price elements:
XPath Syntax
• XPath uses path expressions to select nodes in an XML document
• Node is selected by following a path or steps.
Expression Description
nodename Selects all nodes with the name "nodename"
/ Selects from the root node
//
Selects nodes in the document from the current node that match 
the selection no matter where they are
. Selects the current node
.. Selects the parent of the current node
@ Selects attributes
Example for 
Xpath 
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book>
  <title lang="en">Harry Potter</title>
  <price>29.99</price>
</book>
<book>
  <title lang="en">Learning XML</title>
  <price>39.95</price>
</book>
</bookstore>
Path Expression Result
bookstore Selects all nodes with the name "bookstore"
/bookstore
Selects the root element bookstore
Note: If the path starts with a slash ( / ) it always
represents an absolute path to an element!
bookstore/book Selects all book elements that are children of bookstore
//book
Selects all book elements no matter where they are in the
document
bookstore//book
Selects all book elements that are descendant of the
bookstore element, no matter where they are under the
bookstore element
//@lang Selects all attributes that are named lang
Predicates
• Used to find a specific node or a node that contains a specific value.
• Predicates are always embedded in square brackets.
Path Expression Result
/bookstore/book[1]
Selects the first book element that is the child of the bookstore
element.
Note: In IE 5,6,7,8,9 first node is[0], but according to W3C, it is
[1]. To solve this problem in IE, set the SelectionLanguage to
XPath:
In JavaScript: xml.setProperty("SelectionLanguage","XPath");
/bookstore/book[last()]
Selects the last book element that is the child of the bookstore
element
Predicates
Path Expression Result
/bookstore/book[last()-1]
Selects the last but one book element that is the child of
the bookstore element
/bookstore/book[position()<3]
Selects the first two book elements that are children of
the bookstore element
//title[@lang]
Selects all the title elements that have an attribute
named lang
//title[@lang='en']
Selects all the title elements that have a "lang" attribute
with a value of "en"
/bookstore/book[price>35.00]
Selects all the book elements of the bookstore element
that have a price element with a value greater than
35.00
/bookstore/book[price>35.00]/title
Selects all the title elements of the book elements of the
bookstore element that have a price element with a
value greater than 35.00
Selecting Unknown Nodes
• XPath wildcards can be used to select unknown XML nodes.
• Example:
Wildcard Description
* Matches any element node
@* Matches any attribute node
node() Matches any node of any kind
Path Expression Result
/bookstore/*
Selects all the child element nodes of the
bookstore element
//* Selects all elements in the document
//title[@*]
Selects all title elements which have at least
one attribute of any kind
Selecting Several Paths
• By using the | operator in an XPath expression you can select several paths.
• Some path expressions and the result of the expressions:
Path Expression Result
//book/title | //book/price
Selects all the title AND price elements of all book
elements
//title | //price
Selects all the title AND price elements in the
document
/bookstore/book/title | //price
Selects all the title elements of the book element of
the bookstore element AND all the price elements in
the document
03 x files
Example for Xpath
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book>
  <title lang="en">Harry Potter</title>
  <price>29.99</price>
</book>
<book>
  <title lang="en">Learning XML</title>
  <price>39.95</price>
</book>
</bookstore>
Path Expression Result
//book/title | //book/price
Selects all the title AND price elements of all
book elements
//title | //price
Selects all the title AND price elements in the
document
/bookstore/book/title | //price
Selects all the title elements of the book
element of the bookstore element AND all the
price elements in the document
XPath Syntax
• XPath uses path expressions
– To select nodes in an XML document
• Node is selected by following a path or steps.
Expression Description
nodename Selects all nodes with the name "nodename"
/ Selects from the root node
//
Selects nodes in the document from the current node that
match the selection no matter where they are
. Selects the current node
.. Selects the parent of the current node
@ Selects attributes
XPath Syntax
• XPath uses path expressions
– To select nodes in an XML document
• Node is selected by following a path or steps.
Expression Description
nodename Selects all nodes with the name "nodename"
/ Selects from the root node
//
Selects nodes in the document from the current node that
match the selection no matter where they are
. Selects the current node
.. Selects the parent of the current node
@ Selects attributes
03 x files
XPath Example
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="cooking">
  <title lang="en">Everyday Italian</title>
  <author>Giada De Laurentiis</author>
  <year>2005</year>
  <price>30.00</price>
</book>
<book category="children">
  <title lang="en">Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>
XPath Example
<book category="web">
  <title lang="en">XQuery Kick Start</title>
  <author>James McGovern</author>
  <author>Per Bothner</author>
  <author>Kurt Cagle</author>
  <author>James Linn</author>
  <author>Vaidyanathan Nagarajan</author>
  <year>2003</year>
  <price>49.99</price>
</book>
<book category="web">
  <title lang="en">Learning XML</title>
  <author>Erik T. Ray</author>
  <year>2003</year>
  <price>39.95</price>
</book>
</bookstore>
03 x files

More Related Content

What's hot (20)

X FILES
X FILESX FILES
X FILES
 
Ch2 neworder
Ch2 neworderCh2 neworder
Ch2 neworder
 
Learning XSLT
Learning XSLTLearning XSLT
Learning XSLT
 
Basics of XML
Basics of XMLBasics of XML
Basics of XML
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 
Xml basics for beginning
Xml basics for beginningXml basics for beginning
Xml basics for beginning
 
XML
XMLXML
XML
 
Xml Presentation-3
Xml Presentation-3Xml Presentation-3
Xml Presentation-3
 
XML
XMLXML
XML
 
XML
XMLXML
XML
 
Xml
XmlXml
Xml
 
Xml schema
Xml schemaXml schema
Xml schema
 
XML Schema
XML SchemaXML Schema
XML Schema
 
02 xml schema
02 xml schema02 xml schema
02 xml schema
 
Publishing xml
Publishing xmlPublishing xml
Publishing xml
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
fundamentals of XML
fundamentals of XMLfundamentals of XML
fundamentals of XML
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
XML/XSLT
XML/XSLTXML/XSLT
XML/XSLT
 
Xml schema
Xml schemaXml schema
Xml schema
 

Similar to 03 x files (20)

Xpath
XpathXpath
Xpath
 
X path
X pathX path
X path
 
X path
X pathX path
X path
 
Querring xml with xpath
Querring xml with xpath Querring xml with xpath
Querring xml with xpath
 
XML
XMLXML
XML
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 
Xml session
Xml sessionXml session
Xml session
 
XML Technologies
XML TechnologiesXML Technologies
XML Technologies
 
XSLT
XSLTXSLT
XSLT
 
Xml transformation language
Xml transformation languageXml transformation language
Xml transformation language
 
Structured Strategy: How to Supercharge Your Content Analysis with XML and XPath
Structured Strategy: How to Supercharge Your Content Analysis with XML and XPathStructured Strategy: How to Supercharge Your Content Analysis with XML and XPath
Structured Strategy: How to Supercharge Your Content Analysis with XML and XPath
 
Xml
XmlXml
Xml
 
Day2 xslt x_path_xquery
Day2 xslt x_path_xqueryDay2 xslt x_path_xquery
Day2 xslt x_path_xquery
 
XML Transformations With PHP
XML Transformations With PHPXML Transformations With PHP
XML Transformations With PHP
 
Session 4
Session 4Session 4
Session 4
 
Xml
XmlXml
Xml
 
Xml passing in java
Xml passing in javaXml passing in java
Xml passing in java
 
Xml
XmlXml
Xml
 
Unit 5 xml (1)
Unit 5   xml (1)Unit 5   xml (1)
Unit 5 xml (1)
 
23xml
23xml23xml
23xml
 

More from Baskarkncet

More from Baskarkncet (16)

Unit_I.pptx
Unit_I.pptxUnit_I.pptx
Unit_I.pptx
 
Cocomo model
Cocomo modelCocomo model
Cocomo model
 
Unit 1
Unit 1Unit 1
Unit 1
 
HCI
HCIHCI
HCI
 
03 namespace
03 namespace03 namespace
03 namespace
 
11 deployment diagrams
11 deployment diagrams11 deployment diagrams
11 deployment diagrams
 
10 component diagram
10 component diagram10 component diagram
10 component diagram
 
09 package diagram
09 package diagram09 package diagram
09 package diagram
 
08 state diagram and activity diagram
08 state diagram and activity diagram08 state diagram and activity diagram
08 state diagram and activity diagram
 
07 interaction diagrams
07 interaction diagrams07 interaction diagrams
07 interaction diagrams
 
06 class diagrams
06 class diagrams06 class diagrams
06 class diagrams
 
05 use case
05 use case05 use case
05 use case
 
03 unified process
03 unified process03 unified process
03 unified process
 
02 uml
02 uml02 uml
02 uml
 
04 uml diagrams
04 uml diagrams04 uml diagrams
04 uml diagrams
 
01 introduction
01 introduction01 introduction
01 introduction
 

Recently uploaded

me3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part Ame3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part Akarthi keyan
 
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...amrabdallah9
 
specification estimation and valuation of a building
specification estimation and valuation of a buildingspecification estimation and valuation of a building
specification estimation and valuation of a buildingswethasekhar5
 
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Sean Meyn
 
GENERAL CONDITIONS FOR CONTRACTS OF CIVIL ENGINEERING WORKS
GENERAL CONDITIONS  FOR  CONTRACTS OF CIVIL ENGINEERING WORKS GENERAL CONDITIONS  FOR  CONTRACTS OF CIVIL ENGINEERING WORKS
GENERAL CONDITIONS FOR CONTRACTS OF CIVIL ENGINEERING WORKS Bahzad5
 
nvidia AI-gtc 2024 partial slide deck.pptx
nvidia AI-gtc 2024 partial slide deck.pptxnvidia AI-gtc 2024 partial slide deck.pptx
nvidia AI-gtc 2024 partial slide deck.pptxjasonsedano2
 
CSR Managerial Round Questions and answers.pptx
CSR Managerial Round Questions and answers.pptxCSR Managerial Round Questions and answers.pptx
CSR Managerial Round Questions and answers.pptxssusera0771e
 
Guardians and Glitches: Navigating the Duality of Gen AI in AppSec
Guardians and Glitches: Navigating the Duality of Gen AI in AppSecGuardians and Glitches: Navigating the Duality of Gen AI in AppSec
Guardians and Glitches: Navigating the Duality of Gen AI in AppSecTrupti Shiralkar, CISSP
 
Phase noise transfer functions.pptx
Phase noise transfer      functions.pptxPhase noise transfer      functions.pptx
Phase noise transfer functions.pptxSaiGouthamSunkara
 
Mohs Scale of Hardness, Hardness Scale.pptx
Mohs Scale of Hardness, Hardness Scale.pptxMohs Scale of Hardness, Hardness Scale.pptx
Mohs Scale of Hardness, Hardness Scale.pptxKISHAN KUMAR
 
Basic Principle of Electrochemical Sensor
Basic Principle of  Electrochemical SensorBasic Principle of  Electrochemical Sensor
Basic Principle of Electrochemical SensorTanvir Moin
 
How to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdfHow to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdfRedhwan Qasem Shaddad
 
Carbohydrates principles of biochemistry
Carbohydrates principles of biochemistryCarbohydrates principles of biochemistry
Carbohydrates principles of biochemistryKomakeTature
 
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docxSUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docxNaveenVerma126
 
Gender Bias in Engineer, Honors 203 Project
Gender Bias in Engineer, Honors 203 ProjectGender Bias in Engineer, Honors 203 Project
Gender Bias in Engineer, Honors 203 Projectreemakb03
 
Tachyon 100G PCB Performance Attributes and Applications
Tachyon 100G PCB Performance Attributes and ApplicationsTachyon 100G PCB Performance Attributes and Applications
Tachyon 100G PCB Performance Attributes and ApplicationsEpec Engineered Technologies
 
cloud computing notes for anna university syllabus
cloud computing notes for anna university syllabuscloud computing notes for anna university syllabus
cloud computing notes for anna university syllabusViolet Violet
 
Power System electrical and electronics .pptx
Power System electrical and electronics .pptxPower System electrical and electronics .pptx
Power System electrical and electronics .pptxMUKULKUMAR210
 

Recently uploaded (20)

me3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part Ame3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part A
 
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
 
specification estimation and valuation of a building
specification estimation and valuation of a buildingspecification estimation and valuation of a building
specification estimation and valuation of a building
 
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
 
GENERAL CONDITIONS FOR CONTRACTS OF CIVIL ENGINEERING WORKS
GENERAL CONDITIONS  FOR  CONTRACTS OF CIVIL ENGINEERING WORKS GENERAL CONDITIONS  FOR  CONTRACTS OF CIVIL ENGINEERING WORKS
GENERAL CONDITIONS FOR CONTRACTS OF CIVIL ENGINEERING WORKS
 
nvidia AI-gtc 2024 partial slide deck.pptx
nvidia AI-gtc 2024 partial slide deck.pptxnvidia AI-gtc 2024 partial slide deck.pptx
nvidia AI-gtc 2024 partial slide deck.pptx
 
CSR Managerial Round Questions and answers.pptx
CSR Managerial Round Questions and answers.pptxCSR Managerial Round Questions and answers.pptx
CSR Managerial Round Questions and answers.pptx
 
計劃趕得上變化
計劃趕得上變化計劃趕得上變化
計劃趕得上變化
 
Guardians and Glitches: Navigating the Duality of Gen AI in AppSec
Guardians and Glitches: Navigating the Duality of Gen AI in AppSecGuardians and Glitches: Navigating the Duality of Gen AI in AppSec
Guardians and Glitches: Navigating the Duality of Gen AI in AppSec
 
Phase noise transfer functions.pptx
Phase noise transfer      functions.pptxPhase noise transfer      functions.pptx
Phase noise transfer functions.pptx
 
Mohs Scale of Hardness, Hardness Scale.pptx
Mohs Scale of Hardness, Hardness Scale.pptxMohs Scale of Hardness, Hardness Scale.pptx
Mohs Scale of Hardness, Hardness Scale.pptx
 
Basic Principle of Electrochemical Sensor
Basic Principle of  Electrochemical SensorBasic Principle of  Electrochemical Sensor
Basic Principle of Electrochemical Sensor
 
How to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdfHow to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdf
 
Carbohydrates principles of biochemistry
Carbohydrates principles of biochemistryCarbohydrates principles of biochemistry
Carbohydrates principles of biochemistry
 
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docxSUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
 
Présentation IIRB 2024 Marine Cordonnier.pdf
Présentation IIRB 2024 Marine Cordonnier.pdfPrésentation IIRB 2024 Marine Cordonnier.pdf
Présentation IIRB 2024 Marine Cordonnier.pdf
 
Gender Bias in Engineer, Honors 203 Project
Gender Bias in Engineer, Honors 203 ProjectGender Bias in Engineer, Honors 203 Project
Gender Bias in Engineer, Honors 203 Project
 
Tachyon 100G PCB Performance Attributes and Applications
Tachyon 100G PCB Performance Attributes and ApplicationsTachyon 100G PCB Performance Attributes and Applications
Tachyon 100G PCB Performance Attributes and Applications
 
cloud computing notes for anna university syllabus
cloud computing notes for anna university syllabuscloud computing notes for anna university syllabus
cloud computing notes for anna university syllabus
 
Power System electrical and electronics .pptx
Power System electrical and electronics .pptxPower System electrical and electronics .pptx
Power System electrical and electronics .pptx
 

03 x files