XML technologies / XSL-FO / Reference / Elements in XSL-FO / fo:conditional-page-master-reference

(Excerpt from "XSL-FO ― Die Referenz" by Manuel Montero Pineda & Steffen Herkert, 2016, dpunkt.verlag)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Recommendation section: 6.4.12

Category: 6.4 Declarations and Pagination and Layout Formatting Objects

Description

This element names a page master object to be used when the required conditions are met.

XSL-FO version: 1.0

Parent elements

<fo:repeatable-page-master-alternatives>

This element defines how different page masters are repeated, for example by alternating left- and right-aligned page masters.

Attributes

blank-or-not-blank

In the element fo:conditional-page-master-reference this property defines a condition determining whether a page master should be selected at a particular point in the page sequence.

master-reference

This attribute references individual page masters (fo:simple-page-master) or complete page sequence masters (fo:page-sequence-master). They receive a name in a master-name attribute, and this name must be supplied in master-reference. The name must occur in at least one master-name attribute. If a page master and a page sequence master share a name, the page sequence master is referenced unless the reference is within a fo:simple-page-master element. If two page masters share a master-name, the first one defined is referenced.

odd-or-even

The fo:conditional-page-master-reference element references a page master for a page sequence (fo:repeatable-page-master-alternatives). If a sequence contains only one fo:conditional-page-master-reference element, every page uses the same master. Many publications, especially books, need alternating page masters to distinguish left and right pages: inner and outer margins, page number position, and header position and content. Multiple masters are therefore referenced in one sequence. To restrict a master to even- or odd-numbered pages, the corresponding fo:conditional-page-master-reference element can specify the attribute odd-or-even.

page-position

The fo:conditional-page-master-reference elements describe a page sequence within fo:repeatable-page-master-alternatives. Each fo:conditional-page-master-reference element references a page master. The page-position attribute specifies where in the generated document the master may be used: only the first page, only the last page, the remaining pages, or all pages. Combined with odd-or-even, several masters with the same value for page-position can occur in fo:repeatable-page-master-alternatives.

Support:

Conformance level

Antenna House

FOP

RenderX XEP

Altsoft XML2PDF

Compart DocBridge

Extended

Y

Y

Y

P

Y

XSL-FO example:

<fo:root font-family="Arial" font-size="10pt" line-height="1.2em" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:cpfo="http://www.compart.net/xmlns/cpfo" xmlns:svg="http://www.w3.org/2000/svg" xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions">
<fo:layout-master-set>
<fo:simple-page-master master-name="Inhalt-Seiten.first" margin="0mm 0mm 0mm
                      0mm" page-height="auto" page-width="auto">
<fo:region-body margin="20mm 15mm 5mm
                        25mm"/>
<fo:region-before extent="5mm" region-name="first.before"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="Inhalt-Seiten.rest" margin="0mm 0mm 0mm
                      0mm" page-height="auto" page-width="auto">
<fo:region-body margin="20mm 15mm 5mm
                        25mm"/>
<fo:region-before extent="5mm" region-name="rest.before"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="Inhalt-Seiten.last" margin="0mm 0mm 0mm
                      0mm" page-height="auto" page-width="auto">
<fo:region-body margin="20mm 15mm 5mm
                        25mm"/>
<fo:region-before extent="5mm" region-name="last.before"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="Inhalt-Seiten.any" margin="0mm 0mm 0mm
                      0mm" page-height="auto" page-width="auto">
<fo:region-body margin="20mm 15mm 5mm
                        25mm"/>
<fo:region-before extent="5mm" region-name="any.before"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="Inhalt-Seiten.master">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="Inhalt-Seiten.rest" page-position="rest"/>
<fo:conditional-page-master-reference master-reference="Inhalt-Seiten.first" page-position="first"/>
<fo:conditional-page-master-reference master-reference="Inhalt-Seiten.last" page-position="last"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="Inhalt-Seiten.master" font-size="10pt">
<fo:static-content flow-name="first.before">
<fo:block margin-top="2mm" text-align="center" font-size="16pt">
 Seitenvorlage
              
<fo:inline font-weight="700">
erste Seite
</fo:inline>
;
                page-position="
<fo:inline font-weight="700">
first
</fo:inline>
" 
</fo:block>
</fo:static-content>
<fo:static-content flow-name="rest.before">
<fo:block margin-top="2mm" text-align="center" font-size="16pt">
 Seitenvorlage: 
<fo:inline font-weight="700">
übrige Seiten
</fo:inline>
; page-position="
<fo:inline font-weight="700">
rest
</fo:inline>
" 
</fo:block>
</fo:static-content>
<fo:static-content flow-name="last.before">
<fo:block margin-top="2mm" text-align="center" font-size="16pt">
 Seitenvorlage:
              
<fo:inline font-weight="700">
letzte Seite
</fo:inline>
;
                page-position="
<fo:inline font-weight="700">
last
</fo:inline>
" 
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block page-break-after="always">
Inhalt Seitenfolge
</fo:block>
<fo:block page-break-after="always">
Inhalt
                Seitenfolge
</fo:block>
<fo:block page-break-after="always">
Inhalt Seitenfolge
</fo:block>
<fo:block page-break-after="always">
Inhalt
                Seitenfolge
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

Download the examples

More information online about

Introduction: "Page layout">

Practical example: "Complex page sequence masters">

Practical example: "Multi-column pages with column rules">

Rendering of the element in the XSL-FO reference

In the output:

Page 2

Page 3

Page 4

Excerpt from the W3C Recommendation:

back to top