Contents | < Bookmarks | Extensions >

Miscellaneous Inline Elements

There are several inline elements left to describe:

Page Numbers

fo:page-number is used to insert the current page number

fo:page-number-citation is used to retrieve the page number of a give element. This element is also useful in inserting the number of pages in a document, as shown below:

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
        <fo:simple-page-master master-name="default" page-height="5cm" 
                                  page-width="10cm" margin="5mm">
            <fo:region-body/>
            <fo:region-after region-name="footer" extent="0.5in"/>
        </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="default" font-family="10pt Verdana">
        <fo:static-content flow-name="footer">
            <fo:block text-align="right" border-top="1pt dashed silver">
                Page
                <fo:page-number />
                of
                <fo:page-number-citation  ref-id="theEnd" />
            </fo:block>
        </fo:static-content>
        <fo:flow flow-name="xsl-region-body">
            <fo:block>
                The text content of the first page.
            </fo:block>
            <fo:block break-before="page">
                The text content of the second page.
            </fo:block>
            <fo:block id="theEnd" />
        </fo:flow>
    </fo:page-sequence>
</fo:root>
For the complete source code for this code example see "Tutorial/Page Count.fo" located under XML Documents Samples/Tutorial folder.

The rendering result is displayed in the next figure.

Figure 1

To start the numbering from a different page number use initial-page-number attribute of fo:page-sequence.

fo:basic-link can be used to display hyperlinks in a document, either to an external document, or as a cross reference within the current document.

As opposed to HTML, this element, does not underline the text or sets the text the color to blue; it just simply marks the area as being active.

You must use the standard properties like color and text-decoration to simulate the aspect of HTML hyperlinks.

<fo:block>
    Hyperlink to an external resource:
    <fo:basic-link  color="blue" text-decoration="underline" 
                      external-destination="url(http://www.ecrion.com)" >
        Ecrion Home
    </fo:basic-link>
</fo:block>

Leaders

fo:leader is a more complicated version of HTML's rule element. In the next example we will display a dotted leader in a table of contents:

<fo:flow flow-name="xsl-region-body" font-family="Arial Narrow" font-size="12pt">
    <fo:block font-size="18pt">
        Table of Contents
    </fo:block>
    <fo:block text-align-last="justify">
        <fo:basic-link color="blue" internal-destination="chapter1">
            Hello World
        </fo:basic-link>
        <fo:inline keep-together.within-line="always">
            <fo:leader leader-pattern="dots"/> 
            <fo:page-number-citation ref-id="chapter1" />
        </fo:inline>
    </fo:block>
    <fo:block text-align-last="justify">
        <fo:basic-link color="blue" internal-destination="chapter2">
            Paragraphs
        </fo:basic-link>
        <fo:inline keep-together.within-line="always">
            <fo:leader leader-pattern="dots" />
            <fo:page-number-citation ref-id="chapter2" />
        </fo:inline>
    </fo:block>
    <fo:block id="chapter1" break-before="page" font-size="18pt">
        Hello World
    </fo:block>
</fo:flow>
For the complete source code for this code example see "Tutorial/Leader.fo" located under XML Documents Samples/Tutorial folder.

The rendering result is displayed in the next figure.

Figure 2

 

Contents | < Bookmarks | Extensions >