XSL Formatting Objects

Here's an overview of the 56 formatting objects that exist as of this writing—we'll see a good number of them in action in this chapter.

ObjectDescription
bidi-overrideOverrides the default Unicode-bidirectionality algorithm direction in mixed-language documents.
blockCreates a display block, often used for formatting paragraphs, titles, headlines, figure and table captions, and so on.
block-containerGenerates a block-level reference area.
characterRepresents a character that is associated with a glyph for display.
color-profileDeclares a color profile for a style sheet.
conditional-page-master-referenceSpecifies a page master to be used when the given conditions are met.
declarationsGroups global declarations for a style sheet.
external-graphicAdds an inline graphic to the document, where the graphics data is outside the XML result document.
floatCan specify that some content is formatted in a separate area at the beginning of the page or placed to one side.
flowSupports the flowing text content that is displayed in pages.
footnoteCreates a footnote citation and the associated footnote.
footnote-bodyCreates the content of the footnote.
initial-property-setSets the formatting properties for the first line of a block.
inlineUsually is used to format part of the text with a background or to give it a border.
inline-containerCreates an inline reference area.
instream-foreign-objectIs used to insert an inline graphic or other object where the object data is a descendant of the fo:instream-foreign-object.
layout-master-setIs a wrapper for all the masters used in the document.
leaderCreates a rule or row of repeating characters or a repeating pattern of characters that is used between two text-formatting objects.
list-blockIs used to format a list.
list-itemHolds the label and the body of an item in a list.
list-item-bodyHolds the content of the body of a list item.
list-item-labelHolds the content of the label of a list item.
markerIs used with fo:retrieve-marker to create on-the-fly headers or footers.
multi-caseAdds flow objects that the parent object, fo:multi-switch, can be used to show or hide.
multi-propertiesSwitches between two or more property sets that are connected to a given part of the content.
multi-property-setIndicates an alternative set of formatting properties that can be applied to the content.
multi-switchSwitches between two or more subtrees of formatting objects.
multi-toggleIs used inside an fo:multi-case object to switch to another fo:multi-case.
page-numberHolds the current page number.
page-number-citationReferences the page number for the page containing the cited formatting object.
page-sequenceSpecifies how to create a sequence of pages within a document.
page-sequence-masterContains sequences of page masters that are used to generate sequences of pages.
region-afterRefers to the region located after a fo:region-body region.
region-beforeRefers to the region before a fo:region-body region.
region-bodyRefers to the region in the center of the fo:simple-page-master.
region-endRefers to the region at the end of a fo:region-body region.
region-startRefers to the region starting a fo:region-body region.
repeatable-page-master-alternativesIndicates a subsequence made up of repeated instances of a set of alternative page masters.
repeatable-page-master-referenceIndicates a subsequence of repeated instances of a single page master.
retrieve-markerIs used with fo:marker to create on-the-fly headers or footers.
rootIs the top node of an XSL formatted document.
simple-linkRepresents the start location in a simple link.
simple-page-masterGives the geometry of a page, which may be divided into up to five regions.
single-page-master-referenceIndicates a subsequence made up of a single instance of a single page master.
static-contentContains a sequence of formatting objects that should be presented in a single region or repeated in like-named regions on one or more pages in the page-sequence. This most often is used for repeating headers and footers.
tableFormats the data in a table.
table-and-captionFormats the data and caption of a table.
table-bodyHolds the content of the table body.
table-captionHolds block-level formatting objects that, in turn, hold the caption for a table.
table-cellGroups content to be placed in a table cell.
table-columnSets characteristics for table cells that have the same column.
table-footerHolds the content of the table footer.
table-headerHolds the content of the table header.
table-rowGroups table cells into rows.
titleGives a document a title. The content of the fo:title object can be formatted and displayed in the document.
wrapperIndicates inherited properties for a group of formatting objects.

XSL Formatting Properties

