Top Banner
Introduction to XSL-FO OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn Road, Suite 100 Camarillo, CA 93012
11

Introduction to XSL FOsupport.omniupdate.com/oucampus10/workshop/documents/xsl-fo... · Introduction to XSL-FO OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn

Sep 22, 2018

Download

Documents

vantuong
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to XSL FOsupport.omniupdate.com/oucampus10/workshop/documents/xsl-fo... · Introduction to XSL-FO OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn

Introduction to XSL-FO OmniUpdate User Training Conference 2015

OmniUpdate, Inc.

1320 Flynn Road, Suite 100 Camarillo, CA 93012

Page 2: Introduction to XSL FOsupport.omniupdate.com/oucampus10/workshop/documents/xsl-fo... · Introduction to XSL-FO OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn

OU Campus Introduction to XSL and XSL Templates Page 2 of 11

Content Content ...................................................... 2  Formatting Objects: An Overview .......... 3  

Transformation .......................................... 3  Formatting ................................................ 3  

Areas ............. Error! Bookmark not defined.  Formatting Object Elements ................... 5  Resources ............................................... 11  

Page 3: Introduction to XSL FOsupport.omniupdate.com/oucampus10/workshop/documents/xsl-fo... · Introduction to XSL-FO OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn

OU Campus Introduction to XSL and XSL Templates Page 3 of 11

Formatting Objects: An Overview As we delve more and more into XSL, we will notice that XSL is basically a two-stage process:

Transformation

Transformation is a simple process of converting or "transforming" the structure and content of a document. The resultant output can then be written on a file or screen

Formatting

Formatting is a process in which the transformed document is used as an input to define the layout of a document. The "objects" in Formatting Objects are the various areas of the printed page and their properties. Since XSL-FO focuses primarily on print/higher resolution media, developers are provided with powerful facilities to achieve high-quality typographical output from an XML document.

Sample XSL FO document:

<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ou="http://omniupdate.com/XSL/Variables">

<xsl:param name="ou:httproot"/>

<xsl:output method="xml" indent="yes" encoding="UTF-8" />

<xsl:template match="document">

<fo:root>

<fo:layout-master-set>

<fo:simple-page-master master-name="A4-portrait"

page-height="11.7in" page-width="8.3in" margin="2cm">

<fo:region-body/>

Page 4: Introduction to XSL FOsupport.omniupdate.com/oucampus10/workshop/documents/xsl-fo... · Introduction to XSL-FO OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn

OU Campus Introduction to XSL and XSL Templates Page 4 of 11

</fo:simple-page-master>

</fo:layout-master-set>

<fo:page-sequence master-reference="A4-portrait">

<fo:flow flow-name="xsl-region-body">

<xsl:apply-templates select="content/node()"/>

</fo:flow>

</fo:page-sequence>

</fo:root>

</xsl:template>

<xsl:template match="p">

<fo:block font-family="Helvetica" font-size="12pt" space-before="12pt" space-after="12pt" text-align="justify" text-indent="3em">

<xsl:apply-templates />

</fo:block>

</xsl:template>

</xsl:stylesheet>

Page 5: Introduction to XSL FOsupport.omniupdate.com/oucampus10/workshop/documents/xsl-fo... · Introduction to XSL-FO OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn

OU Campus Introduction to XSL and XSL Templates Page 5 of 11

Formatting Object Elements Blocks Blocks are the building blocks of a page. A simple fo:block element will produce a standard block area. Blocks are quite flexible elements and they include the following sub elements:

• fo:block • fo:block-container • fo:list • fo:table

Example Block Statement

<fo:block font-size="12pt" text-align="justify">

Hello World!

</fo:block>

Argument – font-size (optional): Defines the font size of the rendered output. Argument – text-align (optional): Defines the text alignment of the rendered output.

Inline Elements Inline elements are used to create standard inline areas. Inline content can be defined as content that, when formatted, does not wrap into a new line. Unlike, standard HTML documents, inline elements are not a pure subset of a block element.

Example Inline Statement

<fo:block font-size="12pt" text-align="justify">

Hello <fo:inline font-weight="bold">World!</fo:inline>

</fo:block>

Argument – font-weight (optional): Defines the font weight of the rendered output.

Fo:root The fo:root is the top node of the formatting object tree and wraps the entire Formatting Object document.

Page 6: Introduction to XSL FOsupport.omniupdate.com/oucampus10/workshop/documents/xsl-fo... · Introduction to XSL-FO OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn

OU Campus Introduction to XSL and XSL Templates Page 6 of 11

Example fo:root element

<fo:root>

</fo:root>

fo:layout-master-set The fo:layout-master-set is a wrapper around all masters used in the document. This element specifies the page layout the formatter will be used in a document.

Example layout-master-set Statement

<fo:layout-master-set>

<fo:simple-page-master master-name="A4-portrait"

page-height="11.7in" page-width="8.3in" margin="2cm">

<fo:region-body/>

</fo:simple-page-master>

</fo:layout-master-set>

fo:simple-page-master The fo:simple-page-master is used to define the page geometry, for example the size, margins etc.

Example simple-page-master Statement

<fo:simple-page-master master-name="A4-portrait" page-height="297mm" page-width="210mm" margin="20mm">

<fo:region-body/>

<fo:region-after/>

</fo:simple-page-master>

Argument – master-name (mandatory): A master-name must be unique across all page-masters and page-sequence-masters.

Argument – page-height (optional): Defines the height of the page. Argument – page-width (optional): Defines the width of the page.

