XPATH Language used to select information from an XML document Based on relationships between nodes (which include elements and attributes) Parents, Children, Siblings, Ancestors, Descendants Can contain expressions, which calculate and compare values using operators. Operator Reference: http://www.w3schools.com/xpath/xpath_operators.asp Can contain built-in functions Function Reference: http://www.w3schools.com/xpath/xpath_functions.asp Nodes can be referenced using full syntax or abbreviated syntax.
XPATH Syntax (Full) Axis – defines a nodeset relative to a current node
For more details and examples, see: http://www.w3schools.com/xpath/xpath_axes.asp
XPATH Syntax (Abbreviated)
XPATH Examples (1) XPATH is used by XSLT to retrieve information from an XML document Variable values Test conditions Template matches Example (from commons.xsl line 160): From a node that is the current node’s ancestor This expression will be true if the condition inside of the parentheses is false [if no nodes match this description] Get any node Whose class attribute contains the text ‘ topic/topic ‘
Example (from code that checks if an item is last in a list):
Evaluate to true if the preceding node count is zero; otherwise evaluate to false Get any node Count how many nodes meet this criteria: From a node which is a sibling to the current node and comes after the current node
Example (from commons.xsl line 67):
From the first node the meets the preceding criteria From a node that is the current node or the current node’s ancestor Get any node Whose class attribute contains the text ‘ topic/topic ‘ Get the value of the id attribute
XSL-FO Overview A unified presentation language which stores both the content of the document and the document’s formatting information. Intended for documents with pages, as opposed to other languages such as HTML Generally used as the stage before PDF format The document is converted to PDF using a Formatting Object Processor The FO Plug-in uses a .fo extension for XSL-FO Files Required components of an FO document:
XSL-FO:Document Components Required components of an FO document: XML Declaration XSL-FO is a type of XML
Contains the whole document, including the Page Layout and Document Data sections
XSL-FO:Document Components Page Layout Defines the properties of a page, including the size, margins and direction of the text flow There can be many simple-page-masters - one for each type of page
XSL-FO:Document Components Document Data References a master-reference which is defined in the Page Layout section Uses flows to define which part of the page should be used Legal values: xsl-region-body, xsl-region-before, xsl-region-after, xsl-region-start, xsl-region-end Contains the content of the page which is formatted using blocks and inline objects.
Margin Top Region Before Region Body Region Start Region End Margin Right Margin Left Region After Margin Bottom XSL-FO Page Layout
Page Layout Diagram for a Left to Right and Top to Bottom Text Flow (defined by writing mode attribute)
XSL-FO Elements XSL-FO has many elements which are used to format the document. All elements should be preceded by the fo: prefix. These elements include: Table elements: table, table-body, table-cell table-row, table-and-caption, table-caption, table-footer, table-header, table-column List elements – list-block, list-item, list-item-body, list-item-label Block elements: block, block-container Inline elements: inline, inline-container Page-Number: represents the current page-number Leader: repeats the specified character Formatting Objects Reference: http://www.w3schools.com/xslfo/xslfo_reference.asp
XSL-FO Attributes Each element in XSL-FO has a corresponding set of attributes These include: Widow and orphans: keep-with-next, keep-with-previous, keep-together, widows, orphans Colors: background-color, color Font size and style: font-family, font-weight, font-style, font-size Borders: border-after-color, border-after-style, border-after-width… Spacing: padding-after, padding-left, padding-right, margin-left, margin-right, margin-bottom, margin-top
XSLT (Extensible Stylesheet Language Transformations) Used to transform XML documents (such as DITA) into XML (such as XHTML, XSL-FO) or other documents (such as text). XSLTStylesheet XSLT Engine / Software / Browser New Document Source XML Document
XSLT (Extensible Stylesheet Language Transformations) XSLT style sheets- contain the formatting and logic of the document. The same style sheets can be reused with any content. Original XML document - contains the content. Style sheets can be applied to the content via: An XSLT compliant browser such as IE6+ Software such as Cooktop http://www.xmlcooktop.com/ XSL files end with .xsl (or .xslt) extensions Much of the internal workings of the Toolkit and the Plug-in as well as Toolkit and Plug-in customizations are implemented using XSLT.
XSLT ElementsAttribute Sets, Templates The main units of code that the FO Plug-in uses to process DITA are attribute sets and templates. Attribute Set - a unit of code that primarily stores information about how to formata DITA element. 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. Template – a unit of code that primarily contains instructions about how to process the DITA. 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.
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.