The formatting objects in the previous section have properties that you can use to customize what they do. As we'll see in this chapter, a typical formatting object can support quite a few properties. Here are the current formatting properties that the W3C formatting objects specification supports— many of these properties are taken from and behave the same as in CSS, and you set lengths and other units exactly as you do in CSS (using units such as px for pixels, pt for points, mm for millimeters, % for percentages, and so on)—you can find more details at http://www.w3.org/TR/xsl/sliceC.html#prtab1 and http://www.w3.org/TR/xsl/sliceC.html#prtab2:

  • absolute-position

  • active-state

  • alignment-adjust

  • auto-restore

  • azimuth

  • background

  • background-attachment

  • background-color

  • background-image

  • background-position

  • background-position-horizontal

  • background-position-vertical

  • background-repeat

  • baseline-identifier

  • baseline-shift

  • blank-or-not-blank

  • block-progression-dimension

  • border

  • border-after-color

  • border-after-style

  • border-after-width

  • border-before-color

  • border-before-style

  • border-before-width

  • border-bottom

  • border-bottom-color

  • border-bottom-style

  • border-bottom-width

  • border-collapse

  • border-color

  • border-end-color

  • border-end-style

  • border-end-width

  • border-left

  • border-left-color

  • border-left-style

  • border-left-width

  • border-right

  • border-right-color

  • border-right-style

  • border-right-width

  • border-separation

  • border-spacing

  • border-start-color

  • border-start-style

  • border-start-width

  • border-style

  • border-top

  • border-top-color

  • border-top-style

  • border-top-width

  • border-width

  • bottom

  • break-after

  • break-before

  • caption-side

  • case-name

  • case-title

  • character

  • clear

  • clip

  • color

  • color-profile-name

  • column-count

  • column-gap

  • column-number

  • column-width

  • content-height

  • content-type

  • content-width

  • country

  • cue

  • cue-after

  • cue-before

  • destination-placement-offset

  • direction

  • display-align

  • dominant-baseline

  • elevation

  • empty-cells

  • end-indent

  • ends-row

  • extent

  • external-destination

  • float

  • flow-name

  • font

  • font-family

  • font-height-override-after

  • font-height-override-before

  • font-size

  • font-size-adjust

  • font-stretch

  • font-style

  • font-variant

  • font-weight

  • force-page-count

  • format

  • glyph-orientation-horizontal

  • glyph-orientation-vertical

  • grouping-separator

  • grouping-size

  • height

  • hyphenate

  • hyphenation-character

  • hyphenation-keep

  • hyphenation-ladder-count

  • hyphenation-push-character-count

  • hyphenation-remain-character-count

  • id

  • indicate-destination

  • initial-page-number

  • inline-progression-dimension

  • internal-destination

  • keep-together

  • keep-with-next

  • keep-with-previous

  • language

  • last-line-end-indent

  • leader-alignment

  • leader-length

  • leader-pattern

  • leader-pattern-width

  • left

  • letter-spacing

  • letter-value

  • linefeed-treatment

  • line-height

  • line-height-shift-adjustment

  • line-stacking-strategy

  • margin

  • margin-bottom

  • margin-left

  • margin-right

  • margin-top

  • marker-class-name

  • master-name

  • max-height

  • maximum-repeats

  • max-width

  • min-height

  • min-width

  • number-columns-repeated

  • number-columns-spanned

  • number-rows-spanned

  • odd-or-even

  • orphans

  • overflow

  • padding

  • padding-after

  • padding-before

  • padding-bottom

  • padding-end

  • padding-left

  • padding-right

  • padding-start

  • padding-top

  • page-break-after

  • page-break-before

  • page-break-inside

  • page-height

  • page-position

  • page-width

  • pause

  • pause-after

  • pause-before

  • pitch

  • pitch-range

  • play-during

  • position

  • precedence

  • provisional-distance-between-starts

  • provisional-label-separation

  • reference-orientation

  • ref-id

  • region-name

  • relative-align

  • relative-position

  • rendering-intent

  • retrieve-boundary

  • retrieve-class-name

  • retrieve-position

  • richness

  • right

  • role

  • rule-style

  • rule-thickness

  • scaling

  • scaling-method

  • score-spaces

  • script

  • show-destination

  • size

  • source-document

  • space-after

  • space-before

  • space-end

  • space-start

  • space-treatment

  • span

  • speak

  • speak-header

  • speak-numeral

  • speak-punctuation

  • speech-rate

  • src

  • start-indent

  • starting-state

  • starts-row

  • stress

  • suppress-at-line-break

  • switch-to

  • table-layout

  • table-omit-footer-at-break

  • table-omit-header-at-break

  • text-align

  • text-align-last

  • text-decoration

  • text-indent

  • text-shadow

  • text-transform

  • top

  • treat-as-word-space

  • unicode-bidi

  • vertical-align

  • visibility

  • voice-family

  • volume

  • white-space

  • white-space-collapse

  • widows

  • width

  • word-spacing

  • wrap-option

  • writing-mode

  • xml:lang

  • z-index

Working with Formatting Objects

This chapter is all about working with the XSL formatting objects, and I'll cover those objects in depth. Knowing how to use these objects is crucial to the whole formatting process because, even if you use a transformation style sheet to transform XML documents to formatting-object form, you still have to know how to create the style sheet to do so. By the end of this chapter, you'll have a solid idea of exactly how that works.

The first formatting object I'll cover is fo:root, the root object of any formatting object document.

The Document Root: fo:root

The fo:root object is the top node of the formatting object tree that makes up a formatting object document—that is, the document node of the formatting object document must be fo:root.

The children of the fo:root formatting object are a single fo:layout-master-set and a sequence of one or more fo:page-sequences. The fo:layout-master-set formatting object holds all "masters" used in the document, which you use to specify how each page will actually be built. Each fo:page-sequence represents a sequence of pages formatted the way you want them. For example, each chapter of a book could be made up of its own page sequence, and you can give each sequence the same header and footer, such as Chapter 2: The Plot Thickens.

In planets.xml, the document node is <PLANETS>; however, the document node of a formatting object document is <fo:root>, which means that we must replace <PLANETS> with <fo:root>. That looks like this in planets.xsl, the transformation style sheet:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    version='1.0'>

    <xsl:template match="PLANETS">
        <fo:root>
        .
        .
        .

The fo:root object can contain both master set layouts and page sequences. I'll take a look at the fo:layout-master-set object first.

The Master Set Layout: fo:layout-master-set

You use masters to create templates for pages, page sequences, and regions. The fo:layout-master-set object contain all the masters used in the document, including page sequence master objects, page master objects, and region master objects, which you apply to create page sequences, pages, and regions.

The name of each master ends in -master in XSL. For example, the page master that we'll use is the simple-page-master object. Page masters specify the subdivisions of a page and the geometry of these subdivisions. Page sequence masters specify the sequence of page masters that will be used to generate pages during the formatting.

You list the masters you want to use in the document in the <fo:layout-master-set> element, so I'll add that element to planets.xsl now:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    version='1.0'>

    <xsl:template match="PLANETS">
        <fo:root>

            <fo:layout-master-set>
    .
    .
    .

To configure each page, you use a page master; the one I'll use here is the fo:simple-page-master object.

Using a Page Master: fo:simple-page-master

A page master is a master template that is used to generate a page, and it specifies the actual layout of the page. You can use a page master whenever you want to in a document, and each page master has a unique name.

