CONTENTS |
<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>
simple page model for first three pages. All pages follow this model.
No footers or headers.
Only the footer is needed, the header is included to keep the balance.
Specification for odd pages.
One-centimeter difference between odd and even pages, swapped for the even pages.
Borders will be removed for use. Inclusion allows the three areas to be viewed without content.
Main chapters, even pages specification.
Need to alternatively select odd and even pages, depending on the parity of the page number.
Select the even simple page model.
First flow. No headers, simple text content to ensure it works as expected. This will be replaced by templates.
Same for all areas, some temporary content is included to check that the layout works.
This will be replaced by retrieve-markers and page-number elements.
<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>
Front matter
Body matter
Rear matter
<?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>
<?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-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>
<?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>
CONTENTS |