XSL Formatting Objects XSLFO - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

XSL Formatting Objects XSLFO

Description:

The Five Regions in a left-to-right, top-to-bottom writing system ... sparkle of different fonts, bold headlines, bulleted lists, and other desirable ... – PowerPoint PPT presentation

Number of Views:75
Avg rating:3.0/5.0
Slides: 25
Provided by: ccNct
Category:

less

Transcript and Presenter's Notes

Title: XSL Formatting Objects XSLFO


1
XSL Formatting Objects(XSL-FO)
2
Overview
  • The names of most XML elements describe the
    semantic meaning of the content they contain
  • The content needs to be formatted and displayed
    to users
  • There must be a step where formatting information
    is applied to the XML document and the semantic
    markup is transformed into presentation markup
  • Cascading Style Sheets (CSS)
  • XSL Formatting Objects (XSL-FO)

3
XSL-FO
  • XSL-FO is a complete XML application for
    describing the precise layout of text on a page.
  • XSL-FO has elements that represent pages, blocks
    of text on the pages, graphics, horizontal rules,
    and more
  • XSLT XSL-FO
  • Most of the time, you write an XSLT stylesheet
    that transforms your document's native markup
    into XSL-FO
  • there is normally a third step in which another
    processor transforms the XSL-FO into a third
    format, such as PDF and TeX
  • Example used 13-1.xml (the same as 12-1.xml)

4
XSL-FO
5
XML Formatting Objects
  • An XSL-FO document describes the layout of a
    series of nested boxes or areas that are placed
    on one or more pages
  • these boxes contain text or occasionally other
    items, such as an external image or a horizontal
    rule
  • Four kinds of boxes
  • Block areas created by particular elements in
    XSL-FO documents
  • Inline areas created by particular elements in
    XSL-FO documents
  • Line areas created by the formatter as
    necessary
  • Glyph areas created by the formatter as
    necessary

6
Content, Padding, Border, and Margin of a Box
It was in Warwick Castle that I came across the
curious stranger whom I am going to talk about.
He attracted me by three things his candid
simplicity, his marvelous familiarity, with
ancient armor, and the restfulness
Content
Padding
Border
Margin
7
Content, Padding, Border, and Margin of a Box
(Cont.)
  • Each box has a content area in which its content
    is placed
  • This content area is surrounded by a padding area
    of blank space
  • An optional border can surround the padding. The
    size of the area is the combined size of the
    border, padding, and content
  • The box may also have a margin that adds blank
    space outside the box's area

8
Content, Padding, Border, and Margin of a Box
(Cont.)
  • Text properties such as font family, font size,
    alignment, and font weight can be applied by
    attaching the appropriate properties to one of
    the boxes that contains the text
  • Text takes on the properties specified on the
    nearest enclosing box
  • Properties are set by attaching attributes to the
    elements that generate the boxes
  • For the most part these properties have the same
    semantics as the CSS properties of the same name
    (only syntax is different)

9
The Structure of an XSL-FODocument
  • The root element of all XSL-FO documents is
    foroot
  • fo prefix must be mapped to http//www.w3.org/1999
    /XSL/Format
  • lt?xml version"1.0" encoding"utf-8"?gt
  • ltforoot xmlnsfo"http//www.w3.org/1999/XSL/Form
    at"gt
  • lt!-- Formatting object elements --gt
  • lt /forootgt

10
folayout-master-set and fopage-sequence
  • The foroot element must contain two things
  • folayout-master-set contains elements
    describing the overall layout the pages
    themselves (size, landscape or portrait, margin
    width)
  • fopage-sequence contains the actual text that
    will be placed on the pages, along with the
    instructions for formatting the text (font
    style)
  • Use a master-reference attribute to identify the
    particular master page that will be used to
    layout the content
  • The formatting engine uses the layout master set
    to create a page. Then it adds content to the
    page from the fopage-sequence until the page is
    full. Then it creates the next page in the
    sequence and places the next batch of content on
    that page. And so on

11
An XSLFO Framework
  • lt?xml version"1.0" encoding"utf-8"?gt
  • ltforoot xmlnsfo"http//www.w3.org/1999/XSL/Form
    at"gt
  • ltfolayout-master-setgt
  • lt!-- page masters --gt
  • lt/folayout-master-setgt
  • ltfopage-sequence master-reference"first"gt
  • lt!-- data to place on the page --gt
  • lt/!--gtlt/fopage-sequencegt
  • lt/forootgt

12
Laying Out the Master Pages
  • XSL-FO 1.0 only defines one kind of master page,
    the fosimple-page-master
  • A standard rectangular page with margins on all
    four sides
  • This master page also has a unique name given by
    a master-name attribute
  • ltfosimple-page-master margin-right"1in"
    margin-left"1in"
  • margin-bottom"1in" margin-top"1in"
    page-width"8.5in"
  • page-height"11in" master-name"first"gt
  • lt!-- Separate parts of the page go here
    --gt
  • lt/fosimple-page-mastergt

