Your SlideShare is downloading. ×
0
 An XML transformation language is
a programming language designed
specifically to transform
an input XML document into a...
 XSLT
- XSLT is a language for transforming
XML documents into XHTML documents or
to other XML documents.
 XPATH
- XPath...
 XSLT stands for XSL Transformations
 XSLT is the most important part of XSL
 XSL stands for
EXtensible Stylesheet Lang...
 The root element that declares the document
to be an XSL style sheet is <xsl:stylesheet>
or <xsl:transform>.
 <xsl:styl...
 XPath is used to navigate through elements and
attributes in an XML document.
 XPath is a syntax for defining parts of ...
 The <xsl:template> element is used to build
templates.
 The match attribute is used to associate a
template with an XML...
 The <xsl:value-of> Element
 The <xsl:value-of> element can be used to
extract the value of an XML element and add
it to...
 Example:
 We want to transform the following XML document ("cdcatalog.xml") into HTML:
 <?xml version="1.0" encoding="...
 Then you create an XSL Style Sheet ("cdcatalog.xsl") with a transformation template:
 <?xml version="1.0" encoding="UTF...
Add the XSL style sheet reference to your XML document ("cdcatalog.xml"):
 <?xml version="1.0" encoding="UTF-8"?>
<?xml-s...
 XQuery is designed to query XML data - not
just XML files, but anything that can appear
as XML, including databases.
 X...
 Functions
 XQuery uses functions to extract data from
XML documents.
 The doc() function is used to open the
"books.xm...
 Path Expressions
 XQuery uses path expressions to navigate
through elements in an XML document.
 The following path ex...
 doc("books.xml")/bookstore/book[price>30]/
title
 The expression above will select all the title
elements under the boo...
 XLink is short for XML Linking Language
 XLink is used to create hyperlinks in XML
documents
 Any element in an XML do...
 <?xml version="1.0" encoding="UTF-8"?>
<homepages
xmlns:xlink="http://www.w3.org/1999/xlink">
<homepage xlink:type="simp...
 http://www.w3schools.com
 http://en.wikipedia.org/wiki/XML_transforma
tion_language
Xml transformation language
Xml transformation language
Xml transformation language
Xml transformation language
Upcoming SlideShare
Loading in...5
×

Xml transformation language

115

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
115
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Xml transformation language"

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

    Clipping is a handy way to collect important slides you want to go back to later.

×