XSLFO : Extensible Stylesheet Language Formatting Objects - PowerPoint PPT Presentation

1 / 40
About This Presentation
Title:

XSLFO : Extensible Stylesheet Language Formatting Objects

Description:

XSL-FO is an XML-based markup language describing the formatting of XML data for ... batik.jar;d:fop-0.20.5libxalan-2.3.1.jar;d:fop-0.20.5libxercesImpl-2. 0.1. ... – PowerPoint PPT presentation

Number of Views:449
Avg rating:3.0/5.0
Slides: 41
Provided by: wan145
Category:

less

Transcript and Presenter's Notes

Title: XSLFO : Extensible Stylesheet Language Formatting Objects


1
XSL-FO Extensible Stylesheet Language
Formatting Objects
  • XSL-FO is an XML-based markup language describing
    the formatting of XML data for output to screen,
    paper or other media.
  • XSL-FO became a W3C Recommendation 15. October
    2001

2
XSL-FO
  • Information about the physical size of the page
    (letter, A4, and so on)
  • Information about margins (top, left, bottom, and
    right), running headers and footers, and other
    properties of the page
  • Information about fonts, font sizes, colors, and
    other characteristics of the text
  • The actual text to be printed, marked up with
    elements that describe paragraphs, highlighting,
    tables, and similar things

3
Converting XML documents to PDF files
  • Use an XSLT stylesheet to transform the XML
    document into a file of XSL-FO elements. To
    perform the transformation, you simply invoke the
    XSLT processor with the XML document and the
    stylesheet. (Part 2 of this tutorial includes an
    XSLT stylesheet that converts XHTML elements into
    formatting objects.)
  • Use a rendering engine (for example, FOP, which
    is used in the tutorial examples) to convert the
    XSL-FO elements into a PDF file. This part is
    even simpler You just invoke the FOP tool,
    giving it the name of the XSL-FO file and the
    name of the PDF file.

4

5


6
Run FOP
  • set classpath.d\fop-0.20.5\build\fop.jard\fop
    -0.20.5\lib\avalon-framework-cvs-20020806.jard\f
    op-0.20.5\lib\batik.jard\fop-0.20.5\lib\xalan-2.
    3.1.jard\fop-0.20.5\lib\xercesImpl-2.0.1.jard\
    fop-0.20.5\lib\xml-apis.jar
  • java org.apache.fop.apps.Fop d\example\simple.fo
    d\example\simple.pdf

7
The ltforootgt element
  • The root element for an XSL-FO document is the
    ltforootgt element. The sample document defines
    the fo namespace prefix in this element
  • ltforoot xmlnsfo"http//www.w3.org/1999/XSL/Form
    at"gt
  • ... lt!-- Everything else in the document
    --gt ... lt/forootgt
  • Typically, the root element contains a
    ltfolayout-master-setgt followed by one or more
    ltfopage-sequencegts.

8
The ltfolayout-master-setgt element
  • The ltfolayout-master-setgt element specifies page
    definitions
  • In a simple document, one layout might be enough,
    but complex documents typically have several page
    definitions
  • ltfosimple-page-mastergt element to define each of
    the page layouts you need then you store them in
    the ltfolayout-master-setgt element.

9
  • ltfolayout-master-setgt
  • ltfosimple-page-master master-
  • name"main" margin-top"36pt"
  • margin-bottom"36pt" page-
  • width"8.5in" page-height"11in"
    margin-
  • left"72pt" margin-right"72pt"gt
  • ltforegion-body margin-bottom"50pt"
    margin-top"50pt"/gt
  • lt/folayout-master-setgt

10
The ltfosimple-page-mastergt element
  • The ltfosimple-page-mastergt element defines the
    layout for a particular page
  • master-name Defines a name for this page master.
    You can create several different
    ltfosimple-page-mastergt elements and then refer
    to each of them as you need to use different page
    layouts throughout your document
  • page-width and page-height Define the size of the
    physical page. This example defines a
    letter-sized page to use A4-sized paper, the
    attributes page-width"21cm" and
    page-height"29.7cm" would do the trick.

