Dear Tim, et.al.,
I'm doing the same as you for our newsletter - wanting to
change the heading when a new chapter is started. I achieve
this by starting a new <fo:page-sequence ...> for each
chapter containing a <fo:static-content
flow-name="xsl-region-before"> containing the title.
I've attached by XSL file. It's in the template for chapter
(in body).
Any comments gratefully received.
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- XML -> PDF for UKUUG newsletter
0.0.0 Initial implementation (mick, 23 Jan 2001)
0.1.0 Restructure based on RenderX tutorial (mick, 16 Feb 2001)
0.1.1 Internal links added (mick, 21 Feb 2001)
-->
<xsl:stylesheet version="1.0"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- top-level newsletter -> title
chapter+
-->
<xsl:template match="/newsletter">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<!-- layout for the first page (toc) -->
<fo:simple-page-master margin-bottom="0.5in"
margin-left="0.75in"
margin-right="0.75in"
margin-top="0.5in"
master-name="toc"
page-height="11.7in"
page-width="8.3in">
<fo:region-after extent="0.75in"/>
<fo:region-before extent="1.5in"/>
<fo:region-body margin-bottom="0.75in"
margin-top="1.45in"/>
</fo:simple-page-master>
<!-- layout for the remaining pages (chapters) -->
<fo:simple-page-master margin-bottom="0.5in"
margin-left="0.75in"
margin-right="0.75in"
margin-top="0.5in"
master-name="chapters"
page-height="11.7in"
page-width="8.3in">
<fo:region-after extent="0.75in"/>
<fo:region-before extent="1.5in"/>
<fo:region-body column-count="2"
column-gap="0.25in"
margin-bottom="0.75in"
margin-top="0.5in"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="newsletter">
<fo:single-page-master-reference master-name="toc"/>
<fo:repeatable-page-master-reference master-name="chapters"/>
</fo:page-sequence-master>
</fo:layout-master-set>
<xsl:call-template name="toc"/>
<xsl:apply-templates select="chapter"/>
</fo:root>
</xsl:template>
<!-- article (in body) -> (@book | @letter | @news | @software)
author?
section+
-->
<xsl:template match="article">
<xsl:variable name="article">
<xsl:number count="chapter"/>
<xsl:number count="article"/>
</xsl:variable>
<fo:block id="{$article}"/>
<xsl:choose>
<xsl:when test="@type='book' or @type='software'">
<xsl:apply-templates select="book|software"/>
</xsl:when>
<!-- @type='letter' has no header -->
<xsl:when test="@type='news'">
<fo:block font-size="16pt"
font-weight="bold"
line-height="18pt"
text-align="start">
<xsl:apply-templates select="title"/>
</fo:block>
</xsl:when>
</xsl:choose>
<xsl:if test="author and @type!='letter'">
<fo:block font-size="14pt"
font-weight="bold"
line-height="16pt"
space-before="16pt"
text-align="start">
(<xsl:if test="@type='book' or @type='software'">Reviewed by
</xsl:if>
<xsl:apply-templates select="author"/>)
</fo:block>
</xsl:if>
<xsl:apply-templates select="section"/>
<xsl:apply-templates select="id(author/@id)/biography"/>
<xsl:if test="position()!=last()">
<fo:block space-after="12pt"
space-before="12pt">
<fo:leader leader-length="3.25in"
leader-pattern="rule"/>
</fo:block>
</xsl:if>
</xsl:template>
<!-- article (in toc) -> @book/title
| @letter/author
| @software/title
| title
-->
<xsl:template match="article"
mode="toc">
<xsl:variable name="article">
<xsl:number count="chapter"/>
<xsl:number count="article"/>
</xsl:variable>
<fo:table>
<fo:table-column column-width="6.5in"/>
<fo:table-column column-width="10pt"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block font-size="10pt"
font-weight="normal"
id="toc{$article}"
line-height="12pt"
start-indent="18pt"
text-align="justify">
<fo:basic-link internal-destination="{$article}">
<xsl:choose>
<xsl:when test="@type='book' or @type='software'">
<xsl:apply-templates select="book/title|software/title"/>
</xsl:when>
<xsl:when test="@type='letter'">
From <xsl:apply-templates mode="toc"
select="author"/>
</xsl:when>
<xsl:when test="@type='news'">
<xsl:apply-templates select="title"/>
</xsl:when>
</xsl:choose>
</fo:basic-link>
<fo:leader leader-pattern="dots"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="10pt"
font-weight="normal"
text-align="end">
<fo:page-number-citation ref-id="{$article}"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:template>
<!-- author -> @id
-->
<xsl:template match="author">
<xsl:apply-templates select="id(@id)/name"/>
</xsl:template>
<!-- author (in toc) -> in-line entities
-->
<xsl:template match="author"
mode="toc">
<xsl:apply-templates/>
</xsl:template>
<!-- biography -> (in-line entity | render)+
-->
<xsl:template match="biography">
<fo:block font-size="8pt"
font-style="italic"
line-height="10pt"
space-before="10pt"
text-align="justify">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<!-- book -> @isbn
title
author?
publisher?
date?
pages?
price?
-->
<xsl:template match="book">
<fo:block font-size="14pt"
font-weight="bold"
line-height="18pt"
text-align="start">
<xsl:apply-templates select="title"/>
</fo:block>
<fo:block font-size="12pt"
font-weight="bold"
line-height="14pt"
text-align="start">
<xsl:apply-templates mode="toc"
select="author"/>
</fo:block>
<fo:block font-size="12pt"
font-weight="bold"
line-height="14pt"
text-align="start">
<xsl:apply-templates select="publisher"/>
<xsl:if test="publisher and date">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:apply-templates select="date"/>
</fo:block>
<fo:block font-size="12pt"
font-weight="bold"
line-height="14pt"
text-align="start">
<xsl:if test="pages">
<xsl:apply-templates select="pages"/>
pages<xsl:if test="price">,</xsl:if>
</xsl:if>
<xsl:if test="price">
<xsl:apply-templates select="price"/>
</xsl:if>
</fo:block>
<fo:block font-size="12pt"
font-weight="bold"
line-height="14pt"
text-align="start">
ISBN <xsl:value-of select="@isbn"/>
</fo:block>
</xsl:template>
<!-- chapter (in body) -> title
article+
-->
<xsl:template match="chapter">
<xsl:variable name="chapter">
<xsl:number count="chapter"/>
</xsl:variable>
<fo:page-sequence master-name="chapters">
<fo:static-content flow-name="xsl-region-before">
<fo:block font-size="18pt"
font-weight="bold"
text-align="center">
<xsl:apply-templates select="title"/>
</fo:block>
<fo:block>
<fo:leader leader-length="6.8in"
leader-pattern="rule"/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:block>
<fo:leader leader-length="6.8in"
leader-pattern="rule"/>
</fo:block>
<fo:block font-size="10pt"
text-align="center">
<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block id="{$chapter}">
<xsl:apply-templates select="article"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</xsl:template>
<!-- chapter (in toc) -> title
article+
-->
<xsl:template match="chapter"
mode="toc">
<xsl:variable name="chapter">
<xsl:number count="chapter"/>
</xsl:variable>
<fo:block font-size="12pt"
font-weight="bold"
line-height="14pt"
space-before="12pt"
text-align="start">
<fo:basic-link internal-destination="{$chapter}">
<xsl:apply-templates select="title"/>
</fo:basic-link>
<xsl:apply-templates mode="toc"
select="article"/>
</fo:block>
</xsl:template>
<!-- details -> @id
@type?
-->
<xsl:template match="details">
<fo:block>
<xsl:apply-templates select="id(@id)/name"/>
<xsl:if test="id(@id)/title">
(<xsl:apply-templates select="id(@id)/title"/>)
</xsl:if>
</fo:block>
<xsl:if test="@type='full'">
<xsl:for-each select="id(@id)/address">
<fo:block>
<xsl:apply-templates select="."/>
</fo:block>
</xsl:for-each>
<fo:block>
<xsl:apply-templates select="id(@id)/postcode"/>
</fo:block>
</xsl:if>
<xsl:if test="id(@id)/phone">
<fo:block>
Phone: <xsl:apply-templates select="id(@id)/phone"/>
</fo:block>
</xsl:if>
<xsl:if test="@type='full'">
<xsl:if test="id(@id)/fax">
<fo:block>
Fax: <xsl:apply-templates select="id(@id)/fax"/>
</fo:block>
</xsl:if>
</xsl:if>
<xsl:if test="id(@id)/email">
<fo:block>
E-mail: <xsl:apply-templates select="id(@id)/email"/>
</fo:block>
</xsl:if>
<xsl:variable name="id">
<xsl:value-of select="@id"/>
</xsl:variable>
<xsl:for-each select="//article[author/@id=$id]">
<fo:inline font-size="8pt"
font-style="italic"
line-height="10pt">
<xsl:choose>
<xsl:when test="@type='book' or @type='software'">
<xsl:apply-templates mode="toc"
select="book/title|software/title"/>
<!--
<xsl:text> review</xsl:text>
-->
</xsl:when>
<xsl:when test="@type='news'">
<xsl:apply-templates mode="toc"
select="title"/>
<!--
<xsl:text> article</xsl:text>
-->
</xsl:when>
</xsl:choose>
<xsl:if test="position()!=last()">
<xsl:text> · </xsl:text>
</xsl:if>
</fo:inline>
</xsl:for-each>
</xsl:template>
<!-- image -> @align? @alt? @src
-->
<xsl:template match="image">
<fo:block>
<fo:external-graphic src="file:{@src}"/>
</fo:block>
</xsl:template>
<!-- item -> @id?
block-level entities
-->
<xsl:template match="item">
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="10pt"
line-height="12pt">
<xsl:choose>
<xsl:when test="@id">
<xsl:variable name="reference">
<xsl:number count="article"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="@id"/>
</xsl:variable>
<fo:inline id="{$reference}">
<xsl:value-of select="@id"/>
</fo:inline>
</xsl:when>
<xsl:when test="../@type='1' or ../@type='A'">
<xsl:number format="{../@type}"/>
</xsl:when>
<xsl:when test="../@type='bullet'">
<fo:inline font-family="Symbol">
·
</fo:inline>
</xsl:when>
<!-- ../@type='none' has no label -->
</xsl:choose>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="10pt">
<fo:block font-size="10pt"
line-height="12pt">
<xsl:apply-templates/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</xsl:template>
<!-- link -> @url
in-line entities
-->
<xsl:template match="link">
<xsl:if test="contains(@url, '.')">
<fo:basic-link external-destination="{@url}">
<xsl:if test="text()">
<xsl:apply-templates select="text()"/>
(<xsl:value-of select="@url"/>)
</xsl:if>
<xsl:if test="not(text())">
<xsl:value-of select="@url"/>
</xsl:if>
</fo:basic-link>
</xsl:if>
<xsl:if test="not(contains(@url, '.'))">
<xsl:variable name="reference">
<xsl:number count="article"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="@url"/>
</xsl:variable>
<fo:basic-link internal-destination="{$reference}"
text-decoration="underline">
<xsl:apply-templates select="text()"/>
[<xsl:value-of select="@url"/>]
</fo:basic-link>
</xsl:if>
</xsl:template>
<!-- list -> item+
-->
<xsl:template match="list">
<fo:list-block space-before="12pt">
<xsl:apply-templates select="item"/>
</fo:list-block>
</xsl:template>
<!-- paragraph -> (@block | @none)
in-line entities
-->
<xsl:template match="paragraph">
<xsl:choose>
<xsl:when test="@type='block'">
<fo:block end-indent="18pt"
font-size="10pt"
line-height="12pt"
space-before="12pt"
start-indent="18pt"
text-align="justify">
<xsl:apply-templates/>
</fo:block>
</xsl:when>
<xsl:when test="@type='none'">
<fo:block font-size="10pt"
line-height="12pt"
space-before="12pt"
text-align="justify">
<xsl:apply-templates/>
</fo:block>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- price -> @dollar | @pound
in-line entities
-->
<xsl:template match="price">
<xsl:choose>
<xsl:when test="@currency='dollar'">
$<xsl:apply-templates/>
</xsl:when>
<xsl:when test="@currency='pound'">
£<xsl:apply-templates/>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- render -> @bold | @code | @emphasis | @italic | @strong
in-line entities
-->
<xsl:template match="render">
<xsl:choose>
<xsl:when test="@type='bold' or @type='strong'">
<fo:inline font-weight="bold">
<xsl:apply-templates/>
</fo:inline>
</xsl:when>
<xsl:when test="@type='code'">
<fo:inline font-family="monospace">
<xsl:apply-templates/>
</fo:inline>
</xsl:when>
<xsl:when test="@type='emphasis' or @type='italic'">
<fo:inline font-style="italic">
<xsl:apply-templates/>
</fo:inline>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- section -> title?
(list | paragraph)+
-->
<xsl:template match="section">
<xsl:if test="title">
<fo:block font-size="12pt"
font-weight="bold"
line-height="14pt"
space-before="14pt"
text-align="start">
<xsl:apply-templates select="title"/>
</fo:block>
</xsl:if>
<xsl:apply-templates select="list|paragraph"/>
</xsl:template>
<!-- software -> title
author?
-->
<xsl:template match="software">
<fo:block font-size="14pt"
font-weight="bold"
line-height="18pt"
text-align="start">
<xsl:apply-templates select="title"/>
</fo:block>
<fo:block font-size="12pt"
font-weight="bold"
line-height="14pt"
text-align="start">
<xsl:apply-templates mode="toc"
select="author"/>
</fo:block>
</xsl:template>
<!-- title -> in-line entities
-->
<xsl:template match="title">
<xsl:apply-templates/>
</xsl:template>
<!-- toc -> chapter+
-->
<xsl:template name="toc">
<fo:page-sequence initial-page-number="1"
master-name="toc">
<fo:static-content flow-name="xsl-region-before">
<fo:block font-size="36pt"
font-weight="bold"
text-align="end">
<xsl:apply-templates select="title"/>
</fo:block>
<fo:block font-size="10pt"
font-style="italic"
line-height="12pt"
space-before="18pt"
text-align="center">
The Newsletter of the UK UNIX Users Group
</fo:block>
<fo:block font-size="10pt"
line-height="14pt"
text-align="center">
Published electronically at
<fo:inline font-family="monospace">
http://www.ukuug.org/newsletter/
</fo:inline>
</fo:block>
<fo:block>
<fo:leader leader-length="6.8in"
leader-pattern="rule"/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:block>
<fo:leader leader-length="6.8in"
leader-pattern="rule"/>
</fo:block>
<fo:block font-size="10pt"
text-align="justify">
ISSN <xsl:value-of select="@issn"/>
<fo:leader leader-length="5.6in"/>
<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="10pt"
line-height="12pt"
text-align="start">
Volume <xsl:value-of select="@volume"/>,
Number <xsl:value-of select="@number"/>
<fo:leader leader-length="4.8in"/>
<xsl:value-of select="@date"/>
</fo:block>
<fo:block>
<fo:leader leader-length="6.8in"
leader-pattern="rule"/>
</fo:block>
<fo:block font-size="14pt"
font-weight="bold"
line-height="18pt"
text-align="center">
Table of Contents
</fo:block>
<xsl:apply-templates mode="toc"
select="chapter"/>
</fo:flow>
</fo:page-sequence>
</xsl:template>
</xsl:stylesheet>
Regards,
Mick /"\
\ /
X ASCII Ribbon Campaign
/ \ Against HTML Mail
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]