XSL Formatting Objects - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

XSL Formatting Objects

Description:

fo:block font-family='Times' font-size='12pt' color='green' ... The first is a template for the page format, and contains a fo:simple-page ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 31
Provided by: CS087
Category:

less

Transcript and Presenter's Notes

Title: XSL Formatting Objects


1
XSL Formatting Objects
  • David Cornforth
  • School of ITEE
  • University of NSW _at_ ADFA
  • Based on slides by Bob McKay, and Chapters 4 to 7
    of the W3C XSL Standard, Version 1.0
  • http//www.w3.org/TR/xsl

2
What is/are Formatting Objects?
  • XSL formatting objects is a namespace (fo) and
    document specification for describing page
    formats and contents
  • XSL-FO transforms XML to the FO vocabulary
  • But browsers cant display FO yet
  • To be useful, a translator from the fo namespace
    to a page layout language is also required (PDF,
    RTF, PS or whatever)
  • XSL-FO supports features that cannot be described
    by HTML, such as R-L, top-bottom text etc.
  • Its possible to write an XML doc that can be
    formatted as a printer doc or as a web page

3
XSL Formatting Process
4
Formatting Object Internationalisation
  • XSL formatting objects are carefully designed to
    be culturally neutral
  • The direction of lines can be left to right,
    right to left, or vertical
  • Similarly, the direction of lineation can be
    vertical or horizontal
  • This makes for fairly cumbersome explanation in
    these notes, the Western directions will be
    assumed for simplicity of explanation

5
The XSL Area Model
  • Intended to cover both fixed-area structures
    (printed pages) and flexible area structures
    (scrolling windows)
  • The formatter generates a tree of nested
    rectangular areas, the area tree
  • Each area has
  • An outer region
  • The border rectangle
  • An inner region
  • The content rectangle
  • Optionally an intermediate area
  • The padding rectangle

6
FO areas
  • There are 4 types of area
  • Regions
  • Highest level container
  • Block areas
  • Paragraph, list item uses relative placement
  • Line areas
  • Line of text formatted depending on context
  • Inline areas
  • Single character, reference

7
XSL-FO Example part 1
  • lt?xml version"1.0" ?gt
  • ltxslstylesheet version"1.0" xmlnsxsl"http//ww
    w.w3.org/1999/XSL/Transform"

  • xmlnsfo"http//www.w3.org/1999/XSL/Format"gt
  • ltxsloutput indent"yes" /gt
  • ltxsltemplate match"/"gt
  • ltforoot xmlnsfo"http//www.w3.org/1999/XSL/
    Format"gt
  • ltfolayout-master-setgt
  • ltfosimple-page-master master-name"A4"gt
  • ltforegion-body /gt
  • lt/fosimple-page-mastergt
  • lt/folayout-master-setgt
  • ltfopage-sequence master-reference"A4"gt
  • ltfoflow flow-name"xsl-region-body"gt
  • ltxslapply-templates select"//CD" /gt
  • lt/foflowgt
  • lt/fopage-sequencegt
  • lt/forootgt
  • lt/xsltemplategt

8
XSL-FO example part 2
  • ltxsltemplate match"CD"gt
  • ltfoblock font-family"Times"
    font-size"18pt" color"red" font-weight"bold"gt
  • Title ltxslvalue-of select"TITLE" /gt
  • lt/foblockgt
  • ltfoblock font-family"Times"
    font-size"12pt" color"green"gt
  • Artist ltxslvalue-of select"ARTIST" /gt
  • lt/foblockgt
  • ltfoblock font-family"Times"
    font-size"12pt" color"green"gt
  • Contents
  • lt/foblockgt
  • ltxslfor-each select"//TRACK"gt
  • ltfoblock font-family"Times"
    font-size"12pt" color"black"gt
  • ltxslvalue-of select"text()" /gt
  • lt/foblockgt
  • lt/xslfor-eachgt
  • lt/xsltemplategt
  • lt/xslstylesheetgt

9
XSL-FO example result
10
Page layout
  • The root element is foroot, and contains
  • one folayout-master-set
  • one or more fopage-sequence
  • The first is a template for the page format, and
    contains a fosimple-page-master, which defines
    margins Attributes
  • master-name
  • page-height, page-width
  • margin-bottom, margin-left, margin-right,
    margin-top
  • writing-mode (e.g. left to right)
  • reference-orientation

11
folayout-master-set
  • Inside the fosimple-page-master element, you
    define extra elements for the regions that will
    appear on your page
  • ltforegion-body
  • ltforegion-before
  • ltforegion-after
  • ltforegion-start
  • ltforegion-end
  • You must include ltforegion-body or nothing will
    be displayed!
  • You can have more than one master page, for
    example, right and left handed pages

12
fopage-sequence
  • There are one or more fopage-sequence elements
  • Each page has an associated page master, named
    using the master-reference attribute
  • Each page-sequence element contains three types
    of child element
  • fotitle does not appear on output
  • fostatic-content text to appear on every page
  • foflow data to appear sequentially
  • Last 2 must have a flow-name attribute that
    matches one on the layout-master-set

13
Specifying page size
  • ltfolayout-master-setgt
  • ltfosimple-page-master master-name"A4"
  • page-height"29.7cm" page-width"21cm"
  • margin-top"2cm" margin-bottom"2cm"
  • margin-left"2cm" margin-right"2cm"gt
  • ltforegion-body /gt
  • lt/fosimple-page-mastergt
  • lt/folayout-master-setgt