11
Units in XSL-FO documents
  • cm centimeters
  • mm millimeters
  • in inches
  • pt points (72 points 1 inch)
  • pc picas (12 points 1 pica, 6 picas 1 inch)
  • px pixels (sometimes different from one formatter
    or device to the next, so be careful)
  • em the width of a capital M

12
  • XSL-FO Pages contain Regions
  • XSL-FO Regions contain Block areas
  • XSL-FO Block areas can contain other Block areas,
    but most often they contain Line areas
  • XSL-FO Line areas contain Inline areas
  • XSL-FO Inline areas define text inside Lines
    (bullets, single character, graphics, and more).

13
The ltforegion-bodygt element
  • The XSL-FO spec defines five regions on a page
    region-body defines the dimensions of the main
    area in the center of the page
  • region-before, the area at the top of the page
    (normally used for running heads)
  • region-after, the area at the bottom of the page
    (normally used for running feet)
  • region-start, the area to the left of the page
  • region-end, the area to the right of the page

14

15
Attributes of region-X
  • region-name name of the region
  • extent assignment value
  • Margin-bottom, margin-left, margin-right,
    margin-top

16
ltfopage-sequencegt element
  • One or more ltfopage-sequencegt elements describe
    the page contents. The master-reference attribute
    refers to the simple-page-master template with
    the same name
  • ltfopage-sequence master-reference"A4"gt
  • lt!-- Page content goes here --gt
    lt/fopage-sequencegt

17
  • Fotitle (optional)
  • ltfotitlegtmyxmllt/fotitlegt
  • Similar to html title tag
  • Fostatic-content( 0 or more)
  • always appear at region-before or
    region-after.
  • followed by ltfoblockgt
  • Foflow (only one)

18
The ltfoflowgt element
  • The ltfoflowgt element defines some content that
    will be flowed within the current margins, font
    settings, and so forth
  • ltfoflow flow-namebodygt
  • Followed by the ltfoblockgt

19
Block Area Attributes
  • ltfoblockgt is the most basic element used to
    format a block of text.
  • You can think of it as similar to the HTML ltpgt
    element.
  • A ltfoblockgt element always causes a line break.
  • ltfoblock font-size"14pt" line-height"17pt"gt
  • ltfoblock text-align"center"gt

20
  • space-before
  • space-before.minimum
  • space-before.maximum
  • space-before.optimum
  • space-before.precedence
  • space-afterspace-after.minimum
  • space-after.maximum
  • space-after.optimum
  • space-after.precedence
  • Ex. ltfoblock space-before"14pt"gt Put 14
    points of vertical space before the block begins

21
  • Border style attributes
  • border-style
  • border-before-style
  • border-after-style
  • border-start-style
  • border-end-style
  • border-top-style (same as border-before)
  • border-bottom-style (same as border-after)
  • border-left-style (same as border-start)
  • border-right-style (same as border-end)

22
  • Border color attributes
  • border-color
  • border-before-color
  • border-after-color
  • border-start-color
  • border-end-color
  • border-top-color (same as border-before)
  • border-bottom-color (same as border-after)
  • border-left-color (same as border-start)
  • border-right-color (same as border-end)

23
  • Border width attributes
  • border-width
  • border-before-width
  • border-after-width
  • border-start-width
  • border-end-width
  • border-top-width (same as border-before)
  • border-bottom-width (same as border-after)
  • border-left-width (same as border-start)
  • border-right-width (same as border-end)

24
  • Font attributes
  • font-family
  • font-weight
  • font-style
  • font-size
  • font-variant

