Overview of XSL, XPath and XSL-FO

1,267 views

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
1,267
On SlideShare
0
From Embeds
0
Number of Embeds
307
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Overview of XSL, XPath and XSL-FO

  1. 1. Overview of XSLT, XPATH, and XSL-FO(Beginner Level) Adena FrazerSuite Solutions<br />
  2. 2. Overview of XSLMain Topics<br /><ul><li>What is XSL?
  3. 3. XPATH
  4. 4. XSL-FO
  5. 5. XSLT
  6. 6. XSL Resources</li></li></ul><li>What is XSL?<br /><ul><li>XSL – Extensible Stylesheet Language
  7. 7. “A family of transformation languages which allows one to describe how files encoded in the XML standard are to be formatted or transformed” (Wikipedia).
  8. 8. Written in valid XML (Extensible Markup Language), which requires matching starting and ending tags around content. </li></ul> <xml>Sample</xml><br /><ul><li>Includes:</li></ul>XPATH -XML Path Language (not XML)<br />XSL-FO - XSL Formatting Objects <br />XSLT - XSL Transformations<br />
  9. 9. Overview of XSLMain Topics<br /><ul><li>What is XSL?
  10. 10. XPATH
  11. 11. XSL-FO
  12. 12. XSLT
  13. 13. XSL Resources</li></li></ul><li>XPATH<br />Language used to select information from an XML document <br />Based on relationships between nodes (which include elements and attributes)<br />Parents, Children, Siblings, Ancestors, Descendants<br />Can contain expressions, which calculate and compare values using operators.<br />Operator Reference:<br />http://www.w3schools.com/xpath/xpath_operators.asp<br />Can contain built-in functions<br />Function Reference: http://www.w3schools.com/xpath/xpath_functions.asp<br />Nodes can be referenced using full syntax or abbreviated syntax.<br />
  14. 14. XPATH Syntax (Full)<br />Axis – defines a nodeset relative to a current node<br /><ul><li>For more details and examples, see: http://www.w3schools.com/xpath/xpath_axes.asp</li></li></ul><li>XPATH Syntax (Abbreviated)<br />
  15. 15. XPATH Examples (1)<br />XPATH is used by XSLT to retrieve information from an XML document<br />Variable values<br />Test conditions<br />Template matches<br />Example (from commons.xsl line 160):<br />From a node that is the current node’s ancestor<br />This expression will be true if the condition inside of the parentheses is false [if no nodes match this description]<br />Get any node<br />Whose class attribute contains the text ‘ topic/topic ‘<br />
  16. 16. XPATH Examples (2)<br /><ul><li>Example (from code that checks if an item is last in a list):</li></ul>Evaluate to true if the preceding node count is zero; otherwise evaluate to false<br />Get any node<br />Count how many nodes meet this criteria:<br />From a node which is a sibling to the current node and comes after the current node<br /><ul><li>Example (from commons.xsl line 67):</li></ul>From the first node the meets the preceding criteria<br />From a node that is the current node or the current node’s ancestor<br />Get any node<br />Whose class attribute contains the text ‘ topic/topic ‘<br />Get the value of the id attribute<br />
  17. 17. Overview of XSLMain Topics<br /><ul><li>What is XSL?
  18. 18. XPATH
  19. 19. XSL-FO
  20. 20. XSLT
  21. 21. XSL Resources</li></li></ul><li>XSL-FO Overview<br />A unified presentation language which stores both the content of the document and the document’s formatting information.<br />Intended for documents with pages, as opposed to other languages such as HTML<br />Generally used as the stage before PDF format<br />The document is converted to PDF using a Formatting Object Processor<br />The FO Plug-in uses a .fo extension for XSL-FO Files<br />Required components of an FO document:<br />
  22. 22. XSL-FO:Document Components<br />Required components of an FO document:<br />XML Declaration<br />XSL-FO is a type of XML<br /><ul><li>Root Node
  23. 23. Contains the whole document, including the Page Layout and Document Data sections
  24. 24. Declares the XSL-FO Namespace</li></li></ul><li>XSL-FO:Document Components<br />Page Layout<br />Defines the properties of a page, including the size, margins and direction of the text flow<br />There can be many simple-page-masters - one for each type of page<br />
  25. 25. XSL-FO:Document Components<br />Document Data<br />References a master-reference which is defined in the Page Layout section<br />Uses flows to define which part of the page should be used<br />Legal values: xsl-region-body, xsl-region-before, xsl-region-after, xsl-region-start, xsl-region-end<br />Contains the content of the page which is formatted using blocks and inline objects.<br />
  26. 26. Margin Top<br />Region Before<br />Region Body<br />Region Start<br />Region End<br />Margin Right<br />Margin Left<br />Region After<br />Margin Bottom<br />XSL-FO Page Layout<br /><ul><li>Page Layout Diagram for a Left to Right and Top to Bottom Text Flow (defined by writing mode attribute)
  27. 27. Diagram is different for different text flows </li></li></ul><li>XSL-FO Elements<br />XSL-FO has many elements which are used to format the document. All elements should be preceded by the fo: prefix.<br />These elements include:<br />Table elements: table, table-body, table-cell table-row, table-and-caption, table-caption, table-footer, table-header, table-column<br />List elements – list-block, list-item, list-item-body, list-item-label<br />Block elements: block, block-container<br />Inline elements: inline, inline-container<br />Page-Number: represents the current page-number<br />Leader: repeats the specified character<br />Formatting Objects Reference: http://www.w3schools.com/xslfo/xslfo_reference.asp<br />
  28. 28. XSL-FO Attributes<br />Each element in XSL-FO has a corresponding set of attributes<br />These include:<br />Widow and orphans: keep-with-next, keep-with-previous, keep-together, widows, orphans<br />Colors: background-color, color<br />Font size and style: font-family, font-weight, font-style, font-size<br />Borders: border-after-color, border-after-style, border-after-width…<br />Spacing: padding-after, padding-left, padding-right, margin-left, margin-right, margin-bottom, margin-top<br />
  29. 29. Overview of XSLMain Topics<br /><ul><li>What is XSL?
  30. 30. XPATH
  31. 31. XSL-FO
  32. 32. XSLT
  33. 33. XSL Resources</li></li></ul><li>XSLT (Extensible Stylesheet Language Transformations)<br />Used to transform XML documents (such as DITA) into XML (such as XHTML, XSL-FO) or other documents (such as text).<br />XSLTStylesheet<br />XSLT Engine / Software / Browser<br />New Document<br />Source XML Document<br />
  34. 34. XSLT (Extensible Stylesheet Language Transformations)<br />XSLT style sheets- contain the formatting and logic of the document. The same style sheets can be reused with any content.<br />Original XML document - contains the content.<br />Style sheets can be applied to the content via:<br />An XSLT compliant browser such as IE6+ <br />Software such as Cooktop <br />http://www.xmlcooktop.com/<br />XSL files end with .xsl (or .xslt) extensions<br />Much of the internal workings of the Toolkit and the Plug-in as well as Toolkit and Plug-in customizations are implemented using XSLT.<br />
  35. 35. XSLT ElementsAttribute Sets, Templates<br />The main units of code that the FO Plug-in uses to process DITA are attribute sets and templates.<br />Attribute Set - a unit of code that primarily stores information about how to formata DITA element.<br />Example: an attribute set which relates to a <p> element may store information about which font, font size, and font weight should be used to display text surrounded by <p> tags.<br />Template – a unit of code that primarily contains instructions about how to process the DITA. <br />Example: a template which relates to a <p> element may contain instructions about when and where to display auto-generated text and what that text should be.<br />
  36. 36. XSLT ElementsAttribute Sets, Templates<br /><ul><li>Attribute – an XSLT element that corresponds to a single XSL-FO attribute. The name of the XSLT attribute corresponds to the XSL-FO attribute name, and the text surrounded by the XSLT attribute tags corresponds to the XSL-FO attribute value.</li></ul>Example (from commons-attr.xsl line 419):<br /><ul><li>Attribute Set – contains a group of attributes.
  37. 37. Example (from commons-attr.xsl line 418):</li></li></ul><li>XSLT ElementsAttribute Sets, Templates<br />Template –contains instructions about how to process the XML content defined by the template’s match attribute.<br />Example (from commons.xsl line 1625):<br /><ul><li>Matches XML elements whose class attribute contains the text ‘ topic/ph ‘
  38. 38. Puts the content of those elements inside of an XSL:FO <inline> tag
  39. 39. Identifies the attributes in the “ph” attribute set as attributes of the XSL-FO inline element</li></li></ul><li>XSLT Elements:Attribute Sets, Templates<br /><ul><li>Example
  40. 40. Original XML Content:
  41. 41. Code is processed using the template and attribute set from the previous slides
  42. 42. XSL-FO Output:</li></li></ul><li>Overview of XSLMain Topics<br /><ul><li>What is XSL?
  43. 43. XPATH
  44. 44. XSL-FO
  45. 45. XSLT
  46. 46. XSL Resources</li></li></ul><li>XSL Resources (1)<br />Email Lists<br />Mulberry Technologies XSL Email List<br />http://www.mulberrytech.com/xsl/xsl-list/subscribe-unsubscribe.html<br />Dita-Users email list (for Toolkit / Plug-in related questions)<br />http://tech.groups.yahoo.com/group/dita-users/<br />W3C Documentation<br />XSL Version 1.0<br />http://www.w3.org/TR/2001/REC-xsl-20011015/<br />XSL Version 1.1<br />http://www.w3.org/TR/2006/REC-xsl11-20061205/<br />XPATH Version 1.0<br />http://www.w3.org/TR/xpath<br />XPATH Version 2.0<br />http://www.w3.org/TR/2007/REC-xpath20-20070123/<br />XPATH Functions and Operators Reference<br />http://www.w3.org/TR/xpath-functions/<br />
  47. 47. XSL Resources (2)<br />Other Websites<br />W3Schools Tutorials and References<br />XSLT:http://www.w3schools.com/xsl/default.asp<br />XSL-FO:http://www.w3schools.com/xslfo/default.asp<br />XPath:http://www.w3schools.com/xpath/default.asp<br />XSLT Reference<br />http://www.zvon.org/xxl/XSLTreference/Output/<br />Dave Pawson’s XSL FAQ<br />http://www.dpawson.co.uk/xsl/<br />Wikipedia<br />http://www.wikipedia.org/<br />
  48. 48. Overview of XSLMain Topics<br /><ul><li>What is XSL?
  49. 49. XPATH
  50. 50. XSL-FO
  51. 51. XSLT
  52. 52. XSL Resources</li></li></ul><li>End of Session: Overview of XSLT, XPATH, and XSL-FO (Beginner Level)<br />

×