Page 7: Introduction to XSL FOsupport.omniupdate.com/oucampus10/workshop/documents/xsl-fo... · Introduction to XSL-FO OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn

OU Campus Introduction to XSL and XSL Templates Page 7 of 11

Argument – margin (optional): Defines the margin of the page.

fo:region-body fo:region-body specifies a viewport/reference pair that is located in the "center" of the fo:simple-page-master

Example region-body Statement

<fo:simple-page-master master-name="A4-portrait" page-height="297mm" page-width="210mm" margin="20mm">

<fo:region-body margin-top="0.7cm" margin-bottom="0.7cm" column-count="2" column-gap="0.25cm"/>

<fo:region-after/>

</fo:simple-page-master>

Argument – margin-top (optional): Defines the margin of the top of the region.

Argument – margin-bottom (optional): Defines the margin of the bottom of the region.

Argument – column-count (optional): Defines the number of columns in region-body.

Argument – column-gap (optional): Specifies the width of the separation between adjacent columns.

fo:region-before fo:region-before specifies a region that is located on the "before" side of the page-reference-area. This can be considered as the header of the document.

Example region-before Statement

<fo:simple-page-master master-name="A4-portrait" page-height="297mm" page-width="210mm" margin="20mm">

<fo:region-before extent="0.5cm"/>

</fo:simple-page-master>

Argument – extent (optional): Specifies the width of the region-start or region-end or the height of the region-before or region-after.

Page 8: Introduction to XSL FOsupport.omniupdate.com/oucampus10/workshop/documents/xsl-fo... · Introduction to XSL-FO OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn

OU Campus Introduction to XSL and XSL Templates Page 8 of 11

fo:region-after fo:region-after specifies a region that is located on the "after" side of the page-reference-area. This can be considered as the footer of the document.

Example region-after Statement

<fo:simple-page-master master-name="A4-portrait" page-height="297mm" page-width="210mm" margin="20mm">

<fo:region-before extent="0.5cm"/>

</fo:simple-page-master>

Argument – extent (optional): Specifies the width of the region-start or region-end or the height of the region-before or region-after.

fo:region-start fo:region-start specifies a region that is located on the "start" side of the page-reference-area. This region is the starting edge of the document.

Example region-start Statement

<fo:simple-page-master master-name="A4-portrait" page-height="297mm" page-width="210mm" margin="20mm">

<fo:region-start extent="0.5cm"/>

</fo:simple-page-master>

Argument – extent (optional): Specifies the width of the region-start or region-end or the height of the region-before or region-after.

fo:region-end fo:region-end specifies a region that is located on the "end" side of the page-reference-area. This region is the end edge of the document.

Example region-end Statement

<fo:simple-page-master master-name="A4-portrait" page-height="297mm" page-width="210mm" margin="20mm">

<fo:region-end extent="0.5cm"/>

Page 9: Introduction to XSL FOsupport.omniupdate.com/oucampus10/workshop/documents/xsl-fo... · Introduction to XSL-FO OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn

OU Campus Introduction to XSL and XSL Templates Page 9 of 11

</fo:simple-page-master>

Argument – extent (optional): Specifies the width of the region-start or region-end or the height of the region-before or region-after.

fo:page-sequence The fo:page-sequence element is used to specify how to create a sequence of pages within a document. The element contains the content to fill a sequence of pages.

Example page-sequence Statement

<fo:page-sequence master-reference="A4-portrait">

<fo:flow flow-name="xsl-region-body">

<xsl:apply-templates select="content/node()"/>

</fo:flow>

</fo:page-sequence>

Argument – master-reference (mandatory): The names need not be unique, but may not be empty and must refer to a master-name that exists within the document.

fo:flow The fo:flow element is a sequence of flow objects that provides the flowing text content that is distributed into pages. The element contains the content, primarily in the body region.

Example flow Statement

<fo:flow flow-name="xsl-region-body">

<xsl:apply-templates select="content/node()"/>

</fo:flow>

Argument – flow-name (mandatory): The flow-names reserved in XSL are: xsl-region-body, xsl-region-before, xsl-region-after, xsl-region-start, xsl-region-end, xsl-before-float-separator, xsl-footnote-separator.

fo:static-content The fo:static-content element holds a sequence that is to be presented in a single region or repeated in page-sequence. Static-content elements are reusable content, which are typically used in region-before, region-after, region-start and region-end.

Page 10: Introduction to XSL FOsupport.omniupdate.com/oucampus10/workshop/documents/xsl-fo... · Introduction to XSL-FO OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn

OU Campus Introduction to XSL and XSL Templates Page 10 of 11

Example static-content Statement

<fo:static-content flow-name="xsl-region-before">

<fo:block>

Hello World

</fo:block>

</fo:static-content>

Argument – flow-name (mandatory): The flow-names reserved in XSL are: xsl-region-body, xsl-region-before, xsl-region-after, xsl-region-start, xsl-region-end, xsl-before-float-separator, xsl-footnote-separator.

Page 11: Introduction to XSL FOsupport.omniupdate.com/oucampus10/workshop/documents/xsl-fo... · Introduction to XSL-FO OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn

OU Campus Introduction to XSL and XSL Templates Page 11 of 11

Resources W3C XSLT 2.0 Reference: http://www.w3.org/TR/xslt20/

W3C XSLT 3.0 Reference: http://www.w3.org/TR/xslt-30/

W3C XPath Reference: http://www.w3.org/TR/xpath-functions/