Examples

1. Examples of XSL-FO Stylesheets
2. Whats the minimum set of elements for an fo stylesheet

1.

Examples of XSL-FO Stylesheets

Nikolai Grigoriev

Have you looked at the PDF version of the XSL 1.0 CR at the W3C site? It has many of the things you have listed. It has been produced via XSL FO; you can find the relative stylesheet at the Renderx site, and look how these things have been done.

2.

Whats the minimum set of elements for an fo stylesheet

Sebastian Rahtz

If you, or any XSL FO guru, spots an error, PLEASE tell me. I spent a long time on this, and I want it to be right.

This is for the Mar 2000 version of the WD

<fo:layout-master-set>

* first define 3 page master, simple1, left1 and right1

  <fo:simple-page-master master-name="simple1" page-width="211mm"
  page-height="297mm" margin-top="75pt" margin-bottom="100pt"
  margin-left="80pt" margin-right="150pt">
    <fo:region-body margin-bottom="24pt" margin-top="24pt" />

    <fo:region-after extent="25pt" />

    <fo:region-before extent="25pt" />
  </fo:simple-page-master>

* note that we explicitly name the regions in here, so that we can
* assign static content properly later

  <fo:simple-page-master master-name="left1" page-width="211mm"
  page-height="297mm" margin-top="75pt" margin-bottom="100pt"
  margin-left="80pt" margin-right="150pt">
    <fo:region-body margin-bottom="24pt" margin-top="24pt" />

    <fo:region-after region-name="xsl-region-after-left"
    extent="25pt" />

    <fo:region-before region-name="xsl-region-before-left"
    extent="25pt" />
  </fo:simple-page-master>

  <fo:simple-page-master master-name="right1" page-width="211mm"
  page-height="297mm" margin-top="75pt" margin-bottom="100pt"
  margin-left="80pt" margin-right="150pt">
    <fo:region-body margin-bottom="24pt" margin-top="24pt" />

    <fo:region-after region-name="xsl-region-after-right"
    extent="25pt" />

    <fo:region-before region-name="xsl-region-before-right"
    extent="25pt" />
  </fo:simple-page-master>

* OK, now define some page master sequences. first, a twosided one,
* where we alternate left and right masters depending on odd-or-even

  <fo:page-sequence-master master-name="twoside1">
    <fo:repeatable-page-master-alternatives>
      <fo:conditional-page-master-reference master-name="first1"
      page-position="first" />

      <fo:conditional-page-master-reference master-name="right1"
      odd-or-even="odd" />

      <fo:conditional-page-master-reference master-name="left1"
      odd-or-even="even" />
    </fo:repeatable-page-master-alternatives>
  </fo:page-sequence-master>

* now a one-sided version, where we use the "simple1" master for all
* but the  first page

  <fo:page-sequence-master master-name="oneside1">
    <fo:repeatable-page-master-alternatives>
      <fo:conditional-page-master-reference master-name="first1"
      page-position="first" />

      <fo:conditional-page-master-reference
      master-name="simple1" />
    </fo:repeatable-page-master-alternatives>
  </fo:page-sequence-master>


Got that straight? anyone else read that far? Now we can actually
*use* these beasts, eg the following starts a new page sequence in
twosided mode with appropriate static content for left and right

<fo:page-sequence hyphenate="true" language="US"
initial-page-number="1" master-name="twoside1">
  <fo:static-content flow-name="xsl-region-after-right">
    <fo:block text-align="end" font-size="10pt">
      <fo:page-number />
    </fo:block>
  </fo:static-content>

  <fo:static-content flow-name="xsl-region-after-left">
    <fo:block text-align="justify" font-size="10pt">
      <fo:page-number />
      <fo:leader rule-thickness="0pt" />
    </fo:block>
  </fo:static-content>

  <fo:static-content flow-name="xsl-region-before-right">
    <fo:block text-align="center" font-size="10pt">
    TEI Lite: An Introduction to Text Encoding for
    Interchange</fo:block>
  </fo:static-content>

  <fo:static-content flow-name="xsl-region-before-left">
    <fo:block text-align="center" font-size="10pt">Lou Burnard and
    C. M. Sperberg-McQueen</fo:block>
  </fo:static-content>

  <fo:static-content flow-name="xsl-region-before-first" />

  <fo:static-content flow-name="xsl-region-after-first">
    <fo:block font-size="10pt">
      <fo:leader text-align="center" rule-thickness="0pt" />
      <fo:page-number />
    </fo:block>
  </fo:static-content>

  <fo:flow flow-name="xsl-region-body" font-family="Times Roman"
  font-size="10pt">...</fo:flow>
</fo:page-sequence>