200 likes | 352 Views
Part II. XSL Formatting Objects. This part is simplified in this picture. What’s XSL FO ?. An XML application that describes how pages will look when presented to a reader
E N D
Part II XSL Formatting Objects
This part is simplified in this picture What’s XSL FO ? • An XML application that describes how pages will look when presented to a reader • Interprets the result tree in its formatting object tree form to produce the presentation intended by the designer of the stylesheet Remember the tree graph from Part I ?
Why XSL FO ? • Provides a more sophisticated visual layout model than HTML+CSS • Formatting supported by XSL FO includes right-to-left and top-to-bottom text, footnotes, margin notes, page numbers in cross-references, and more • CSS is primarily intended for use on the Web, while XSL-FO is designed for broader use, ex. lay out an entire printed book
More Trees to Build Formatting Object Tree
More Trees to Build Generate the Area Tree
Formatting • The process of turning the result of an XSL transformation into a tangible form for the reader or listener • Constructing an area tree
XSL Formatting Model • Based on rectangular boxes called areas that can contain text, empty space, images, or other formatting objects • An XSL formatter reads the formatting objects to determine which areas to place where on the page • When processed, the formatting objects document is broken up into pages • Each page contains a number of areas which include: Area Model • Regions • Block areas • Line areas • Inline areas
Area Tree • An ordered tree containing geometric information for the placement of every shape and image in the document • Together with information embodying spacing constraints and other rendering information • This information is referred to under the rubric of traits, which are to areas what formatting properties are to formatting objects and attributes are to XML elements
Formatting Objects • They are elements (nodes) in the formatting object tree, whose names are from the XSL namespace • Belongs to a class of formatting objects identified by its element name
Formatting Objects • what areas are created by a formatting object of that class • how the traits of the areas are established • how the areas are structured hierarchically with respect to areas created by other formatting objects The formatting behavior of each class of formatting objects is described in terms of :
Formatting Properties • When taken as a whole, the various formatting objects in an XSL-FO document specify the order in which content is to be placed on pages • Formatting properties specify the details of formatting such as size, position, font, color and more • Formatting properties are represented as attributes on the individual formatting object elements
XSL FO Document • Follow XML syntax rules • Use .fob or .fo as extensions for files containing XSL formatting objects • .xml extension can also be used A Well-formed XML document, that uses XSL FO vocabulary:
XSL FO document • Start with: • <? Xml version=“1.0” encoding=“utf-8”?> • <fo:root> • Continue with: • The layout master set, which consists of Structure • Descriptions of the kinds of pages that can occur in the document • Sequences in which those page formats can occur • The pages and their content
The Details ? • There are exactly 56 XSL formatting object elements • More than 200 separate XSL formatting properties • We will NOT cover the details about how to use them, consult the XSL specification if interested • The only tools that can render the XSL FO file to an output medium that I know so far is FOP – Formatting Object print formatter • We will show you some example documents and some pdf displays ** see details of FOP at http://www.apache.org/fop
A Simple Document <fo:root xmlns:xlink="http://www.w3.org/2000/xlink/namespace/" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master margin-right="50pt" margin-left="50pt" margin-bottom="50pt" margin-top="50pt" page-width="792pt" page-height="612pt"> <fo:region-body/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence> <fo:flow> <fo:block line-height="80pt" font-size="72pt" font-family="Helvetica"> FOP ain't fopped! </fo:block> </fo:flow> </fo:page-sequence> </fo:root> Formatting Objects Formatting Properties
Output • Use the FOP (FO print formatter ) to transform formatted object tree into a PDF format • View it in Adobe’s Acrobat PDF viewer
Output Examples Direction
More Output Examples Alignment and Images
Tools • FOP http://www.apache.org/fop • More in the future
References • W3C Proposed Recommendation 28 August 2001, http://www.w3.org/TR/xsl • Chapter 17 of “ XML Bible ” by Elliotte Rusty Harold http://www.ibiblio.org/xml/books/bible2/chapters/ch17.html • http://www.xml.com/lpt/a/2001/01/17/xsl-fo/index.html • http://www.sun.com/software/xml/developers/slides-dtd