25
  • Text attributes
  • text-align
  • text-align-last
  • text-indent
  • start-indent
  • end-indent
  • wrap-option (defines word wrap)
  • break-before (defines page breaks)
  • break-after (defines page breaks)
  • reference-orientation (defines text rotation in
    90" increments)

26
  • keep-with-next
  • keep-with-next.within-line
  • keep-with-next.within-column
  • keep-with-next.within-page
  • keep-with-previous
  • keep-with-previous.within-line
  • keep-with-previous.within-column
  • keep-with-previous.within-page
  • keep-together
  • keep-together.within-line
  • keep-together.within-column
  • keep-together.within-page
  • Ex ltfoblock font-size"24pt" keep-with-next.with
    in-page"always"gt
  • Always keep this block on the same page as
    the block that follows it

27
ltfoinlinegt element
  • ltfoinlinegt defines some new text properties
    within an existing ltfoblockgt
  • Bold text Use the ltfoinlinegt element with an
    attribute of font-weight"bold".
  • Italicized text Use the ltfoinlinegt element with
    an attribute of font-style"italic".
  • Monospaced text Use the ltfoinlinegt element with
    an attribute of font-family"monospace".
  • Changing fonts Use the ltfoinlinegt element with
    an attribute of font-family"serif"

28
  • ltfoflow flow-name"xsl-region-body"gt
  • ltfoblock font-size"14pt"
    line-height"17pt"gt
  • This is a paragraph of text. Notice that
    as
  • ltfoinline font-style"italic"gtthis
    meaningless
  • proselt/foinlinegt drones on and on, the
    FOP
  • software automatically calculates line
    breaks for us.
  • Isn't that fascinating?
  • lt/foblockgt
  • lt/foflowgt

29
Fopage-number
  • Initial-page-number
  • Force-page-count odd, even, end-on-even,
    end-on-odd or auto
  • Pageltfopage-number/gt

30
ltfoexternal-graphicgt element
  • ltfoexternal-graphic src"images/x.gif"gt
  • The ltfoexternal-graphicgt element doesn't cause a
    line break by default. If you want the graphic to
    appear separately, put the ltfoexternal-graphicgt
    inside a ltfoblockgt.

31
Drawing lines
  • The XSL-FO spec also defines a ltfoleadergt
    element to draw lines in a document
  • The valid values for the leader-pattern property
    are space, rule, and dots. The default value is
    space, meaning the ltfoleadergt element merely
    creates blank white space

32
  • ltfoblockgt
  • ltfoleader leader-pattern"dots"/gt
  • lt/foblockgt

33
XSL-FO Tables
  • The XSL-FO table model is not very different from
    the HTML table model
  • There are nine XSL-FO objects used to create
    tables
  • fotable-and-caption
  • fotable lttablegt
  • fotable-caption
  • fotable-column ltcolgt
  • fotable-header lttheadgt
  • fotable-footer
  • fotable-body lttbodygt
  • fotable-row lttrgt
  • fotable-cell lttdgt

34
Fobasic-link
  • ltfobasic-link
  • external-destinationhttp//www.ncue.edu.t
    wgtncue
  • lt/fobasic-linkgt

35
Multiple pages
  • Using fosimple-page-master to build the name of
    every page
  • Then using fopage-sequence-master to decide the
    order of appearance
  • The ltfopage-sequence-mastergt object specifies
    which simple-page-masters are to be used and in
    which order

36
  • ltfopage-sequence-mastergt
  • lt!-- Contents(single-page-master-ref
    erence repeatable-page-master-reference
    repeatable-page-master-alternatives) --gt
  • lt/fopage-sequence-mastergt

37
  • The ltfosingle-page-master-referencegt object
    holds a reference to a particular page-master to
    be used at a given point in the sequence of
    pages.
  • Attribute master-reference

38
  • The ltforepeatable-page-master-referencegt object
    specifies repetition of a single
    simple-page-master.
  • Attribute master-reference maximum-repeats

39
  • The ltforepeatable-page-master-alternativesgt
    object specifies repetition of a set of
    simple-page-masters.
  • Attribute maximum-repeats

40
  • The ltfoconditional-page-master-referencegt object
    specifies a page-master to be used when the
    conditions defined are true.
  • Three properties, page-position, odd-or-even,
    blank-or-not-blank, specifies the conditions. All
    three conditions must be true for the
    ltfoconditional-page-master-referencegt to be
    true.
  • page-position is true if the generated page has
    the specified position (first, last, rest, any)
  • odd-or-even is true if the value is "any" or if
    the value (odd, even) matches the page number
  • blank-or-not-blank is true, if the value is
    "not-blank" and the page has areas generated by
    descendants of ltfoflowgt if the value is "blank"
    and the page has no areas from ltfoflowgt or if
    the value is "any"
Write a Comment
User Comments (0)
About PowerShow.com