1 / 75

XML Technologies

XML Technologies. X-Languages. Contents. X Link X Pointer X Path X Query (Brief) X Form (Brief) XSLT FO. X Languages. X Query XPointer XLink. X Path XSLT. X Link. Standard way of defining hyperlinks in XML Short for XML Linking

Download Presentation

XML Technologies

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML Technologies X-Languages

  2. Contents • X Link • X Pointer • X Path • X Query (Brief) • X Form (Brief) • XSLT • FO

  3. X Languages X Query XPointer XLink X Path XSLT

  4. X Link • Standard way of defining hyperlinks in XML • Short for XML Linking • Similar to HTML Links but more powerful • Any element can have an XLink

  5. X Link Syntax • In HTML we use the <A> tag • In XML all tags can have a link <homepages xmlns:xlink="http://www.w3.org/1999/xlink"> <homepage xlink:type="simple" xlink:href="http://www.um.edu.mt"> University of Malta </homepage> </homepages>

  6. X Link Explanation • Declare the namespace in the top element <homepages xmlns:xlink="http://www.w3.org/1999/xlink"> • Define a simple element i.e. Go from the current position to that address. Multidirectional are not supported by most browsers. xlink:type="simple" xlink:href="http://www.um.edu.mt" • To define whether to use the current window or a new one ... xlink:show="new"

  7. Advanced X Links • XLink gets more interesting when we want to access remote locations as resources, instead of standalone pages • The value of the xlink:show attribute could have been set to "embed". This means that the resource should be processed inline within the page • With XLink, you can also specify WHEN the resource should appear • xlink:actuate="onLoad" specifies that the resource should be loaded and shown when the document loads • xlink:actuate="onRequest" means that the resource is not read or shown before the link is clicked. This is very handy for low-bandwidth settings

  8. X Pointer • XML Pointer Language • Allow hyperlinks to point to specific parts of an XML document • Uses XPath for navigation

  9. X Pointer Example • If a hyperlink points to an XML document we can add an XPointer after the URL href="http://www.example.com/cdlist.xml#id('rock').child(5)" • Find the element with unique Id rock • Point to the 5th item in the list

  10. X Pointer Short Hand href="http://www.example.com/cdlist.xml#id('rock') Is equivalent to href="http://www.example.com/cdlist.xml#rock

  11. X Path • Lies at the heart of the XML technologies • Is a syntax for defining parts of document • Uses path expressions to navigate • Contains a library of standard function (over 100) • Major element of XSLT

  12. X Path Nodes • Element • Attribute • Text • Namespace • Processing-instruction (<?xml version="1.0"?>) • Comment • Root node

  13. Node relationships • Parent • Children • Siblings • Ancestors • Descendants

  14. Example <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <book> <title lang="eng">Learning XML</title> <price>39.95</price> </book> </bookstore>

  15. Usage

  16. Examples

  17. Example predicates

  18. Using Wildcards

  19. Selecting several paths

  20. Axes

  21. Location step • an axis (defines the tree-relationship between the selected nodes and the current node) • a node-test (identifies a node within an axis) • zero or more predicates (to further refine the selected node-set) axisname::nodetest[predicate]

  22. Location step example

  23. Absolute vrs Relative An absolute location path: /step/step/... A relative location path: step/step/... The difference is the initial /

  24. Programming example xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load("books.xml"); xpath="/bookstore/book[1]/title"; xmlDoc.selectNodes(xpath);

  25. X Query • Designed to query XML Data • Like SQL for databases • Built on XPath

  26. XQuery Example doc("books.xml")/bookstore/book/title Load the document and use XPath to get the data For more powerful queries use FLWOR expressions

  27. X Forms • Similar to HTML forms but defined in XML • Richer and more flexible • Platform and device independent • Standard in XHTML 2.0

  28. X Forms Example

  29. X Forms Result • The form • The XML • The Text

  30. XSL • XML Stylesheet Language • Consist of three parts • XSLT • Xpath • XSL-FO

  31. XSLT • XSL Transformations • Transforms XML to another XML document • Uses XPath to navigate • Most important part of XSL • Supported by most browsers

  32. Power • Add • Remove • Sort • Rearrange • Perform Tests • Make decisions • Hide • Etc ...

  33. Workings • Use XPath to define elements of source • When a match occurs • Transform the matching part into the resulting document

  34. Example CD Catalogue (XML) CD Catalogue (XSL) CD Catalogue (XML + XSL) Combined by adding the following line in the XML document <?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>

  35. Declaration part of a Stylesheet <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  36. <xsl:template> • XSL style sheet made up of different rules called templates • The Match attribute is used to associate a template to an element in the XML document

  37. Simple Template 1

  38. Simple Template 1 Result

  39. Simple Template 2

  40. Simple Template 2 Result

  41. Simple Template 3

  42. Simple Template 3 Result

  43. Simple Template 4

  44. Simple Template 4 Result

  45. Simple Template 5

  46. Simple Template 5 Result

  47. Simple Template 6

  48. Simple Template 6 Result

  49. Simple Template 7

More Related