In the current XSL specification, there is only one kind of page-master, the fo:simple-page-master object (in the future, the XSL specification may support additional page masters). You use the fo:simple-page-master object to generate pages and define the geometry of the page.

To set the overall geometry of the page, you can use these properties of the fo:simple-page-master object:

  • Common margin properties for blocks: margin-top, margin-bottom, margin-left, margin-right, space-before, space-after, start-indent, end-indent

  • master-name

  • page-height

  • page-width

  • reference-orientation

  • writing-mode

In planets.xsl, I'll name the simple page master "page" using the master-name property; when I want to create pages using this master, I'll be able to refer to it by name. I'll also specify the page dimensions and margins like this:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    version='1.0'>

    <xsl:template match="PLANETS">
        <fo:root>

            <fo:layout-master-set>
                 <fo:simple-page-master master-name="page"
                     page-height="400mm" page-width="300mm"
                     margin-top="10mm" margin-bottom="10mm"
                     margin-left="20mm" margin-right="20mm">
    .
    .
    .

Besides laying out the margins of a page, an fo:simple-page-master has children that specify one or more regions in the page, enabling you to customize the layout in detail.

Creating Regions

In version 1.0 of the XSL recommendation, page masters have up to five regions. The central region, which corresponds to the body of the page, is called the body region. The top part of the page, the header, is called the before region, the bottom part of the page, the footer, is called the after region. In languages that read left to right, such as English, the left side of the page is called the start region, and the right side is called the end region. In languages that read right to left, the start and end regions are reversed. You can think of start and end regions as sidebars that flank the body region.

Five XSL formatting objects correspond to these regions:

  • fo:region-before

  • fo:region-after

  • fo:region-body

  • fo:region-start

  • fo:region-end

You can use these properties with these formatting objects:

  • Common border, padding, and background properties: background-attachment, background-color, background-image, background-repeat, background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border- bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • Common margin properties for blocks: margin-top, margin-bottom, margin-left, margin-right, space-before, space-after, start-indent, end-indent

  • clip

  • column-count

  • column-gap

  • display-align

  • extent

  • overflow

  • region-name

  • reference-orientation

  • writing-mode

You can customize the regions of a page as you like, as in planets.xsl, where I'm setting margins for the body region. The four outer regions (but not the body region) have an extent property that sets the size of those regions, and I'll use that here:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    version='1.0'>

    <xsl:template match="PLANETS">
        <fo:root>

            <fo:layout-master-set>
                 <fo:simple-page-master master-name="page"
                     page-height="400mm" page-width="300mm"
                     margin-top="10mm" margin-bottom="10mm"
                     margin-left="20mm" margin-right="20mm">

                     <fo:region-body
                       margin-top="0mm" margin-bottom="10mm"
                       margin-left="0mm" margin-right="0mm"/>

                     <fo:region-after extent="10mm"/>
                 </fo:simple-page-master>
             </fo:layout-master-set>
    .
    .
    .

That ends the only master I'll have in this document, the simple page master named "page", so that completes the fo:layout-master-set object.

As mentioned, besides the fo:layout-master-set, a formatting object document usually also contains one or more fo:page-sequence objects that define page sequences using the masters you define in the fo:layout-master-set.

Creating Page Sequences: fo:page-sequence

The pages in the output document are actually created when the XSL processor processes fo:page-sequence objects. A page sequence consists of a run of pages that share the same characteristics, such as a chapter in a book.

Each fo:page-sequence object references either an fo:page-sequence-master or a page master, and the actual layout of the pages is specified by those masters. You can get fairly involved here, creating sequences in which the page numbering alternates from side to side on the page, as when you're creating pages for a book.

These properties apply to the fo:page-sequence object:

  • country

  • format

  • language

  • letter-value

  • grouping-separator

  • grouping-size

  • id

  • initial-page-number

  • force-page-count

  • master-name

In the current W3C XSL recommendation, you specify what page master you want to use for a page sequence with the <fo:page-sequence> element's master-name attribute. I named the simple page master we created "page", so I'll set that attribute to that name here. However, FOP is based on an earlier version of XSL and requires an <fo:sequence-specification> element—which is no longer supported in the XSL recommendation—to let you specify the page master. So, in addition to using the master-name attribute, I'll add an <fo:sequence-specification> element for FOP, enclosing an <fo:sequence-specifier-single> element, which also is no longer supported, and setting that element's master-name attribute to "page". (For future XSL formatting processors that conform to the current XSL recommendation, remove the <fo:sequence-specification> and <fo:sequence-specifier-single> elements.)

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    version='1.0'>

    <xsl:template match="PLANETS">
        <fo:root>

            <fo:layout-master-set>
                 <fo:simple-page-master master-name="page"
                     page-height="400mm" page-width="300mm"
                     margin-top="10mm" margin-bottom="10mm"
                     margin-left="20mm" margin-right="20mm">

                     <fo:region-body
                       margin-top="0mm" margin-bottom="10mm"
                       margin-left="0mm" margin-right="0mm"/>

                     <fo:region-after extent="10mm"/>
                 </fo:simple-page-master>
             </fo:layout-master-set>

             <fo:page-sequence master-name="page">

                 <!-- Added for fop -->
                 <fo:sequence-specification>
                     <fo:sequence-specifier-single master-name="page"/>
                 </fo:sequence-specification>
                 <!-- Added for fop -->
                 .
                 .
                 .

That specifies what page master we want to use for a page sequence. Next, you must specify the content of the page sequence. The content of these pages comes from flow children of the fo:page-sequence.

Creating Flows: fo:flow