14
XSL-FO example result
15
foflow (Harold p.523)
  • Main content, can be
  • foblock
  • foblock-container
  • fotable-and-caption
  • fotable
  • folist-block
  • It is common for the foflow element to contain
    only ltxslapply-templates//ROOT /gt or similar.

16
Static content
  • For things that should appear on every page
    (header, footer)
  • ltforegion-body margin-top"1cm" /gt
  • ltforegion-after extent"1cm" /gt
  • ltfostatic-content flow-name"xsl-region-after"gt
  • ltfoblockgt
  • Author David Cornforth, page
  • ltfopage-number /gt
  • lt/foblockgt
  • lt/fostatic-contentgt

17
Table formatting (p.535, 551)
  • ltfotable table-layout"fixed"gt
  • ltfotable-column column-width"10cm" /gt
  • ltfotable-column column-width"6.5cm" /gt
  • ltfotable-bodygt
  • ltfotable-rowgt
  • ltfotable-cellgt
  • ltfoblock font-size"10pt"
    text-align"justify"gt
  • ltxslvalue-of select"description"
    /gt
  • lt/foblockgt
  • lt/fotable-cellgt
  • ltfotable-cellgt
  • ltxslcall-template name"info" /gt
  • lt/fotable-cellgt
  • lt/fotable-rowgt
  • lt/fotable-bodygt
  • lt/fotablegt

18
Non-XMLGraphics (p.539)
  • ltfoexternal-graphic src"MilesDavis.jpg" /gt

19
  • XML graphic objects use (p.541)
  • ltfoinstream-foreign-objectgt
  • ltsvg xmlnshttp//www.w3.org/2000/svg
  • width30mm height20mmgt
  • ltpolygon stylefillFFCCCC
    points0,62 36,0 72,62 /gt
  • lt/svggt
  • lt/foinstream-foreign-objectgt

20
Lists (Harold p. 547)
  • ltfolist-blockgt contains either ltfolist-itemgt
    elements or
  • ltfolist-item-labelgt plus ltfolist-item-bodygt
  • Example
  • ltfolist-blockgt
  • ltxslfor-each select"//TRACK"gt
  • ltfolist-itemgt
  • ltfolist-item-labelgt
  • ltfoblock font-family"Times"
    font-size"10pt"gt
  • ltxslvalue-of select"position()"
    /gt
  • lt/foblockgt
  • lt/folist-item-labelgt
  • ltfolist-item-bodygt
  • ltfoblock text-indent"1cm"
    font-family"Times" font-size"10pt"gt
  • ltxslvalue-of select"text()" /gt
  • lt/foblockgt
  • lt/folist-item-bodygt
  • lt/folist-itemgt
  • lt/xslfor-eachgt
  • lt/folist-blockgt

21
Inlines (Harold p.556)
  • What happens if you want to change text
    properties but not start a new block?
  • Use ltfoinline
  • ltfoblockgt
  • Try XSL stylesheets sometime theyre
  • ltfoinline font-styleitalicgtreallylt/foinline
    gtcool.
  • lt/foblockgt

22
Formatting paragraph break
  • Break properties
  • Keep-with-next
  • Keep-with-previous
  • Keep-together
  • Break-before
  • Break-after
  • Example
  • ltfoblock keep-with-nextalwaysgt
  • some content
  • lt/foblockgt

23
Formatting properties indent
  • Four attributes
  • start-indent
  • end-indent
  • text-indent (only the first line)
  • last-line-end-indent
  • Example
  • ltfoblock start-indent"1cm"gt
  • ltfoblock text-indent-1cm start-indent"1cm"gt

24
Character properties
  • ltfoblock color"blue"gt
  • ltfoblock font-family"Times"gt
  • ltfoblock font-size"18pt"gt
  • ltfoblock font-stretchcondensedgt expanded
  • ltfoblock font-styleitalicgt
  • ltfoblock font-variantsmall-capsgt
  • ltfoblock font-weight"bold"gt 200
    lighter

25
Text properties
  • ltfoblock text-transformcapitalizegt
    uppercase
  • ltfoblock text-shadowFFFF66gt
  • ltfoblock text-decorationunderlinegt
  • ltfoblock letter-spacing2pxgt
  • ltfoblock word-spacing0.5cmgt
  • ltfoblock line-height24ptgt
  • ltfoblock text-aligncentergt justify
  • ltfoblock text-align-lastcentergt

26
Area properties
  • ltfoblock background-colortransparentgt
  • ltfoblock background-imageSimpsons.jpggt
  • ltfoblock border-colorredgt
  • ltfoblock border-width0.1mmgt
  • ltfoblock border-stylesolidgt
  • ltfoblock padding-before1cmgt
  • ltfoblock padding1cmgt
  • ltfoblock margin-top5mmgt
  • ltfoblock margin5mmgt

27
More area properties
  • ltfoblock space-before5mmgt
  • ltfoblock start-indent5mmgt
  • ltfoblock height3cmgt
  • ltfoblock overflowhiddengt
  • ltfoblock reference-orientation90gt

28
Summary
  • Most XCL formatting objects generate rectangular
    areas
  • Pages contain regions
  • Regions contain blocks
  • Blocks contain blocks and lines
  • Lines contain inlines
  • Inlines contain inlines and character areas.

29
More summary
  • The root element is foroot and contains
  • folayout-master-set
  • fopage-sequence
  • The folayout-master-set contains
  • fosimple-page-master elements that define the
    layout on a type of page, divided into before,
    after, start, end, body
  • The fopage-sequence contains
  • fotitle
  • fostatic-content
  • foflow

30
Questions?
Write a Comment
User Comments (0)
About PowerShow.com