Table of Contents
This section contains content relating to my XSL-FO book. Initially it is only the examples extracted from the book.
Example 2-1. A basic page specification
<?xml version="1.0" encoding="utf-8"?>
[1]<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
[2]<fo:layout-master-set>
<fo:simple-page-master
page-height="11in"
page-width="8.5in"
[3] master-name="only">
<fo:region-body
[4] region-name="xsl-region-body"
margin="0.7in" />
[5] <fo:region-before
region-name="xsl-region-before"
extent="0.7in" />
<fo:region-after
[6] region-name="xsl-region-after"
extent="0.7in" />
</fo:simple-page-master>
</fo:layout-master-set>
[7]<fo:page-sequence master-reference="only" format="A">
<fo:flow flow-name="xsl-region-body">
[8] <fo:block >Some base content, containing an inline warning,
<fo:inline >Warning: </fo:inline>Do not touch blue paper,
a fairly straightforward piece requiring emphasis
<fo:inline font-weight="bold">TEXT</fo:inline>, and
some instructions which require presenting in a different
way, such as <fo:inline font-style="italic">Now light
the blue paper</fo:inline>.
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Example 2-2. Writing mode
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE fo:root SYSTEM "fo.dtd"> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" writing-mode="lr-tb"> <fo:layout-master-set> ...
Example 2-3. Minimal test file
[1]<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
[2] <fo:layout-master-set>
<fo:simple-page-master master-name="only">
<fo:region-body
[3] region-name="xsl-region-body"
margin="0.7in" padding="6pt" />
<fo:region-before
region-name="xsl-region-before"
extent="0.7in" />
<fo:region-after
region-name="xsl-region-after"
extent="0.7in" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence
[4] master-reference="only">
<fo:flow flow-name="xsl-region-body">
[5] <fo:block>Hello World</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Example 2-4. Source XML for the examples
<doc> <section><head> Simple sectioned title </head> <para>Some base content, containing an inline warning, <emphasis role="warning">Do not touch blue paper</emphasis>, a fairly straightforward piece requiring emphasis <emphasis>TEXT</emphasis>, and some instructions which require presenting in a different way, such as <instruction>Now light the blue paper</instruction>. </para> </section> .... </doc>
Example 2-5. Basic stylesheet
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
[1] xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml"/>
[2]<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master
master-name="only">
<fo:region-body
region-name="xsl-region-body"
margin="0.7in"
/>
<fo:region-before
region-name="xsl-region-before"
extent="0.7in"
display-align="before" />
<fo:region-after
region-name="xsl-region-after"
display-align="after"
extent="0.7in"
/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="only">
<fo:flow
flow-name="xsl-region-body">
[3] <xsl:apply-templates />
</fo:flow>
</fo:page-sequence>
</fo:root>
[4]</xsl:template>
</xsl:stylesheet>
Example 2-6. Other templates
[1]<xsl:template match="section">
[2] <fo:block id="{generate-id()}">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
[3]<xsl:template match="head">
<fo:block
font-family="Times"
font-size="18pt"
font-weight="bold"
space-before="18pt"
space-after="12pt"
text-align="center">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
[4]<xsl:template match="para">
<fo:block
font-family="Times"
font-size="12pt"
space-before="12pt"
space-after="12pt"
text-align="justify">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
[5]<xsl:template match="emphasis[@role='warning']">
<fo:inline
color="red">Warning: </fo:inline>
<xsl:apply-templates/>
</xsl:template>
[6]<xsl:template match="doc">
<xsl:apply-templates/>
</xsl:template>
Example 2-7. Out-of-line processing for a table of contents
<xsl:template match="/">
<fo:root>
<fo:page-sequence master-reference="only">
<fo:flow flow-name="xsl-region-body">
<!-- Produce the frontmatter here -->
<xsl:call-template name="toc"/>
[1] <xsl:apply-templates />
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
[2]<xsl:template name="toc">
[3] <xsl:for-each select="section">
<fo:block text-align-last="justify"><xsl:value-of
select="head"/> <fo:leader
leader-pattern="dots"/> <fo:page-number-citation ref-id="{@id}"/>
[4] <xsl:for-each select="section">
<fo:block text-indent="2em" text-align-last="justify"> <xsl:value-of
select="head"/> <fo:leader
leader-pattern="dots"/> <fo:page-number-citation ref-id="{@id}" />
</fo:block>
</xsl:for-each>
</fo:block>
</xsl:for-each>
</xsl:template>
Example 8. A Hello World Example.
<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
source-document="url('base.xml')" >
<fo:layout-master-set>
<fo:simple-page-master
master-name="simple"
page-height="29.7cm"
page-width="21cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="3cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence
master-reference="simple">
<fo:flow
flow-name="xsl-region-body">
<fo:block>Hello, World</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Example 9. Leaving room for a header
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master
master-name="only"
page-height="29.7cm"
page-width="21cm"
margin-top="2.5cm"
margin-bottom="2.5cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body
region-name="xsl-region-body"
margin-top="2.4cm" margin-bottom="2.4cm"
margin-left="0cm" margin-right="2.4cm"
column-count="1"/>
<fo:region-before
region-name="xsl-region-before" extent="2.3cm" />
<fo:region-after
region-name="xsl-region-after" extent="2.3cm" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence
master-reference="only">
<fo:title>sequence title</fo:title>
<fo:folio-prefix>A</fo:folio-prefix>
<fo:folio-suffix> revision 1</fo:folio-suffix>
<fo:static-content flow-name="xsl-region-before" >
<fo:block font-family="Arial, Garamond, serif" font-size="14pt"
border="thin black solid">Part 1, page <fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after" >
<fo:block font-family="Arial, Garamond, serif"
font-size="12pt"
text-align="end"
border="thin black solid">A bare footer
</fo:block>
</fo:static-content>
<fo:flow
flow-name="xsl-region-body">
<fo:wrapper font-family="Arial, Garamond, serif" font-size="14pt">
<fo:block>Hello, World. </fo:block>
</fo:wrapper>
</fo:flow>
</fo:page-sequence>
</fo:root>
Example 10. Header content
<fo:page-sequence master-reference="only">
<fo:flow
flow-name="xsl-region -body">
....
</fo:flow>
<fo:static-content
flow-name="xsl-region-before">
<fo:block> Header content, e.g. Page <fo:page-number/> </fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
.....
</fo:page-sequence>
Example 11. Use of the xsl-footnote-separator static content.
<!-- footnote-separator as a region.-->
<fo:static-content flow-name="xsl-region-after" >
<fo:block font-family="Arial, Garamond, serif"
font-size="12pt"
text-align="end"
border="thin black solid">A bare footer
</fo:block>
</fo:static-content>
<fo:static-content
flow-name="xsl-footnote-separator">
<fo:block space-before="4em">
<fo:leader color="red" leader-pattern="rule"
rule-style="solid" leader-length="100%"/>
</fo:block>
</fo:static-content>
Example 12. Footnotes and a footer containing page numbers
<fo:static-content
flow-name="xsl-region-after">
<fo:block><fo:leader color="blue" leader-pattern="rule"
rule-style="solid" leader-length="100%"/>
</fo:block>
<fo:block text-align="outside">This is page number <fo:page-number/>
</fo:block>
</fo:static-content>
Example 13. Identifying the final page
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates/>
<-- Source document is flowed here -->
<fo:block id="lastpage"/>
</fo:flow>
Example 14. Using the page number of the last page
<fo:static-content
flow-name="xsl-region-after">
<fo:block text-align="outside">Page <fo:page-number/> of
<fo:page-number-citation-last ref-id="lastpage"/>
</fo:block>
</fo:static-content>
Example 15. A more complete example
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master
master-name="only"
page-height="29.7cm"
page-width="21cm"
margin-top="2.5cm"
margin-bottom="2.5cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body
region-name="xsl-region-body"
margin-top="2.4cm" margin-bottom="2.4cm"
margin-left="0cm" margin-right="2.4cm"
column-count="1"/>
<fo:region-before
region-name="xsl-region-before" extent="2.3cm" />
<fo:region-after
region-name="xsl-region-after" extent="2.3cm" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence
master-reference="only">
<fo:title>sequence title</fo:title>
<fo:folio-prefix>A</fo:folio-prefix>
<fo:folio-suffix> revision 1</fo:folio-suffix>
<fo:static-content flow-name="xsl-region-before" >
<fo:block font-family="Arial, Garamond, serif" font-size="14pt"
border="thin black solid"
text-align="center">Part 1, page <fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after" >
<fo:block font-family="Arial, Garamond, serif"
font-size="12pt"
text-align="outside"
border="thin black solid">Document title. </fo:block>
</fo:static-content>
<fo:static-content
flow-name="xsl-footnote-separator">
<fo:block space-before="4em">
<fo:leader color="red" leader-pattern="rule"
rule-style="solid" leader-length="100%"/>
</fo:block>
</fo:static-content>
<fo:flow
flow-name="xsl-region-body">
<fo:wrapper font-family="Arial, Garamond, serif" font-size="14pt">
<fo:block>Hello, World. </fo:block>
<fo:block>Footnote demonstration.
<fo:footnote>
<fo:inline font-size="8pt" baseline-shift="super">1</fo:inline>
<fo:footnote-body>
<fo:block>1. This is the content of the footnote</fo:block>
</fo:footnote-body>
</fo:footnote>
</fo:block>
</fo:wrapper>
</fo:flow>
</fo:page-sequence>
</fo:root>
Example 16. Before and after regions overlapping the start and end regions.
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="only"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="1cm"
margin-left="1cm"
margin-right="1cm"
>
<fo:region-body
region-name="xsl-region-body"
margin="0.7in" padding="6pt" />
<fo:region-before
region-name="xsl-region-before"
extent="0.7in"
border="thin solid black"
precedence='true'
/>
<fo:region-after
region-name="xsl-region-after"
extent="0.7in"
border="thin solid black"
precedence='true'/>
<fo:region-start
region-name="xsl-region-start"
extent="0.7in"
border="thin solid black"/>
<fo:region-end
region-name="xsl-region-end"
extent="0.7in"
border="thin solid black"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence
master-reference="only">
<fo:flow flow-name="xsl-region-body">
<fo:block>Hello World</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Example 17. The effect of letting overflow be visible
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="only"
page-height="29.7cm"
page-width="11cm"
margin-top="1cm"
margin-bottom="1cm"
margin-left="1cm"
margin-right="1cm" >
<fo:region-body
region-name="xsl-region-body"
margin="0.7in" padding="6pt"
overflow='visible'
/>
<fo:region-before
region-name="xsl-region-before"
extent="0.7in"
precedence='true'
/>
<fo:region-after
region-name="xsl-region-after"
extent="0.7in"
precedence='true'/>
<fo:region-start
region-name="xsl-region-start"
extent="0.7in"
border="thin solid black"/>
<fo:region-end
region-name="xsl-region-end"
extent="0.7in"
border="thin solid black"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence
master-reference="only" >
<fo:flow flow-name="xsl-region-body" >
<fo:block>
<fo:inline keep-together.within-line='always'>A long line
which will overflow if long enough</fo:inline>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Example 18. An example of a block-container used to shift the reference orientation
<fo:flow
flow-name="xsl-region-body"
reference-orientation="0">
<fo:block>Hello World</fo:block>
<fo:block-container reference-orientation="90">
<fo:block >Rotated content. </fo:block>
<fo:block>Has the reference-orientation attribute</fo:block>
<fo:block>on the block-container set to 90</fo:block>
</fo:block-container>
</fo:flow>
Example 19. Three column output
<?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 master-name="only"
page-height="297mm" page-width="210mm"
reference-orientation="0">
<fo:region-body
reference-orientation="0"
region-name="xsl-region-body"
column-count="3"
column-gap="3mm"
margin-top="0.8in"
/>
<fo:region-before
extent="0.7in"
region-name="xsl-region-before" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="only">
<fo:static-content
flow-name="xsl-region-before">
<fo:block
text-align="outside">Page  <fo:page-number/></fo:block>
<fo:block>
<fo:leader color="blue"
leader-pattern="rule"
rule-style="solid"
leader-length="100%"/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body" >
<fo:block start-indent="2em">
...
</fo:flow>
</fo:page-sequence>
</fo:root>
Example 21. Using
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<!-- Narrow page layout -->
<fo:simple-page-master master-name="narrow"
page-height="14.7cm"
page-width="11cm"
margin-top="2.5cm"
margin-bottom="2.5cm"
margin-left="2.5cm"
margin-right="2.5cm"
>
<fo:region-body region-name="xsl-region-body"
margin-top="2cm"
margin-bottom="2cm"
margin-left="1cm"
margin-right="3cm" />
<fo:region-before
region-name="xsl-region-before"
extent="1.5cm" precedence='false'/>
<fo:region-after
region-name="xsl-region-after"
extent="1.5cm" precedence='false'/>
<fo:region-start
region-name="xsl-region-start"
extent="1cm" />
<fo:region-end
region-name="xsl-region-end"
extent="1cm" />
</fo:simple-page-master>
<!-- Wide page layout -->
<fo:simple-page-master
master-name="wide"
page-height="14.7cm"
page-width="21cm"
margin-top="2.5cm"
margin-bottom="2.5cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body region-name="xsl-region-body"
margin-top="2cm"
margin-bottom="2cm"
margin-left="3cm"
margin-right="1cm" />
<fo:region-before
region-name="xsl-region-before"
extent="1.5cm" precedence='false'
/>
<fo:region-after
region-name="xsl-region-after"
extent="1.5cm" precedence='false'/>
<fo:region-start
region-name="xsl-region-start"
extent="1cm" />
<fo:region-end
region-name="xsl-region-end"
extent="1cm" />
</fo:simple-page-master>
<!-- Now the page selection logic -->
<fo:page-sequence-master
master-name="all">
<fo:single-page-master-reference
master-reference="wide"/>
<fo:single-page-master-reference
master-reference="narrow"/>
<fo:single-page-master-reference
master-reference="wide"/>
</fo:page-sequence-master>
</fo:layout-master-set>
<!--Content to be formatted -->
<fo:page-sequence
master-reference="all">
<fo:static-content flow-name="xsl-region-before" >
<fo:block font-family="Arial, Garamond, serif"
font-size="14pt"
text-align="center">Part 1, page <fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after" >
<fo:block font-family="Arial, Garamond, serif"
font-size="12pt"
text-align="outside"
>Document title. </fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body" >
<fo:block >Document content. Fill out to see the overflow effect</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Example 22. Using the
<fo:page-sequence-master
master-name="all">
<fo:single-page-master-reference
master-reference="wide"/>
<fo:single-page-master-reference
master-reference="narrow"/>
<fo:repeatable-page-master-reference
master-reference="wide"/>
</fo:page-sequence-master>
Example 23. A Page Sequence Master example
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<!-- Title page layout -->
<fo:simple-page-master master-name="title"
page-height="14.7cm"
page-width="21cm"
margin-top="2.5cm"
margin-bottom="2.5cm"
margin-left="2.5cm"
margin-right="2.5cm"
>
<fo:region-body region-name="xsl-region-body"
margin-top="2cm"
margin-bottom="10cm"
margin-left="1cm"
margin-right="3cm"
/>
<fo:region-before
region-name="xsl-region-before"
extent="1.5cm" precedence='false'/>
<fo:region-after
region-name="xsl-region-after"
extent="1.5cm" precedence='false'/>
<fo:region-start
region-name="xsl-region-start"
extent="1cm" />
<fo:region-end
region-name="xsl-region-end"
extent="1cm" />
</fo:simple-page-master>
<!-- Even page layout -->
<fo:simple-page-master master-name="even"
page-height="14.7cm"
page-width="21cm"
margin-top="2.5cm"
margin-bottom="2.5cm"
margin-left="2.5cm"
margin-right="2.5cm"
>
<fo:region-body region-name="xsl-region-body"
margin-top="2cm"
margin-bottom="2cm"
margin-left="1cm"
margin-right="3cm" />
<fo:region-before
region-name="xsl-region-before"
extent="1.5cm" precedence='false'/>
<fo:region-after
region-name="xsl-region-after"
extent="1.5cm" precedence='false'/>
<fo:region-start
region-name="xsl-region-start"
extent="1cm" />
<fo:region-end
region-name="xsl-region-end"
extent="1cm" />
</fo:simple-page-master>
<!-- Odd page layout -->
<fo:simple-page-master
master-name="odd"
page-height="14.7cm"
page-width="21cm"
margin-top="2.5cm"
margin-bottom="2.5cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body region-name="xsl-region-body"
margin-top="2cm"
margin-bottom="2cm"
margin-left="3cm"
margin-right="1cm" />
<fo:region-before
region-name="xsl-region-before"
extent="1.5cm" precedence='false'
/>
<fo:region-after
region-name="xsl-region-after"
extent="1.5cm" precedence='false'/>
<fo:region-start
region-name="xsl-region-start"
extent="1cm" />
<fo:region-end
region-name="xsl-region-end"
extent="1cm" />
</fo:simple-page-master>
<!-- Now the page selection logic -->
<fo:page-sequence-master
master-name="all">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference
master-reference="title"
page-position="first"/>
<fo:conditional-page-master-reference
master-reference="odd"
odd-or-even="odd"/>
<fo:conditional-page-master-reference
master-reference="even"
odd-or-even="even"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<!--Content to be formatted -->
<fo:page-sequence
master-reference="all">
<fo:static-content flow-name="xsl-region-before" >
<fo:block font-family="Arial, Garamond, serif"
font-size="14pt"
text-align="center">Part 1, page <fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after" >
<fo:block font-family="Arial, Garamond, serif"
font-size="12pt"
text-align="outside"
>Document title. </fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body" >
<fo:block text-align="justify"
font-weight="bold"
font-size="20pt"
>The document title on its own page</fo:block>
... Add sufficient content to fill 3 pages to see this example working.
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Example 24. A repeatable page master alternatives example
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference
master-reference="portrait"
page-position="first"/>
<fo:conditional-page-master-reference
master-reference="portrait"
page-position="last"/>
<fo:conditional-page-master-reference
master-reference="verso"
odd-or-even="odd"/>
<fo:conditional-page-master-reference
master-reference="recto"
odd-or-even="even"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
Example 4-1. Space resolution
<fo:block space-after.minimum="3pt">
space-after.maximum="24pt"
space-after.optimum="12pt">
.....
</fo:block>
<fo:block space-before.minimum="6pt"
space-before.maximum="18pt"
space-before.optimum="12pt">
....
</fo:block>
Example 5-1. A simple block
<xsl:template match="para">
<fo:block
border-style="solid"
border-width=".1mm"
font-family="Times"
font-size="12pt"
space-before="12pt"
space-after="12pt"
text-align="justify">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
Example 5-2. Indentation
<xsl:template match="quote">
<fo:block
start-indent="6em"
end-indent="6em"
font-family="Times"
font-size="12pt"
space-before="12pt"
space-after="12pt"
text-align="start">
"<xsl:apply-templates/>"
</fo:block>
</xsl:template>
Example 5-3. First line indentation
<xsl:template match="para">
<fo:block
space-before="12pt"
space-after="12pt"
text-indent="3em"
text-align="justify">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
Example 5-4. Hanging indents
<fo:block
text-indent='-4em'
start-indent='4em'>
An example of a hanging indent, a paragraph with the first
line left aligned, and the remainder of the paragraph
indented by a fixed amount. Set by using the start indent
and text-indent properties on a block. The text-indent is
set to a negative value, the start indent to a positive
value.
</fo:block>
Example 5-5. XML source for block as a break
<para>This paragraph includes a quotation <quote>The fair breeze blew, the white foam flew <nl/> The furrow followed free; <nl/> We were the first that ever burst<nl/> Into that silent sea. </quote> <author>Samuel Taylor Coleridge</author> And continues after it. </para>
Example 5-7. Possible line treatment
<xsl:template match="nl"> <fo:character character = '
' /> </xsl:template>
Example 5-8. Retaining space
<fo:block space-before="2in" space-before.conditionality = 'retain'> ...
Example 5-9. Inter-paragraph spacing
<fo:block space-after="12pt" border-style="solid" border-width=".1mm" > This is the first of three blocks .</fo:block> <fo:block border-style="solid" border-width=".1mm" space-after="12pt"> This block has the space-after set to 12pt, so there will be an interaction.</fo:block> <fo:block border-style="solid" border-width=".1mm" space-before="18pt" space-before.precedence="5"> This block really must have the larger (18pt) space before .</fo:block>
Example 5-10. Wrapper blocks to offset content from the main flow
<fo:block
border-style="solid"
border-width="2mm">
<fo:block start-indent="4em"
space-before="2em"
space-after="1em"
end-indent="4em">First contained block
</fo:block>
<fo:block start-indent="4em"
space-after="2em"
end-indent="4em">Second contained block.
The significant border together with the indents
offsets the content,
seperating it visually from the main flow.
</fo:block>
</fo:block>
Example 5-11. A stylesheet snippet showing styling for a signature
<xsl:template match="signature">
<fo:block-container absolute-position="fixed"
top="240mm" left="100mm">
<fo:block xsl:use-attribute-sets="para">
Yours Sincerely: <xsl:apply-templates/>
</fo:block>
</fo:block-container>
</xsl:template>
Example 5-12. A title page specification
<fo:block
break-before="page"
break-after="page"
space-after="4in"
space-before="3in"
space-before.conditionality="retain"
font="24pt Times bold"
text-align="center">
Document Title, using single or multiple lines.
</fo:block>
Example 5-13. External graphics
<fo:block> <fo:external-graphic src='url(pig.jpg)'/> </fo:block>
<fo:block>
<fo:external-graphic
src="url(pig.jpg)"/>
</fo:block>
<fo:block>A block containing the graphic wrapped in
an inline container,
<fo:inline alignment-baseline="before-edge">
<fo:external-graphic
src="url(images/1.png)"/>
</fo:inline>
</fo:block>
Example 5-14. Titled images
<fo:block>
<fo:block>Title for the figure</fo:block>
<fo:external-graphic src="url(images/filename.ext)"/>
</fo:block>
Example 5-15. A cross-reference target
<xsl:template match="chapter">
<fo:block id="{@id}">
.....process content
</fo:block>
</xsl:template>
Example 5-16. Basic version of border specification
<xsl:attribute-set name='border'> <xsl:attribute name='border-before-style'>solid</xsl:attribute> <xsl:attribute name='border-after-style'>solid</xsl:attribute> <xsl:attribute name='border-start-style'>solid</xsl:attribute> <xsl:attribute name='border-end-style'>solid</xsl:attribute> <xsl:attribute name='border-before-width'>.1mm</xsl:attribute> <xsl:attribute name='border-after-width'>.1mm</xsl:attribute> <xsl:attribute name='border-start-width'>.1mm</xsl:attribute> <xsl:attribute name='border-end-width'>.1mm</xsl:attribute> </xsl:attribute-set>
Example 5-17. Using a simple border
<fo:block
border-style="solid"
border-width=".1mm"
width="2in">
A simple narrow border
</fo:block>
Example 5-18. A more complete border example
<fo:block
border-after-color="red"
border-after-style="outset"
border-after-width="1em"
border-before-color="blue"
border-before-style="outset"
border-before-width="1.5em"
border-end-color="silver"
border-end-style="outset"
border-end-width="2em"
border-start-color="green"
border-start-style="outset"
border-start-width="2em"
padding="6pt"
width="4in">
A paragraph with a completely specified border.
Style is shared as 'outset',
color varies on each edge,
as does width.
</fo:block>
Example 5-19. Specifying padding on a block
<fo:block space-before="18pt">A simple block with no padding. Note the proximity of the content to the page edge (the containing area). This may be too close when large blocks of text are used. </fo:block> <fo:block border ="thin black solid" padding-end="6pt" padding-start="6pt" text-align="justify">A simple block with padding specified as 6pt. Note the proximity of the content to the border (the containing area). This may be better when large blocks of text are used. A simple block with padding specified as 6pt. Note the proximity of the content to the border (the containing area). This may be better when large blocks of text are used. </fo:block>
Example 5-20. Basic list syntax
<fo:list-block> <fo:list-item> <fo:list-item-label> <fo:block>•</fo:block> </fo:list-item-label> <fo:list-item-body> <fo:block>List item contents.</fo:block> </fo:list-item-body> </fo:list-item> </fo:list-block>
Example 5-21. A simple nested list
<fo:list-block
start-indent="5mm"
provisional-distance-between-starts="10mm">
<fo:list-item>
<fo:list-item-label end-indent="label-end( )">
<fo:block>•</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start( )">
<fo:block>List item contents.</fo:block>
[1] <fo:list-block>
<fo:list-item>
<fo:list-item-label
end-indent="label-end( )">
<fo:block font-family="ZapfDingbats">➘
</fo:block>
</fo:list-item-label>
<fo:list-item-body
start-indent="body-start( )">
<fo:block>List item contents of nested list.
</fo:block>
</fo:list-item-body>
</fo:list-item>
[2] </fo:list-block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
Example 5-22. Varying the label length specification
<fo:list-block
start-indent="5mm"
provisional-distance-between-starts="40mm">
<fo:list-item space-after="1em">
<fo:list-item-label >
<fo:block
font-weight="bold">A long label which wraps.</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start( )" end-indent="5mm">
<fo:block>List item contents. Note the text flow which takes
place when sufficient text is placed to ensure wrapping.
Note the text flow which takes place when sufficient text
is placed to ensure wrapping.</fo:block>
</fo:list-item-body>
</fo:list-item>
<fo:list-item>
<fo:list-item-label >
<fo:block font-weight="bold">
Another long label which wraps.</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start( )">
<fo:block>Second content. </fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
Example 5-23. The simplest of table models
<table>
<tbody>
<row><td>R1C1</td><td>R1C2</td><td>R1C3</td></row>
<row><td>R2C1</td><td>R2C2</td><td>R2C3</td></row>
</tbody>
</table>
Example 5-24. Stylesheet snippet
<xsl:template match="table">
<fo:table width="3in">
<xsl:apply-templates/>
</fo:table>
</xsl:template>
<xsl:template match="tbody">
<fo:table-body>
<xsl:apply-templates/>
</fo:table-body>
</xsl:template>
<xsl:template match="row">
<fo:table-row>
<xsl:apply-templates/>
</fo:table-row>
</xsl:template>
<xsl:template match="td">
<fo:table-cell border="solid 1px black">
<fo:block><xsl:apply-templates/></fo:block>
</fo:table-cell>
</xsl:template>
Example 5-25. Proportional-width columns
<table-column column-width="proportional-column-width(1)"/> <table-column column-width="proportional-column-width(3)"/> <table-column column-width="proportional-column-width(1)"/>
Example 5-26. Fixed columns, variable width
<fo:table>
<fo:table-column column-label="1" column-width="20%"/>
<fo:table-column column-label="2" column-width="60%"/>
<fo:table-column column-label="3" column-width="20%"/>
... Remainder of table specification.
Example 5-27. Fixed columns, constant width
<fo:table>
<fo:table-column
column-label="1"
column-width="33%"
number-columns-repeated="3"/>
... Remainder of table specification.
Example 5-28. Row and column spanning
<fo:table-row>
<fo:table-cell border="solid black 1px"
border-collapse="collapse"
number-columns-spanned="2">
<fo:block>R2C1</fo:block>
</fo:table-cell>
<!-- R2C2 omitted-->
.... and for row 4,
<fo:table-row>
<fo:table-cell
border="solid black 1px"
border-collapse="collapse"
number-rows-spanned="2">
<fo:block>R4C1</fo:block>
</fo:table-cell>
... and for row 5
<fo:table-row>
<!-- R5C1 omitted -->
Example 5-29. Cell alignment
<fo:table-cell border="solid black 1px"
display-align="center"
border-collapse="collapse"
text-align="center">
<fo:block font-weight="bold">XXX</fo:block>
</fo:table-cell>
Example 5-30. Full form
space-before.minimum="4.0pt" space-before.optimum="4.0pt" space-before.maximum="4.0pt" space-before.precedence="0" space-before.conditionality="discard"
Example 6-1. Inline example, XML source
<para>Some base content, containing an inline warning, <emphasis role="warning">Do not touch blue paper</emphasis>, a fairly straightforward piece requiring emphasis <emphasis>TEXT</emphasis>, and some instructions which require presenting in a different way, such as <instruction>Now light the blue paper</instruction>. </para>
Example 6-2. Inline example, stylesheet snippet
<xsl:template match="para">
[1]<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="emphasis[@role='warning']">
[2]<fo:inline background-color="red">Warning:</fo:inline>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="emphasis[not(@role) or @role='']">
[3]<fo:inline font-weight="bold">
<xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="instruction">
[4]<fo:inline font-style="italic">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
Example 6-3. Text decoration
<fo:block text-decoration="underline">Underline on for all but one <fo:inline text-decoration="no-underline">word</fo:inline> of the sentence. </fo:block>
Example 6-4. Text shadow effect
<fo:block>
<fo:inline
text-shadow="red 1mm 1mm">
Text with a red shadow down and to the right by 1mm
.</fo:inline>
</fo:block>
Example 6-5. The use of fo:inline-container
<fo:block>
<fo:inline-container writing-mode="rl-tb">
<fo:block>
Some text with writing mode st to rl-tb.</fo:block>
</fo:inline-container>
</fo:block>
Example 6-6. An inline graphic
<fo:inline id="ls1">The main
<fo:external-graphic src="url(images/image.png)"/> is ....
</fo:inline>
Example 6-7. Scaled graphic
<fo:external graphic content-height="1em" content-width="1em" src="url(images/image.png)" />
Example 6-8. Letter spacing
<fo:inline letter-spacing="2mm">This is text with 2mm letter-spacing,</fo:inline> <fo:inline word-spacing="1cm"> this has 1cm word spacing.</fo:inline>
Example 6-9. Leaders for lines
<fo:block>
[1] <fo:leader
[2] leader-length="100%"
[3] leader-pattern="rule"
[4] rule-style="solid"
[5] rule-thickness="0.1mm" color="black"/>
</fo:block>
Example 6-10. Leader pattern example
<fo:leader leader-pattern="use-content" leader-length="60%">o</fo:leader>
Example 6-11. Table of contents usage
<fo:block text-align-last="justify">Chapter 10 <fo:leader leader-pattern="dots" />Page 25</fo:block>
Example 6-12. ID generation
<xsl:template match="p">
<fo:block>
<xsl:call-template name="gen-id">
<xsl:with-param name="id-val" select="@id"/>
</xsl:call-template>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template name="gen-id">
<xsl:param name="id-val" select="@id"/>
<xsl:if test="$id-val">
<xsl:attribute name="id"><xsl:value-of
select="$id-val"/></xsl:attribute>
</xsl:if>
</xsl:template>
Example 6-13. Cross-reference generation
<section id="sect1"> <head>Introduction</head> <p>A plain paragraph</p> <p id="referenced-para">A paragraph which is referenced, hence has the id value.</p>
Example 6-14. Source XML example
<p>See <link target="sect1"/> on page <pgref target="referenced-para"/>.</p>
Example 6-15. Link usage
<xsl:template match='section'>
<fo:block id='{@id}'>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match='para'>
<fo:block id='{generate-id( )}'>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="link">
<xsl:value-of select="id(@target)/head"/>
</xsl:template>
<xsl:template match="pgref">
<fo:page-number-citation ref-id="{@target}"/>
</xsl:template>
Example 6-16. Leaders for lists
<fo:inline>
<fo:character
character="•" font-family="ZapfDingbats"/> <fo:leader
leader-pattern="space"
leader-length="1.5cm"/> The list item contents</fo:inline>
Example 6-17. Stretchable spaces for three area headers
<fo:block text-align-last="justify">
<fo:inline> start1 </fo:inline>
<fo:inline> center </fo:inline>
<fo:inline> end </fo:inline>
</fo:block>
<fo:block text-align-last="justify">
<fo:inline letter-spacing="0pt" word-spacing="0pt"> start2 </fo:inline>
<fo:inline letter-spacing="0pt" word-spacing="0pt"> center </fo:inline>
<fo:inline letter-spacing="0pt" word-spacing="0pt"> end </fo:inline>
</fo:block>
<fo:block text-align-last="justify">
<fo:inline> start3 </fo:inline>
<fo:leader />
<fo:inline> center </fo:inline>
<fo:leader />
<fo:inline> end </fo:inline>
</fo:block>
<fo:block text-align-last="justify">
<fo:inline> start4 longer </fo:inline>
<fo:leader />
<fo:inline> center </fo:inline>
<fo:leader />
<fo:inline> end </fo:inline>
</fo:block>
<fo:list-block>
<fo:list-item>
<fo:list-item-label>
<fo:block id="A" text-align="left">start5</fo:block>
</fo:list-item-label>
<fo:list-item-body>
<fo:list-block>
<fo:list-item>
<fo:list-item-label>
<fo:block id="B" text-align="center">Center</fo:block>
</fo:list-item-label>
<fo:list-item-body>
<fo:block id="C" text-align="right">Right</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
Example 6-18. Header justification
<fo:inline text-align-last="justify">
Left-hand text
<fo:leader leader-pattern="space" />
Centre Text using inlines
<fo:leader leader-pattern="space" />
Right-hand text
</fo:inline>
Example 6-19. Lists in headers
<xsl:template name='head1'>
<xsl:param name='header-width'>
<fo:static-content flow-name="xsl-region-before">
<!-- header-width is the width of the full header in picas -->
<xsl:variable name="header-width" select="36"/>
<xsl:variable name="header-field-width">
<xsl:value-of select="$header-width * 0.3333"/><xsl:text>pc</xsl:text>
</xsl:variable>
<fo:list-block font-size="8pt" provisional-label-separation="0pt">
<xsl:attribute name="provisional-distance-between-starts">
<xsl:value-of select="$header-field-width"/>
</xsl:attribute>
<fo:list-item>
<fo:list-item-label end-indent="label-end( )">
<fo:block text-align="left">
<xsl:text>The left header field which is long </xsl:text>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start( )">
<fo:list-block provisional-label-separation="0pt">
<xsl:attribute name="provisional-distance-between-starts">
<xsl:value-of select="$header-field-width"/>
</xsl:attribute>
<fo:list-item>
<fo:list-item-label end-indent="label-end( )">
<fo:block text-align="center">
Page - <fo:page-number/>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start( )">
<fo:block text-align="right">
<xsl:text>short right</xsl:text>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:static-content>
</xsl:template>
Example 7-1. Graphics example
<fo:block>
<fo:block >Title for the figure</fo:block>
<fo:external-graphic
src="url(images/pig.jpg)"
[1] content-height="300%"
scaling="uniform"/>
</fo:block>
<fo:block>fo:external-graphic wrapped in a block, and</fo:block>
<fo:block>a block containing the graphic wrapped in
an inline container,
<fo:inline>
<fo:external-graphic src="url(images\1.png)"/>
</fo:inline>
with content both before and after the graphic.
</fo:block>
Example 7-2. Background and border colors
<fo:block background-color="aqua"
border-after-color="red"
border-after-width="1.2em"
border-before-color="blue"
border-before-width="1em"
border-end-color="silver"
border-end-width="1em"
border-start-color="green"
border-start-width="1em"
border-style="solid"
padding="6pt"
start-indent="1in"
end-indent="2in"
>
A paragraph with a completely specified border.
Style is not specified.
color varies on each edge</fo:block>
Example 7-3. Color and nesting
<fo:block
background-color="yellow" color="blue">
A paragraph with blue text on a yellow border.
Nested in the text are two inline objects, one of which
specifies a different 'color' and
one which specifies a different 'background-color' value.
Here is the
<fo:inline color='green'>green inline</fo:inline>.
And here is the
<fo:inline background-color='white'>white background inline
</fo:inline>. More text in the block after the inlines.</fo:block>
Example 7-4. Color profile example
<fo:declarations>
<fo:color-profile src="url('./myprofile.icc')" color-profile-name="cp1"/>
</fo:declarations>
<-- Intervening stuff -->
<fo:block color='icc-color(200, 200, 50, cp1, 1.45, 2.22)'>
A block whose text color is defined using the profile named cp1
</fo:block>
Example 8-1. A color-contrasted character
<fo:character
character="g"
font-size="20pt"
background-color="skyblue"
color="red"/>
Example 8-3. treat-as-word-space example
<fo:inline>Words with<fo:character
character=" "
treat-as-word-space="true"
/>spaces.
</fo:inline>
Example 8-4. Superscript
<fo:character
character="1"
baseline-shift="super"
font-size="8pt"
font-family="'MS Serif'"/>
Example 8-5. Character-level superscript
<fo:inline>See note
<fo:character
character="1"
baseline-shift="super"
font-family="'MS Serif'"/>
</fo:inline>
Example 8-7. Font style
<fo:inline
font-style="normal">This is normal.</fo:inline>
<fo:inline
font-style="italic">Italic.</fo:inline>
<fo:inline
font-style="oblique">Oblique.</fo:inline>
<fo:inline
font-style="backslant">Backslant.</fo:inline>
Example 8-10. Relative font changes
<fo:inline
font-size="smaller">Relative Specification of font size.</fo:inline>
Example 8-11. Attribute sets for font variants
<xsl:variable name="base-font">12</xsl:variable>
<xsl:attribute-set name="head1">
<xsl:attribute name="font-size"><xsl:value-of
select="concat(round($base-font *1.2),'pt')"/></xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="font-family">Helvetica</xsl:attribute>
....
<!-- other attributes as required. -->
</xsl:attribute-set>
Example 8-12. Attribute set usage
<fo:block
xsl:use-attribute-sets="head1"
keep-with-next.within-page="always">
<xsl:apply-templates/>
</fo:block>
Example 8-13. Percentage font-size change
<fo:block
font-size="10pt"
keep-with-next.within-page="always">
<fo:block font-size="80%"
<xsl:apply-templates/>
</fo:block>
</fo:block>
Example 8-14. Negating decorations
<fo:inline
text-decoration="line-through">Continuing,
<fo:inline
text-decoration="no-line-through">with
</fo:inline> font-weight bold
</fo:inline>
Example 9-1. A basic link
xml source
<para>...see the figure on page <link idref="fig53"/>
</para>
and the stylesheet
<xsl:template match="link">
<fo:basic-link background-color="lightblue"
internal-destination="{@idref}">Page
<fo:page-number-citation ref-id="intro"/>
</fo:basic-link>
</xsl:template>
Example 9-2. Cross-references using target content, XML source
<chapter>
<para>A link to <xref idref="ch2" />.
</para></chapter>
<chapter id="ch2">
<title>Second chapter</title>
</chapter>
Example 9-3. Cross-references using target content, XSLT stylesheet
<xsl:template match="chapter">
[1] <fo:block id="{@id}">
<xsl:apply-templates/></fo:block>
</xsl:template>
<xsl:template match="xref">
<fo:inline ><fo:basic-link
[2] internal-destination="{@idref}">
Chapter
[3] <xsl:for-each select="id(@idref)">
<xsl:number level="multiple" count="chapter" format="1 "/>
</xsl:for-each>,
<xsl:value-of select="id(@idref)/title"/>
on Page
<fo:page-number-citation ref-id="{@idref}"/>,
</fo:basic-link>
</fo:inline>
</xsl:template>
Example 9-4. Cross-references using target content, resulting FO
<fo:block font-family="Times"
font-size="12pt" space-before="12pt" space-after="12pt"
[4] text-align="justify">A link to <fo:inline>
<fo:basic-link
internal-destination="ch2">Chapter 2, Second chapter on Page
<fo:page-number-citation ref-id="ch2"/>, </fo:basic-link>
</fo:inline>.
</fo:block>
</fo:block>
Example 9-5. Source XML requiring a table of contents
<chapter><title>one </title> <section><title>one one </title></section> <section><title>one two </title></section> <section><title>one three </title></section> </chapter> <chapter><title>two </title> <section><title>two one</title></section> <section><title>two two</title></section> <section><title>two three, with a long title to show the effect of wrapping on long lines in this mode. Normal layout provides a reasonable solution</title></section> <section><title>two four</title></section> <section><title>two five</title></section> <section><title>two six</title></section>
Example 9-6. Table of contents stylesheet extract
<xsl:template match="chapter" mode="toc">
<fo:block text-align-last="justify">
<fo:inline><xsl:value-of select="title"/>
<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="{@id}"/>
</fo:inline>
</fo:block>
<xsl:apply-templates select="section" mode="toc"/>
</xsl:template>
<xsl:template match="section" mode="toc">
<fo:block text-align-last="justify"
text-indent="-1em" start-indent="1em">
<fo:inline padding-start="1em"><xsl:value-of select="title"/>
<fo:leader leader-pattern="dots" />
<fo:page-number-citation ref-id="{@id}"/>
</fo:inline>
</fo:block>
</xsl:template>
Example 9-7. Source XML
<para>This is a page layout using the
<term id="front-page">page </term> format....
....
<idx>
<item idref="front-page">Background Image</item>
<item idref="b">Bold</item>
<item idref="cen">Centered text</item>
<item idref="sect4">Columns</item>
</idx>
Example 9-8. Stylesheet for the index
<xsl:template match="idx">
<fo:block
start-indent="0.5in"
end-indent="0.5in"
font-size="{$base-font-spec}"
text-align-last="justify">
<fo:inline font-weight="bold">Item</fo:inline>
<fo:leader leader-pattern="dots"/>
<fo:inline font-weight="bold">Page</fo:inline>
</fo:block>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="idx/item">
<fo:block
start-indent="0.5in"
end-indent="0.5in"
font-size="{$base-font-spec}"
text-align-last="justify">
<xsl:apply-templates/>
<fo:leader leader-pattern="dots"/><fo:basic-link
internal-destination="{@idref}">
<fo:page-number-citation
color="blue" ref-id="{@idref}"/></fo:basic-link>
</fo:block>
</xsl:template>
Example 9-10. Marker usage
<xsl:template match="chapter/title">
<fo:block xsl:use-attribute-sets="head1"
break-before="page">
<fo:marker marker-class-name="sect-head" >
<fo:block><xsl:value-of select="."/>
</fo:block>
</fo:marker>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
Example 9-11. Retrieve marker usage in a header
<fo:static-content
flow-name="xsl-region-head">
<fo:block>
<fo:retrieve-marker
retrieve-class-name="sect-head"/>
</fo:block>
</fo:static-content>
Example 9-12. Footnote example, source XML
<para> the bicameral<footnote>The Latin alphabet, which you are reading, is an example of a bicameral font; it has an uppercase and lowercase. Unicameral alphabets (the Arabic and Hebrew alphabets) only have one case.</footnote> font presents us with two forms of presentation..</para>
Example 9-13. Footnote example, the transformation
(In the appropriate page-sequence-master)
<fo:static-content
[1] flow-name="xsl-footnote-separator">
<fo:block text-align-last="justify">
<fo:leader leader-pattern="rule"/>
</fo:block>
</fo:static-content>
<xsl:template match='para'>
<fo:block><xsl:apply-templates/></fo:block>
</xsl:template>
<xsl:template match='footnote'>
<fo:footnote>
[2] <fo:inline>1</fo:inline>
<fo:footnote-body>
[3] <fo:block text-align-last="justify">
<fo:leader leader-pattern="rule"/>
</fo:block>
<fo:list-block>
<fo:list-item>
<fo:list-item-label end-indent="label-end( )">
[4] <fo:block>1</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start( )">
[5] <fo:block><xsl:apply-templates/></fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:footnote-body>
</fo:footnote>
</xsl:template>
Example 9-14. Footnote example, the resulting FO
<fo:block>the bicameral font presents us with two forms of presentation
<fo:footnote>
<fo:inline>1</fo:inline>
<fo:footnote-body>
<fo:list-block>
<fo:list-item>
<fo:list-item-label end-indent="label-end( )">
<fo:block>1</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start( )">
<fo:block>The Latin
alphabet, which you are reading, is an example of a
bicameral font; it has an uppercase and
lowercase. Unicameral alphabets (the Arabic and Hebrew
alphabets) only have one case.</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:footnote-body>
</fo:footnote>
font presents us with two forms of presentation..
</fo:block>
Example 10-1. Flow contents for the first three pages
<fo:page-sequence master-reference="first3">
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates select="/book/frontmatter/title"/>
<xsl:apply-templates select="/book/frontmatter/dedication"/>
<xsl:call-template name="tPage"/>
</fo:flow>
</fo:page-sequence>
Example 10-2. Preface and table of contents flow
<fo:page-sequence
master-reference="prefAndToc"
[1]initial-page-label="1"
[2]format="I">
[3] <fo:static-content
flow-name="xsl-region-after">
<fo:block text-align="outer"><fo:page-number/></fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates select="/book/frontmatter/preface"/>
<xsl:apply-templates select="/" mode="toc"/>
</fo:flow>
</fo:page-sequence>
Example 10-3. Chapter page-sequence
<fo:page-sequence
master-reference="chaps"
initial-page-label="1"
[1] format="1">
<fo:static-content
flow-name="xsl-region-before">
[2] <fo:block text-align="outside">
Chapter <fo:retrieve-marker
[3] retrieve-class-name="chapNum"/>
<fo:leader leader-pattern="space" />
<fo:retrieve-marker
[4] retrieve-class-name="chap"/>
<fo:leader leader-pattern="space" />
[5] Page <fo:page-number font-style="normal" />
[6] of <fo:page-number-citation ref-id='end'/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block xsl:use-attribute-sets='font'>
<xsl:apply-templates select="/book/bodymatter"/>
<xsl:apply-templates select="/book/rearmatter"/>
</fo:flow>
</fo:page-sequence>
Example 10-4. The default template
<xsl:template match="*">
[1] <fo:block color="red">
Element <xsl:value-of
select="name(..)"/>/ <xsl:value-of
select="name( )"/> found, with no template.
</fo:block>
</xsl:template>
Example 10-5. Template for the front page
<xsl:template name="tPage">
<fo:block xsl:use-attribute-sets='font'>
<fo:block
font-size='36pt'
space-before = '50mm'
space-after = '25mm'
><xsl:value-of select='/book/title'/>
</fo:block>
<fo:block
font-size='18pt'
space-before = '25mm'
space-after = '12mm'
>by </fo:block>
<fo:block
font-size='18pt'
space-before = '25mm'
space-after = '12mm'>
<xsl:value-of select='/book/frontmatter/author'/>
</fo:block>
</fo:block>
<fo:block text-align='end'
font-size='10pt'
space-before = '50mm'>
© <xsl:value-of
select="/book/frontmatter/pubdetails/pubname"/>
</fo:block>
<fo:block text-align='end'
font-size='10pt'>
<xsl:value-of
select="/book/frontmatter/pubdetails/pubads"/>
</fo:block>
</xsl:template>
Example 10-6. Fancy title page template
<xsl:template match='/' mode='ffp'>
<fo:block break-before="odd-page" >
<fo:block
xsl:use-attribute-sets="title font"
space-after="20mm">
[1] <xsl:value-of select='/book/title'/>
</fo:block>
<fo:table width='130mm'>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block>
<fo:external-graphic
src="images\ttlpg.jpg"
[2] content-height="100%"
scaling="uniform"/>
</fo:block>
</fo:table-cell>
<fo:table-cell display-align='bottom'>
<fo:block/>
<fo:block space-before='90mm'>
[3] © <xsl:value-of
select='/book/frontmatter/pubdetails/pubname'/>
</fo:block>
<fo:block>
<xsl:value-of
select='/book/frontmatter/pubdetails/pubads'/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:block
font-size='{$small-sz}'>Image courtesy of Aries Cheung, Toronto
</fo:block>
</fo:block>
</xsl:template>
Example 10-7. Table of contents template
<xsl:template match="/" mode="toc">
<fo:block break-before="odd-page" >
<fo:block xsl:use-attribute-sets="title font">
[1] Table of Contents
</fo:block>
<xsl:for-each select='book/frontmatter/preface'>
<fo:block text-align-last="justify">
<fo:inline><xsl:value-of select="title"/>
<fo:leader leader-pattern="dots"/>
[2] <fo:page-number-citation ref-id="{generate-id
</fo:inline>
</fo:block>
</xsl:for-each>
[3]<xsl:for-each select='book/bodymatter/chapter'>
<fo:block text-align-last="justify">
<fo:inline><xsl:value-of select="title"/>
<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="{generate-id( )}"/>
</fo:inline>
</fo:block>
</xsl:for-each>
[4]<xsl:for-each select='book/rearmatter/appendix'>
<fo:block text-align-last="justify">
<fo:inline><xsl:value-of select="title"/>
<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="{generate-id( )}"/>
</fo:inline>
</fo:block>
</xsl:for-each>
</fo:block>
</xsl:template>
Example 11-1. Unexpected element processing
<xsl:template match="*">
<xsl:message>
<xsl:value-of select="name(.)"/>
<xsl:text> with no styling.</xsl:text>
</xsl:message>
<fo:block color="red" >
<xsl:text>
<xsl:value-of select="name(..)"/>/<xsl:value-of select="name(.)"/>
</xsl:text>
</fo:block>
</xsl:template>
Example 11-2. Use of entities in a stylesheet
<?xml version="1.0" ?> <!DOCTYPE xsl:stylesheet [ <!ENTITY lms SYSTEM "lms.xml"> ]> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0"> <fo:root> <-- Include the layout-master-set --> &lms; ......
Example 11-3. Selecting content for flows
<fo:page-sequence
master-name="rest">
<xsl:call-template name="page-sequence">
<xsl:with-param
name="head-R">Page <fo:page-number/> </xsl:with-param>
<xsl:with-param name="foot-L">Chapter title</xsl:with-param>
</xsl:call-template>
<fo:flow flow-name="xsl-region-body">
<xsl:comment>2D</xsl:comment>
<!-- Process section contents -->
<xsl:apply-templates select="simpdoca/section[@id='chap03']" />
</fo:flow>
</fo:page-sequence>
Example A-1. Fixed-position blocks
<fo:block-container
[1] absolute-position="fixed"
[2] top="200mm">
<fo:block>Yours sincerely:
<fo:inline font-style="italic">Dave Pawson</fo:inline>
</fo:block>
</fo:block-container>
Example F-1. Initial layout
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<!-- spm for first 3 pages -->
[1] <fo:simple-page-master master-name="first3"
page-height="29.7cm"
page-width="21cm"
margin-top="1in"
margin-bottom="2in"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body
padding-start="1cm"
padding-end="1cm"
margin-top="0.6in"
margin-bottom="0.6in"
margin-left="0.7in"
margin-right="0.5in"/>
</fo:simple-page-master>
[2] <!-- No headers or footers required -->
<!-- spm for preface and toc -->
<fo:simple-page-master master-name="prefAndToc"
page-height="29.7cm"
page-width="21cm"
margin-top="1in"
margin-bottom="1.5in"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body
padding-start="1cm"
padding-end="1cm"
margin-top="0.6in"
margin-bottom="0.6in"
margin-left="0.7in"
margin-right="0.5in"/>
<fo:region-before
extent ="0.5in"/> <!-- Height of the region -->
[3]
<fo:region-after
extent ="0.5in"/> <!-- Height of region -->
</fo:simple-page-master>
<!-- spm for main chapters, odd pages -->
[4] <fo:simple-page-master master-name="chapsOdd"
page-height="29.7cm"
page-width="21cm"
margin-top="1in"
margin-bottom="0.7in"
[5] margin-left="1.5cm"
margin-right="2.5cm">
<fo:region-body
[6] border-color="red"
border-style="solid"
border-width="1pt"
padding-end="3mm"
padding-start="1mm"
margin-bottom="0.5in"
margin-top="1in"
margin-left="15mm"
margin-right="15mm"/>
<fo:region-before
border-color="red"
border-style="solid"
border-width="1pt"
extent ="0.7in"/> <!-- Height of the region -->
<fo:region-after
border-color="red"
border-style="solid"
border-width="1pt"
extent ="0.4in"/> <!-- Height of region -->
</fo:simple-page-master>
<!-- spm for main chapters, even pages -->
[7] <fo:simple-page-master master-name="chapsEven"
page-height="29.7cm"
page-width="21cm"
margin-top="1in"
margin-bottom="0.7in"
margin-left="2.5cm"
margin-right="1.5cm">
<fo:region-body
border-color="red"
border-style="solid"
border-width="1pt"
padding-end="3mm"
padding-start="1mm"
margin-bottom="0.5in"
margin-top="1in"
margin-left="15mm"
margin-right="15mm"/>
<fo:region-before
border-color="red"
border-style="solid"
border-width="1pt"
extent ="0.7in"/> <!-- Height of the region -->
<fo:region-after
border-color="red"
border-style="solid"
border-width="1pt"
extent ="0.4in"/> <!-- Height of region -->
</fo:simple-page-master>
<!-- Control the sequencing for odd and even pages in chapters -->
[8] <fo:page-sequence-master master-name="chaps">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference
master-reference="chapsOdd"
odd-or-even="odd" />
<fo:conditional-page-master-reference
[9] master-reference="chapsEven"
odd-or-even="even" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<!-- page-sequence for first 3 pages -->
[10] <fo:page-sequence master-reference="first3">
<fo:flow flow-name="xsl-region-body">
<fo:block break-after="page">Front page</fo:block>
<fo:block break-after="page">Dedication page</fo:block>
<fo:block break-after="page">Title page</fo:block>
</fo:flow>
</fo:page-sequence>
<!-- Page sequence for preface and toc -->
[11] <fo:page-sequence master-reference="prefAndToc">
<fo:static-content
flow-name="xsl-region-after">
<fo:block>Preface and toc footer with roman page numbers</fo:block>
</fo:static-content>
[12] flow-name="xsl-region-before">
<fo:flow flow-name="xsl-region-body">
<fo:block break-after="page">Preface</fo:block>
<fo:block break-after="page">Table of contents 1</fo:block>
<fo:block break-after="page">Table of contents 2</fo:block>
</fo:flow>
</fo:page-sequence>
<!-- Page sequence for all chapters -->
<fo:page-sequence master-reference="chaps">
<fo:static-content
<fo:block>Chapter header with Arabic page numbers</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block break-after="page">chapter odd page</fo:block>
<fo:block break-after="page">chapter even pages</fo:block>
<fo:block break-after="page">chapter odd pages</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Example F-2. Source document outline
<book>
<title>Book title</title>
[1]<frontmatter>
<author>A.N. Author</author>
<dedication>
<para>Dedication to all the people
who wrote this book for me.</para>
</dedication>
<pubdetails>
<pubname>A Publisher</pubname>
<pubads>London, 2001 </pubads>
</pubdetails>
<preface>
<title>Preface</title>
<para>First para of preface</para>
<para>Second para of preface</para>
</preface>
</frontmatter>
[2] <bodymatter>
<chapter>
<title>Introduction and first chapter title</title>
<para>Content in the first chapter.
Additional paragraphs are necessary to check for
inter-paragraph spacing and layout. </para>
<para>Content in the first chapter.
Additional paragraphs are necessary to check for
inter-paragraph spacing and layout. </para>
</chapter>
<chapter>
<title>chapter 2 title</title>
<para>Content </para>
</chapter>
<chapter>
<title>Chapter 3 title</title>
<para>Content </para>
</chapter>
<chapter>
<title>Chapter n +2</title>
<para>Content </para>
</chapter>
<chapter>
<title>Chapter n +3</title>
<para>Content </para>
</chapter>
<chapter>
<title>Chapter n +4</title>
<para>Content </para>
</chapter>
<chapter>
<title>Chapter n +5</title>
<para>Content </para>
</chapter>
<chapter>
<title>Chapter n +6</title>
<para>Content </para>
</chapter>
<chapter>
<title>Chapter n +7</title>
<para>Content </para>
</chapter>
<chapter>
<title>Chapter n +8</title>
<para>Content </para>
</chapter>
</bodymatter>
[3]<rearmatter>
<appendix>
<title>Appendix title</title>
<para>content</para>
</appendix>
</rearmatter>
</book>
Example F-3. Main stylesheet
<?xml version="1.0" ?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY sp "<xsl:text> </xsl:text>">
]>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:import href="pl.xsl"/>
<xsl:import href='ps.xsl'/>
<xsl:template match="book">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="frontmatter">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="author">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="frontmatter/title">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template name="tPage">
<fo:block xsl:use-attribute-sets='font'>
<fo:block
font-size='36pt'
space-before = '50mm'
space-after = '25mm'
><xsl:value-of select='/book/title'/>
</fo:block>
<fo:block
font-size='18pt'
space-before = '25mm'
space-after = '12mm'
>by </fo:block>
<fo:block
font-size='18pt'
space-before = '25mm'
space-after = '12mm'>
<xsl:value-of select='/book/frontmatter/author'/>
</fo:block>
</fo:block>
<fo:block text-align='end'
font-size='10pt'
space-before = '60mm'>
© <xsl:value-of
select="/book/frontmatter/pubdetails/pubname"/>
</fo:block>
<fo:block text-align='end'
font-size='10pt' >
<xsl:value-of select="/book/frontmatter/pubdetails/pubads"/>
</fo:block>
</xsl:template>
<xsl:template match="dedication">
<fo:block break-before='page'>
<fo:block xsl:use-attribute-sets="title font">
Dedication.
</fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match='/' mode='ffp'>
<fo:block break-before="odd-page" >
<fo:block xsl:use-attribute-sets="title font"
space-after="20mm">
<xsl:value-of select='/book/title'/>
</fo:block>
<fo:table width='130mm'>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block>
<fo:external-graphic
src="images\ttlpg.jpg"
content-height="100%"
scaling="uniform"/>
</fo:block>
</fo:table-cell>
<fo:table-cell display-align='bottom'>
<fo:block/>
<fo:block space-before='90mm'>
© <xsl:value-of
select='/book/frontmatter/pubdetails/pubname'/>
</fo:block>
<fo:block>
<xsl:value-of
select='/book/frontmatter/pubdetails/pubads'/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:block font-size='{$small-sz}'>Image courtesy of
Aries Cheung, Toronto</fo:block>
</fo:block>
</xsl:template>
<xsl:template match="preface">
<fo:block id='{generate-id( )}'>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="preface/title">
<fo:block xsl:use-attribute-sets="title font">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="/" mode="toc">
<fo:block break-before="odd-page" >
<fo:block xsl:use-attribute-sets="title font">
Table of Contents
</fo:block>
<xsl:for-each select='book/frontmatter/preface'>
<fo:block text-align-last="justify">
<fo:inline><xsl:value-of select="title"/>
<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="{generate-id( )}"/>
</fo:inline>
</fo:block>
</xsl:for-each>
<xsl:for-each select='book/bodymatter/chapter'>
<fo:block text-align-last="justify">
<fo:inline><xsl:value-of select="title"/>
<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="{generate-id( )}"/>
</fo:inline>
</fo:block>
</xsl:for-each>
<xsl:for-each select='book/rearmatter/appendix'>
<fo:block text-align-last="justify">
<fo:inline><xsl:value-of select="title"/>
<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="{generate-id( )}"/>
</fo:inline>
</fo:block>
</xsl:for-each>
</fo:block>
</xsl:template>
<xsl:template match="bodymatter|rearmatter">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="chapter">
<fo:block break-before="odd-page" id='{generate-id( )}'>
<fo:marker marker-class-name="chap">
<xsl:value-of select="title"/>
</fo:marker>
<fo:marker marker-class-name="chapNum">
<xsl:number count="chapter" level="any" from="bodymatter"/>
</fo:marker>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="chapter/title">
<fo:block/>
<fo:block xsl:use-attribute-sets="title font">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="appendix">
<fo:block id='{generate-id( )}'>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="appendix/title">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<!-- minor templates -->
<xsl:template match="para">
<fo:block xsl:use-attribute-sets="para font">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="*">
<fo:block color="red">
***************** Element <xsl:value-of
select="name(..)"/>/ <xsl:value-of
select="name( )"/> found, with no template. ****************
</fo:block>
</xsl:template>
</xsl:stylesheet>
Example F-4. File ps.xsl, the property sets
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY sp "<xsl:text> </xsl:text>">
]>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:variable name='base-font-size' select='12'/>
<xsl:variable name='title-font-size' select='$base-font-size * 1.5'/>
<xsl:variable name='head-font-size' select='$base-font-size * 1.2'/>
<xsl:variable name='small-font-size' select='$base-font-size div 2'/>
<xsl:variable name='base-sz' select= 'concat ($base-font-size,"pt")'/>
<xsl:variable name='title-sz' select= 'concat ($title-font-size,"pt")'/>
<xsl:variable name='head-sz' select= 'concat ($head-font-size,"pt")'/>
<xsl:variable name='small-sz' select= 'concat ($small-font-size,"pt")'/>
<xsl:attribute-set name='font'> <!-- Font family -->
<xsl:attribute
name='font-family'>'Arial' 'Helvetica' Serif</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="title"
use-attribute-sets="font ">
<xsl:attribute name="font-size">
<xsl:value-of select="$title-sz"/>
</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="font-style">normal</xsl:attribute>
<xsl:attribute name="space-before.optimum">
<xsl:value-of select="$title-sz"/>
</xsl:attribute>
<xsl:attribute
name="space-before.conditionality">retain</xsl:attribute>
<xsl:attribute name="space-after.optimum">
<xsl:value-of select="$small-sz"/>
</xsl:attribute>
<xsl:attribute name="keep-with-next">true</xsl:attribute>
<xsl:attribute name="page-break-inside">avoid</xsl:attribute>
<xsl:attribute name="text-align">center</xsl:attribute>
<xsl:attribute name="background-color">white</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name='pad'>
<xsl:attribute name='padding'>
<xsl:value-of select="$small-sz"/>
</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name='border'>
<xsl:attribute name='border-before-style'>solid'</xsl:attribute>
<xsl:attribute name='border-after-style'>solid'</xsl:attribute>
<xsl:attribute name='border-start-style'>solid'</xsl:attribute>
<xsl:attribute name='border-end-style'>solid'</xsl:attribute>
<xsl:attribute name='border-before-width'>.1mm"</xsl:attribute>
<xsl:attribute name='border-after-width'>.1mm"</xsl:attribute>
<xsl:attribute name='border-start-width'>.1mm"</xsl:attribute>
<xsl:attribute name='border-end-width'>.1mm"</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="para"
use-attribute-sets='font '>
<xsl:attribute name="space-before.optimum">
<xsl:value-of select="$base-sz"/>
</xsl:attribute>
<xsl:attribute name="space-after.optimum">
<xsl:value-of select="$base-sz"/>
</xsl:attribute>
</xsl:attribute-set>
</xsl:stylesheet>
Example F-5. Page layout stylesheet
<?xml version="1.0" ?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY lms SYSTEM "lms.xml">
]>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<!-- Time-stamp: "2000-12-22 11:30:45 dave" -->
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<!-- spm for first 3 pages -->
<fo:simple-page-master master-name="first3"
page-height="29.7cm"
page-width="21cm"
margin-top="1in"
margin-bottom="2in"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body
padding-start="1cm"
padding-end="1cm"
margin-top="0.6in"
margin-bottom="0.6in"
margin-left="0.7in"
margin-right="0.5in"/>
</fo:simple-page-master>
<!-- No headers or footers required -->
<!-- spm for preface and toc -->
<fo:simple-page-master master-name="prefAndToc"
page-height="29.7cm"
page-width="21cm"
margin-top="1in"
margin-bottom="1.5in"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body
padding-start="1cm"
padding-end="1cm"
margin-top="0.6in"
margin-bottom="0.6in"
margin-left="0.7in"
margin-right="0.5in"/>
<fo:region-before
extent ="0.5in"/> <!-- Height of the region -->
<fo:region-after
extent ="0.5in"/> <!-- Height of region -->
</fo:simple-page-master>
<!-- spm for main chapters, odd pages -->
<fo:simple-page-master master-name="chapsOdd"
page-height="29.7cm"
page-width="21cm"
margin-top="1in"
margin-bottom="0.7in"
margin-left="1.5cm"
margin-right="2.5cm">
<!--
border-color="red"
border-style="solid"
border-width="1pt"
-->
<fo:region-body
padding-end="3mm"
padding-start="1mm"
margin-bottom="0.5in"
margin-top="1in"
margin-left="15mm"
margin-right="15mm"/>
<fo:region-before
extent ="0.7in"/> <!-- Height of the region -->
<!--
border-color="red"
border-style="solid"
border-width="1pt"
-->
<fo:region-after
extent ="0.4in"/> <!-- Height of region -->
<!--
border-color="red"
border-style="solid"
border-width="1pt"
-->
</fo:simple-page-master>
<!-- spm for main chapters, even pages -->
<fo:simple-page-master master-name="chapsEven"
page-height="29.7cm"
page-width="21cm"
margin-top="1in"
margin-bottom="0.7in"
margin-left="2.5cm"
margin-right="1.5cm">
<fo:region-body
padding-end="3mm"
padding-start="1mm"
margin-bottom="0.5in"
margin-top="1in"
margin-left="15mm"
margin-right="15mm"/>
<!-- border-color="red"
border-style="solid"
border-width="1pt" -->
<fo:region-before
extent ="0.7in"/> <!-- Height of the region -->
<!-- border-color="red"
border-style="solid"
border-width="1pt"
-->
<fo:region-after
extent ="0.4in"/> <!-- Height of region -->
<!-- border-color="red"
border-style="solid"
border-width="1pt"
-->
</fo:simple-page-master>
<!-- Control the sequencing for odd and even pages in chapters -->
<fo:page-sequence-master master-name="chaps">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference
master-reference="chapsOdd"
odd-or-even="odd" />
<fo:conditional-page-master-reference
master-reference="chapsEven"
odd-or-even="even" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<!-- page-sequence for first 3 pages -->
<fo:page-sequence master-reference="first3">
<fo:flow flow-name="xsl-region-body">
<xsl:call-template name="tPage"/>
<xsl:apply-templates select="/book/frontmatter/dedication"/>
<xsl:apply-templates select="/" mode="ffp"/>
</fo:flow>
</fo:page-sequence>
<!-- Page sequence for preface and toc -->
<fo:page-sequence
master-reference="prefAndToc"
initial-page-label="F" format="I">
<fo:static-content
flow-name="xsl-region-after">
<fo:block text-align="outside"><fo:page-number/></fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates select="/book/frontmatter/preface"/>
<xsl:apply-templates select="/" mode="toc"/>
</fo:flow>
</fo:page-sequence>
<!-- Page sequence for all chapters -->
<fo:page-sequence master-reference="chaps">
<fo:static-content
flow-name="xsl-region-before">
<fo:block text-align="outside"
xsl:use-attribute-sets='para font pad'>
Chapter <fo:retrieve-marker retrieve-class-name="chapNum"/>
<fo:leader leader-pattern="space" />
<fo:retrieve-marker retrieve-class-name="chap"/>
<fo:leader leader-pattern="space" />
Page <fo:page-number
font-style="normal" /> of <fo:page-number-citation
ref-id='end'/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block xsl:use-attribute-sets='font'>
<xsl:apply-templates select="/book/bodymatter"/>
<xsl:apply-templates select="/book/rearmatter"/>
</fo:block>
<fo:block id='end'/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>