Flow objects are so called because the text in them "flows" and is arranged to fit the page by the displaying software. The content of a page is handled with flow objects.

Two kinds of flow objects exist: fo:static-content and fo:flow. An fo:static-content flow object holds content, such as the text that goes into headers and footers, that is repeated on the pages of the page sequence. The fo:flow flow object, on the other hand, holds the text itself that makes up the content of the document. The fo:flow object has a single property, flow-name.

I'll add a fo:flow object to planets.xsl to handle the text content of planets.xml. To make sure that the text content of planets.xml is transformed into that flow, I'll use an <xsl:apply-templates> element, which we first saw in the previous chapter. The <xsl:apply-templates> element will make the XSL processor process the various elements in planets.xml (note that I also add the declaration of the xsl namespace) and will insert them into the flow:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    version='1.0'>

    <xsl:template match="PLANETS">
        <fo:root>

            <fo:layout-master-set>
                 <fo:simple-page-master master-name="page"
                     page-height="400mm" page-width="300mm"
                     margin-top="10mm" margin-bottom="10mm"
                     margin-left="20mm" margin-right="20mm">

                     <fo:region-body
                       margin-top="0mm" margin-bottom="10mm"
                       margin-left="0mm" margin-right="0mm"/>

                     <fo:region-after extent="10mm"/>
                 </fo:simple-page-master>
             </fo:layout-master-set>

             <fo:page-sequence master-name="page">
                 <!-- Added for fop -->
                 <fo:sequence-specification>
                     <fo:sequence-specifier-single master-name="page"/>
                 </fo:sequence-specification>
                 <!-- Added for fop -->

                 <fo:flow>
                     <xsl:apply-templates/>
                 </fo:flow>
             </fo:page-sequence>

        </fo:root>
    </xsl:template>
    .
    .
    .

That completes the fo:page-sequence object; we've specified a master to use for this sequence and provided the XSL processor a way to get the content that will go into the pages in the formatted document. Besides fo:flow, there's another flow object: fo:static-content.

Creating Static Content: fo:static-content

The fo:static-content formatting object holds formatting objects that are to be presented in a single region or repeated in regions on one or more pages in the page sequence. It is most often used to create repeating headers and footers because its content is repeated on every page to which it is assigned.

Like the fo:flow flow object, the fo:static-content formatting object has a single property, flow-name.

Creating Block-level Content: fo:block

You use blocks in XSL just as we did in CSS: to create a rectangular display area set off from other display areas in a document. You use the fo:block formatting object for formatting such items as paragraphs, titles, headlines, figure and table captions, and so on. Here's an example from the beginning of the chapter:

<fo:block font-family="sans-serif" line-height="48pt" font-size="36pt">
    Welcome to XSL formatting.
</fo:block>

You can use these properties with fo:block:

  • Common accessibility properties: source-document, role

  • Common aural properties: azimuth, cue-after, cue-before, elevation, pause-after, pause-before, pitch, pitch-range, play-during, richness, speak, speak-header, speak-numeral, speak-punctuation, speech-rate, stress, voice-family, volume

  • Common border, padding, and background properties: background-attachment, background-color, background-image, background-repeat, background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border-bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • Common font properties: font-family, font-size, font-stretch, font-size-adjust, font-style, font-variant, font-weight

  • Common hyphenation properties: country, language, script, hyphenate, hyphenation-character, hyphenation-push-character-count, hyphenation-remain-character-count

  • Common margin properties for blocks: margin-top, margin-bottom, margin-left, margin-right, space-before, space-after, start-indent, end-indent

  • break-after

  • break-before

  • color

  • font-height-override-after

  • font-height-override-before

  • hyphenation-keep

  • hyphenation-ladder-count

  • id

  • keep-together

  • keep-with-next

  • keep-with-previous

  • last-line-end-indent

  • linefeed-treatment

  • line-height

  • line-height-shift-adjustment

  • line-stacking-strategy

  • orphans

  • relative-position

  • space-treatment

  • span

  • text-align

  • text-align-last

  • text-indent

  • visibility

  • white-space-collapse

  • widows

  • wrap-option

  • z-index

Note that the data in planets.xml is broken up into various child elements of a <PLANET> element, such as <NAME>, <MASS>, and so on like this:

<PLANET COLOR="RED">
  <NAME>Mercury</NAME>
  <MASS UNITS="(Earth = 1)">.0553</MASS>
  <DAY UNITS="days">58.65</DAY>
  <RADIUS UNITS="miles">1516</RADIUS>
  <DENSITY UNITS="(Earth = 1)">.983</DENSITY>
  <DISTANCE UNITS="million miles">43.4</DISTANCE><!--At perihelion-->
</PLANET>