13
Laying Out the Master Pages (Cont.)
  • The part of the page inside the margins is
    divided into five regions start, end, before,
    after, body
  • Where the five regions fall depend on the writing
    direction
  • The five regions are represented by
    foregion-start, foregion-end, foregion-before,
    foregion-after, foregion-body child elements of
    the fosimple-page-master element
  • You can place different content into each of the
    five regions
  • The body region and the corresponding
    foregion-body are required
  • By default, the body region takes up the entire
    page
  • Use extent attribute to the four nonbody regions
    to specify the height of the before and after
    regions and the width of the start and end regions

14
Laying Out the Master Pages (Cont.)
  • lt?xml version"1.0" encoding"utf-8"?gt
  • ltforoot xmlnsfo"http//www.w3.org/1999/XSL/Form
    at"gt
  • ltfolayout-master-setgt
  • ltfosimple-page-master margin-right"1in"
    margin-left"1in"
  • margin-bottom"1in" margin-top"1in"
    page-width"8.5in"
  • page-height"11in" master-name"first"gt
  • ltforegion-body /gt
  • lt/fosimple-page-mastergt
  • lt/folayout-master-setgt
  • ltfopage-sequence master-reference"first"gt
  • lt!-- data to place on the page --gt
  • lt/!--gtlt/fopage-sequencegt
  • lt/forootgt

15
The Five Regions in a left-to-right,
top-to-bottom writing system
top-margin
region-before
It was in Warwick Castle that I came across the
curious stranger whom I am going to talk about.
He attracted me by three things his candid
simplicity, his marvelous familiarity, with
ancient armor, and the restfulness
left-margin
right-margin
region-body
region-after
bottom-margin
region-start
region-end
16
Laying Out the Master Pages (Cont.)
  • ltfosimple-page-master margin-right"50pt"
    margin-left"50pt" margin-bottom"50pt"
    margin-top"50pt" page-width"792pt"
    page-height"612pt" master-name"slide"gt
  • ltforegion-before extent"50pt"/gt
  • ltforegion-body margin-bottom"50pt"
    margin-top"75pt"/gt ltforegion-after
    extent"25pt"/gt
  • lt/fosimple-page-mastergt

17
Laying Out the Master Pages (Cont.)
  • ltfosimple-page-master margin-right"0.5in"
    margin-left"0.5in"
  • margin-bottom"0.5in" margin-top"0.5in"
    page-width"8.5in"
  • page-height"11in" master-name"first"gt
  • ltforegion-before extent"0.5in" /gt
  • ltforegion-start extent"0.5in" /gt
  • ltforegion-after extent"0.5in" /gt
  • ltforegion-end extent"0.5in" /gt
  • ltforegion-body margin-top"1.0in"
    margin-bottom"1.0in"
  • margion-left"1.0in" margin-right"1.0in"
    /gt
  • lt/fosimple-page-mastergt

18
Flowing Content into the Pages
  • Add a foflow child to fopage-sequence where the
    actual text of the actual text of the transformed
    document appears
  • flow-name attribute specifying into which region
    of the page its content will flow. Possible
    values include xsl-region-body, xsl-region-start,
    xsl-region-end, xsl-region-before,
    xsl-region-after
  • The formatter instantiates a page based on the
    master page named by the fopage-sequence's
    master-reference attribute, fill one of its
    regions with content from the foflow element
    until the page is full, then second page, third

19
Flowing Content into the Pages (Cont.)
  • The foflow element must contain block-level
    formatting object elements
  • foblock, foblock-container, folist-block,
    fotable, fotable-and-caption
  • A foblock can contain a combination of raw text
    and formatting objects such as foexternal-graphic
    , foinline, fopage-number, fofootnote, and
    even other foblock elements

20
Flowing Content into the Pages (Cont.)
  • ltfoflow flow-name"xsl-region-body"gt
  • ltfoblockgtSouthern Corn Breadlt/foblockgt
  • ltfoblockgt
  • 1 cup
  • flour
  • lt/foblockgt
  • ltfoblockgt
  • 4 tablespoons
  • Royal Baking Powder
  • lt/foblockgt
  • lt/foflowgt

21
Generating the Finished Document
  • XSL-FO formatting program Apache XML Project's
    open source FOP (http//xml.apache.org/fop/)
  • Java Version
  • After you install FOP, run the fop.bat
  • fop cornbread.fo awt
  • fop cornbread.fo pdf cornbread.pdf
  • fop -xml 13-1.xml -xsl 13-2.xsl -awt

22
XSL-FO Properties
  • Adding the sparkle of different fonts, bold
    headlines, bulleted lists, and other desirable
    formatting features requires setting the relevant
    properties on the individual formatting objects
  • Most of the property names and semantics are
    exactly the same as they are for CSS
  • ltfoblock font-weight"bold"gtSouthern Corn
    Breadlt/foblockgt
  • In a few cases CSS properties become XSL-FO
    elements
  • folist-block, folist-item, folist-item-label,
    folist-item-body

23
XSL-FO XSLT
  • 13-1.xml
  • 13-2.xsl

24
Choosing Between CSS and XSL-FO
  • CSS is right for web pages
  • XSL-FO is right for printed matter
  • Multiple column layouts
  • Condition formatting on what's actually in the
    document
  • Place footnotes, running headers, and other
    information in the margins of a page
  • Insert page numbers and automatically
    cross-reference particular pages by number
  • XSLT is a crucial step in getting an input
    document ready for eventual presentation with
    either CSS or XSL-FO
Write a Comment
User Comments (0)
About PowerShow.com