In this example, I'll give the data in each of the children of a <PLANET> element its own block in the formatted document. To do that, I add a rule to planets.xsl for each of those children, specifying the font to use for each block:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    version='1.0'>

    <xsl:template match="PLANETS">
        <fo:root>

            <fo:layout-master-set>
                 <fo:simple-page-master master-name="page"
                     page-height="400mm" page-width="300mm"
                     margin-top="10mm" margin-bottom="10mm"
                     margin-left="20mm" margin-right="20mm">

                     <fo:region-body
                       margin-top="0mm" margin-bottom="10mm"
                       margin-left="0mm" margin-right="0mm"/>

                     <fo:region-after extent="10mm"/>
                 </fo:simple-page-master>
             </fo:layout-master-set>

             <fo:page-sequence master-name="page">

                 <!-- Added for fop -->
                 <fo:sequence-specification>
                     <fo:sequence-specifier-single master-name="page"/>
                 </fo:sequence-specification>
                 <!-- Added for fop -->

                 <fo:flow>
                     <xsl:apply-templates/>
                 </fo:flow>
             </fo:page-sequence>

        </fo:root>
    </xsl:template>

    <xsl:template match="PLANET/NAME">
        <fo:block font-weight="bold" font-size="36pt"
            line-height="48pt" font-family="sans-serif">
            Name:
            <xsl:apply-templates/>
        </fo:block>
    </xsl:template>

    <xsl:template match="PLANET/MASS">
        <fo:block font-size="36pt" line-height="48pt"
            font-family="sans-serif">
            Mass (Earth = 1):
            <xsl:apply-templates/>
        </fo:block>
    </xsl:template>

    <xsl:template match="PLANET/DAY">
        <fo:block font-size="36pt" line-height="48pt"
            font-family="sans-serif">
            Day (Earth = 1):
            <xsl:apply-templates/>
        </fo:block>
    </xsl:template>

    <xsl:template match="PLANET/RADIUS">
        <fo:block font-size="36pt" line-height="48pt"
            font-family="sans-serif">
            Radius (in miles):
            <xsl:apply-templates/>
        </fo:block>
    </xsl:template>

    <xsl:template match="PLANET/DENSITY">
        <fo:block font-size="36pt" line-height="48pt"
            font-family="sans-serif">
            Density (Earth = 1):
            <xsl:apply-templates/>
        </fo:block>
    </xsl:template>

    <xsl:template match="PLANET/DISTANCE">
        <fo:block font-size="36pt" line-height="48pt"
            font-family="sans-serif">

            Distance (million miles):
            <xsl:apply-templates/>
        </fo:block>
    </xsl:template>

</xsl:stylesheet>

And now we've handled all the elements in planets.xml, so that completes planets.xsl. You can see the results in Figure 14.2—congratulations, you've completed your first transformation to XSL formatting objects.

Figure 14.2. Using planets.xsl for formatting.


Inline-Level Formatting Objects

Besides block objects, you can also create inline objects. Inline objects are usually used to format part of the text as that text follows the normal flow in the page. For example, you can make the first character in a paragraph larger, make the whole first line smaller, insert page numbers into text, and so on.

Here are the inline formatting objects:

  • fo:bidi-override

  • fo:character

  • fo:initial-property-set

  • fo:external-graphic

  • fo:instream-foreign-object

  • fo:inline

  • fo:inline-container

  • fo:leader

  • fo:page-number

  • fo:page-number-citation

I'll take a look at a few of the more common of these objects next.

Using fo:character

The fo:character object enables you to handle the characters in a document individually, which is very useful if you want to write an XSL processor, but not necessarily that useful otherwise. You can use fo:character to replace characters with other characters. Here's an example; in this case, I'm matching an element named <MASKED> and replacing the characters in it with a hyphen (-):

<xsl:template match="MASKED">
    <fo:character character="-">
        <xsl:value-of select="."/>
    </fo:character>
</xsl:template>

You can use these properties with fo:character:

  • Common aural properties: azimuth, cue-after, cue-before, elevation, pause-after, pause-before, pitch, pitch-range, play-during, richness, speak, speak-header, speak-numeral, speak-punctuation, speech-rate, stress, voice-family, volume

  • Common border, padding, and background properties: background-attachment, background-color, background-image, background-repeat, background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border-bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • Common font properties: font-family, font-size, font-stretch, font-size-adjust, font-style, font-variant, font-weight

  • Common hyphenation properties: country, language, script, hyphenate, hyphenation-character, hyphenation-push-character-count, hyphenation-remain-character-count

  • Common margin properties-inline: space-end, space-start

  • alignment-adjust

  • treat-as-word-space

  • baseline-identifier

  • baseline-shift

  • character

  • color

  • dominant-baseline

  • font-height-override-after

  • font-height-override-before

  • glyph-orientation-horizontal

  • glyph-orientation-vertical

  • id

  • keep-with-next

  • keep-with-previous

  • letter-spacing

  • line-height

  • line-height-shift-adjustment

  • relative-position

  • score-spaces

  • suppress-at-line-break

  • text-decoration

  • text-shadow

  • text-transform

  • word-spacing

fo:initial-property-set

You can format the first line of an fo:block object with fo:initial-property-set (it's much like the CSS first-line pseudoelement). Here's an example where I'm setting the first line of a block in small caps:

<fo:block>
    <fo:initial-property-set font-variant="small-caps" />
    Here is the actual text of the paragraph; the first line,
    and only the first line, will be displayed in small caps.
</fo:block>

You can use these properties with fo:initial-property-set:

  • Common accessibility properties: source-document, role

  • Common aural properties: azimuth, cue-after, cue-before, elevation, pause-after, pause-before, pitch, pitch-range, play-during, richness, speak, speak-header, speak-numeral, speak-punctuation, speech-rate, stress, voice-family, volume

  • Common border, padding, and background properties: background-attachment, background-color, background-image, background-repeat, background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border-bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • Common font properties: font-family, font-size, font-stretch, font-size-adjust, font-style, font-variant, font-weight

  • color

  • id

  • letter-spacing

  • line-height

  • line-height-shift-adjustment

  • relative-position

  • score-spaces

  • text-decoration

  • text-shadow

  • text-transform

  • word-spacing

Adding Graphics: fo:external-graphic

Another inline formatting object that is available is fo:external-graphic, which you use to embed an image in a document. (Unfortunately, fo:external-graphic is not supported by FOP yet.)

You can set the size of the image in the document with the content-height, content-width, and scaling properties; if you don't set these properties, the image is displayed in its original size. Here's an example displaying an image and a caption:

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

    <fo:layout-master-set>
        <fo:simple-page-master margin-right="20mm"
            margin-left="20mm" margin-bottom="10mm"
            margin-top="10mm" page-width="300mm"
            page-height="400mm" master-name="page">

            <fo:region-body margin-right="0mm"
                margin-left="0mm" margin-bottom="10mm"
                margin-top="0mm"/>

         <fo:region-after extent="10mm"/>

        </fo:simple-page-master>
    </fo:layout-master-set>

    <fo:page-sequence master-name="page">

        <!-- Added for fop -->
        <fo:sequence-specification>
            <fo:sequence-specifier-single master-name="page"/>
        </fo:sequence-specification>
        <!-- Added for fop -->

        <fo:flow>

            <fo:block>
                <fo:external-graphic src="alps15.jpg"/>
            </fo:block>

            <fo:block space-before="10pt" start-indent="10mm"
                end-indent="0mm">
                A view of the Austrian Alps near Wolfgang See
            </fo:block>

        </fo:flow>
    </fo:page-sequence>
</fo:root>

You can use these properties with fo:external-graphic:

  • Common accessibility properties: source-document, role

  • Common aural properties: azimuth, cue-after, cue-before, elevation, pause-after, pause-before, pitch, pitch-range, play-during, richness, speak, speak-header, speak-numeral, speak-punctuation, speech-rate, stress, voice-family, volume

  • Common border, padding, and background properties: background-attachment, background-color, background-image, background-repeat, background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border-bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • Common margin properties-inline: space-end, space-start

  • alignment-adjust

  • baseline-identifier

  • baseline-shift

  • block-progression-dimension

  • content-height

  • content-type

  • content-width

  • dominant-baseline

  • height

  • id

  • inline-progression-dimension

  • keep-with-next

  • keep-with-previous

  • line-height

  • line-height-shift-adjustment

  • relative-position

  • overflow

  • scaling

  • scaling-method

  • src

  • width

The Inline Formatting Object: fo:inline

You can use the fo:inline formatting object to format a part of your text with a background or surround it with a border. This object is fairly general and lets you format an inline area almost as though it were a block.

You can use these properties with fo:inline:

  • Common accessibility properties: source-document, role

  • Common aural properties: azimuth, cue-after, cue-before, elevation, pause-after, pause-before, pitch, pitch-range, play-during, richness, speak, speak-header, speak-numeral, speak-punctuation, speech-rate, stress, voice-family, volume

  • Common border, padding, and background properties: background-attachment, background-color, background-image, background-repeat, background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border-bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • Common font properties: font-family, font-size, font-stretch, font-size-adjust, font-style, font-variant, font-weight

  • Common margin properties-inline: space-end, space-start

  • alignment-adjust

  • baseline-identifier

  • baseline-shift

  • color

  • dominant-baseline

  • id

  • keep-together

  • keep-with-next

  • keep-with-previous

  • line-height

  • line-height-shift-adjustment

  • relative-position

  • text-decoration

  • visibility

  • z-index

Creating Page Numbers: fo:page-number

Another useful inline formatting object is fo:page-number, which creates an inline area displaying the current page number. Here's an example:

<fo:block>
    <xsl:text>This is page </xsl:text><fo:page-number/>.
</fo:block>

You can use these properties with fo:page-number:

  • Common accessibility properties: source-document, role

  • Common aural properties: azimuth, cue-after, cue-before, elevation, pause-after, pause-before, pitch, pitch-range, play-during, richness, speak, speak-header, speak-numeral, speak-punctuation, speech-rate, stress, voice-family, volume

  • Common border, padding, and background properties: background-attachment, background-color, background-image, background-repeat, background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border- bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • Common font properties: font-family, font-size, font-stretch, font-size-adjust, font-style, font-variant, font-weight

  • Common margin properties-inline: space-end, space-start

  • alignment-adjust

  • baseline-identifier

  • baseline-shift

  • dominant-baseline

  • id

  • keep-with-next

  • keep-with-previous

  • letter-spacing

  • line-height

  • line-height-shift-adjustment

  • relative-position

  • score-spaces

  • text-decoration

  • text-shadow

  • text-transform

  • word-spacing

Creating Tables

Some of the most useful constructs you can format with XSL are tables. A table in XSL is much like one in HTML—a rectangular grid of rows and columns of cells. You can use nine formatting objects to create tables:

  • fo:table-and-caption

  • fo:table

  • fo:table-column

  • fo:table-caption

  • fo:table-header

  • fo:table-footer

  • fo:table-body

  • fo:table-row

  • fo:table-cell

Creating tables is a little involved in XSL. You create a fo:table object, format each column with an fo:table-column object, and then create a table-body object, as well as table-row objects for each row and table-cell objects for each cell in each row. Here's an example creating a 3 × 3 table with the words Tic, Tac, and Toe repeated on each line:

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
        <fo:simple-page-master margin-right="20mm"
            margin-left="20mm" margin-bottom="20mm"
            margin-top="20mm" page-width="300mm"
            page-height="400mm" master-name="page">

            <fo:region-body margin-right="0mm" margin-left="0mm"
                margin-bottom="20mm" margin-top="0mm"/>

            <fo:region-after extent="20mm"/>

        </fo:simple-page-master>
    </fo:layout-master-set>

    <fo:page-sequence master-name="page">

        <!-- Added for fop -->
        <fo:sequence-specification>
            <fo:sequence-specifier-single master-name="page"/>
        </fo:sequence-specification>
        <!-- Added for fop -->

        <fo:flow>
            <fo:table width="12cm" table-layout="fixed">
                <fo:table-column column-number="1" column-width="25mm">
                </fo:table-column>
                <fo:table-column column-number="2" column-width="25mm">
                </fo:table-column>
                <fo:table-column column-number="3" column-width="25mm">
                </fo:table-column>
                <fo:table-body>
                     <fo:table-row line-height="20mm">
                         <fo:table-cell column-number="1">
                             <fo:block font-family="sans-serif"
                                 font-size="36pt">
                                 Tic
                             </fo:block>
                         </fo:table-cell>
                         <fo:table-cell column-number="2">
                             <fo:block font-family="sans-serif"
                                 font-size="36pt">
                                 Tac
                             </fo:block>
                         </fo:table-cell>
                         <fo:table-cell column-number="3">
                             <fo:block font-family="sans-serif"
                                 font-size="36pt">
                                 Toe
                             </fo:block>
                         </fo:table-cell>
                     </fo:table-row>
                     <fo:table-row line-height="20mm">
                         <fo:table-cell column-number="1">
                             <fo:block font-family="sans-serif"
                                 font-size="36pt">
                                 Tic
                             </fo:block>
                         </fo:table-cell>
                         <fo:table-cell column-number="2">
                             <fo:block font-family="sans-serif"
                                 font-size="36pt">
                                 Tac
                             </fo:block>
                         </fo:table-cell>
                         <fo:table-cell column-number="3">
                             <fo:block font-family="sans-serif"
                                 font-size="36pt">
                                 Toe
                             </fo:block>
                         </fo:table-cell>
                     </fo:table-row>
                     <fo:table-row line-height="20mm">
                         <fo:table-cell column-number="1">
                             <fo:block font-family="sans-serif"
                                 font-size="36pt">
                                 Tic
                             </fo:block>
                         </fo:table-cell>
                         <fo:table-cell column-number="2">
                             <fo:block font-family="sans-serif"
                                 font-size="36pt">
                                 Tac
                             </fo:block>
                         </fo:table-cell>
                         <fo:table-cell column-number="3">
                             <fo:block font-family="sans-serif"
                                 font-size="36pt">
                                 Toe
                             </fo:block>
                         </fo:table-cell>
                     </fo:table-row>
               </fo:table-body>
            </fo:table>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

After running this file, table.fo, through FOP and creating table.pdf, you can see the result in Figure 14.3.

Figure 14.3. An XSL formatted table in Adobe Acrobat.


I'll now take a look at the various objects you use to create tables.

fo:table

You use the fo:table object to create a new table. The table itself consists of an optional header, an optional footer, and one or more table bodies. The actual grid of cells, arranged into rows and columns, appears in a table body.

You can use these properties with the fo:table object:

  • Common accessibility properties: source-document, role

  • Common aural properties: azimuth, cue-after, cue-before, elevation, pause-after, pause-before, pitch, pitch-range, play-during, richness, speak, speak-header, speak-numeral, speak-punctuation, speech-rate, stress, voice-family, volume

  • Common border, padding, and background properties: background-attachment, background-color, background-image, background-repeat, background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border-bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • Common margin properties-block: margin-top, margin-bottom, margin-left, margin-right, space-before, space-after, start-indent, end-indent

  • block-progression-dimension

  • border-collapse

  • border-separation

  • break-after

  • break-before

  • id

  • inline-progression-dimension

  • height

  • keep-together

  • keep-with-next

  • keep-with-previous

  • relative-position

  • table-layout

  • table-omit-footer-at-break

  • table-omit-header-at-break

  • width

  • writing-mode

fo:table-column

You can use the fo:table-column formatting object to indicate characteristics that apply to table cells that have the same column. Probably the most important property here is the column-width property, which you use to set the width of each column.

You can use these properties with the fo:table-column object:

  • Common border, padding, and background properties: background-attachment, background-color, background-image, background-repeat, background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border- bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • column-number

  • column-width

  • number-columns-repeated

  • number-columns-spanned

  • visibility

fo:table-body

The actual content of tables appears in fo:table-body objects. The object is the one that contains the actual fo:table-row objects, which, in turn, contain the fo:table-cell objects that hold the data for the table.

You can use these properties with the fo:table-body object:

  • Common border, padding, and background properties: background-attachment, background-color, background-image, background-repeat, background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border-bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • id

  • relative-position

fo:table-row

You use the fo:table-row object is used to group table cells into rows. The XSL processor determines the dimensions of the table by how many rows you've added to the table.

You can use these properties with the fo:table-row object:

  • Common accessibility properties: source-document, role

  • Common aural properties: azimuth, cue-after, cue-before, elevation, pause-after, pause-before, pitch, pitch-range, play-during, richness, speak, speak-header, speak-numeral, speak-punctuation, speech-rate, stress, voice-family, volume

  • Common border, padding, and background properties: background-attachment, background-color, background-image, background-repeat, background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border-bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • block-progression-dimension

  • break-after

  • break-before

  • id

  • height

  • keep-together

  • keep-with-next

  • keep-with-previous

  • relative-position

fo:table-cell

You place the content for each cell in an fo:table-cell object. To specify the font and other characteristics of that content, you can enclose an fo:block object inside each fo:table-cell object. You can connect a table cell with a table column using the column-number property.

You can use these properties with the fo:table-cell object:

  • Common accessibility properties: source-document, role

  • Common aural properties: azimuth, cue-after, cue-before, elevation, pause-after, pause-before, pitch, pitch-range, play-during, richness, speak, speak-header, speak-numeral, speak-punctuation, speech-rate, stress, voice-family, volume

  • Common border, padding, and background properties: background-attachment, background-color, background-image, background-repeat, background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border-bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • block-progression-dimension

  • column-number

  • display-align

  • empty-cells

  • ends-row

  • height

  • id

  • number-columns-spanned

  • number-rows-spanned

  • relative-align

  • relative-position

  • starts-row

  • width

Creating Lists

Besides tables, another XSL construct that is very close to the corresponding construct in HTML are lists. An XSL list presents a vertical arrangement of items, just as in HTML. You use four formatting objects to construct lists:

  • fo:list-block

  • fo:list-item

  • fo:list-item-label

  • fo:list-item-body

You enclose the whole list in an fo:list-block object, and you enclose each item in the list in an fo:list-item object. To create a label for the list item, you use an fo:list-item-label object; to insert the actual data for each list item, you use an fo:list-item-body object.

Here's an example creating a numbered list with three list items: Tic, Tac, and Toe:

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
        <fo:simple-page-master margin-right="20mm" margin-left="20mm"
            margin-bottom="10mm" margin-top="10mm" page-width="300mm"
            page-height="400mm" master-name="page">

            <fo:region-body margin-right="0mm" margin-left="0mm"
            margin-bottom="10mm" margin-top="0mm"/>

            <fo:region-after extent="10mm"/>
        </fo:simple-page-master>
    </fo:layout-master-set>

    <fo:page-sequence master-name="page">
        <!-- Added for fop -->
        <fo:sequence-specification>
            <fo:sequence-specifier-single master-name="page"/>
        </fo:sequence-specification>
        <!-- Added for fop -->

        <fo:flow>
            <fo:list-block
                provisional-distance-between-starts="15mm"
                provisional-label-separation="5mm">

                 <fo:list-item line-height="20mm">
                    <fo:list-item-label>
                        <fo:block font-family="sans-serif"
                            font-size="36pt">
                            1.
                        </fo:block>
                    </fo:list-item-label>
                    <fo:list-item-body>
                        <fo:block font-family="sans-serif"
                            font-size="36pt">
                            Tic.
                        </fo:block>
                    </fo:list-item-body>
                </fo:list-item>
                <fo:list-item line-height="20mm">
                    <fo:list-item-label>
                        <fo:block font-family="sans-serif"
                            font-size="36pt">
                            2.
                        </fo:block>
                    </fo:list-item-label>
                    <fo:list-item-body>
                        <fo:block font-family="sans-serif"
                            font-size="36pt">
                            Tac.
                        </fo:block>
                    </fo:list-item-body>
                </fo:list-item>
                 <fo:list-item line-height="20mm">
                    <fo:list-item-label>
                        <fo:block font-family="sans-serif"
                            font-size="36pt">
                            3.
                        </fo:block>
                    </fo:list-item-label>
                    <fo:list-item-body>
                        <fo:block font-family="sans-serif"
                            font-size="36pt">
                            Toe.
                        </fo:block>
                    </fo:list-item-body>
                </fo:list-item>
            </fo:list-block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

You can see the resulting PDF file displayed in the Adobe Acrobat in Figure 14.4, showing the list.

Figure 14.4. An XSL formatted list in Adobe Acrobat.


I'll take a look at the list formatting objects in more detail now.

fo:list-block

You use fo:list-block to format a list; this object encloses fo:list-item objects.

You can use these properties with the fo:list-block object:

  • Common accessibility properties: source-document, role

  • Common aural properties: azimuth, cue-after, cue-before, elevation, pause-after, pause-before, pitch, pitch-range, play-during, richness, speak, speak-header, speak-numeral, speak-punctuation, speech-rate, stress, voice-family, volume

  • Common border, padding, and background properties: background-attachment, background-color, background-image, background-repeat, background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border-bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • Common margin properties-block: margin-top, margin-bottom, margin-left, margin-right, space-before, space-after, start-indent, end-indent

  • break-after

  • break-before

  • id

  • keep-together

  • keep-with-next

  • keep-with-previous

  • provisional-distance-between-starts

  • provisional-label-separation

  • relative-position

fo:list-item

You use a fo:list-item object to contain the label and the body of an item in a list.

You can use these properties with the fo:list-item object:

  • Common accessibility properties: source-document, role

  • Common aural properties: azimuth, cue-after, cue-before, elevation, pause-after, pause-before, pitch, pitch-range, play-during, richness, speak, speak-header, speak-numeral, speak-punctuation, speech-rate, stress, voice-family, volume

  • Common border, padding, and background properties: background-attachment, background-color, background-image, background-repeat, background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border-bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • Common margin properties-block: margin-top, margin-bottom, margin-left, margin-right, space-before, space-after, start-indent, end-indent

  • break-after

  • break-before

  • id

  • keep-together

  • keep-with-next

  • keep-with-previous

  • relative-align

  • relative-position

fo:list-item-label

You use the fo:list-item-label object to hold the label of a list item, usually to enumerate or decorate (as with a bullet) the body of the list item.

You can use these properties with the fo:list-item-label object:

  • Common accessibility properties: source-document, role

  • id

  • keep-together

fo:list-item-body

You use the fo:list-item-body object to hold the actual body of a list item. To format the item's body the way you want it, you can enclose an fo:block object in an fo:list-item-body object.

You can use these properties with the fo:list-item-body object:

  • Common accessibility properties: source-document, role

  • id

  • keep-together

As you can see, there's a lot to XSL formatting objects; in fact, there's a lot more that we don't have the space to cover here. For more details, take a look at the W3C site. Not a lot of software packages can put formatting objects to work yet, but that should change in the future.

In the next chapter, I'm going to start taking an in-depth look at another important part of the XML specification—XLinks and XPointers.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.56.18