XSL-FO Flow and Static content

Both XSL-FO elements <fo:flow> and <fo:static-content> are child elements of the <fo:page-sequence> element. The <fo:flow> is required.

XSL-FO flow

The <fo:flow> element is used to fill XSL-FO pages. The <fo:flow> element consist of flow objects that are arranged in pages. The <fo:flow> element has the foloowing attributes:

  • flow-name attribute defines where the content will go and it has 5 values:
    • xsl-region-body
    • xsl-region-before
    • xsl-region-after
    • xsl-region-start
    • xsl-region-end
  • id attribute sets a unique identifier of a formatting object and allows making references to it.
  • index-class attribute is used for indexing. It associates a formatting object with an index-class and has an index-key specified.
  • index-key attribute is used for indexing. It associates a formatting object with its index-key specified.

The <fo:flow> contains block-level formatting objects:

  • <fo:block>
  • <fo:block-container>
  • <fo:table-and-caption>
  • <fo:table>
  • <fo:list-block>

XSL-FO static content

Static content may be defined via <fo:static-content>. It contains formatting objects that is used repeatedly and can be assigned to one or more pages in the page-sequence. The <fo:static-content> is commonly used for headers and footers. It has the same attributes and contains the same block-level formatting objects as <fo:flow>.

Here is a modified "Hello, World" example:

  <?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="my-first-page">
			  <fo:region-body margin="15pt"/>
  		  </fo:simple-page-master>
	  </fo:layout-master-set>
	  <fo:page-sequence master-reference="my-first-page">
		  <fo:static-content flow-name="xsl-region-before" font="italic">
			  <fo:block>This is an example</fo:block>
		  </fo:static-content>
		  <fo:flow flow-name="xsl-region--body">
			  <fo:block>Hello, world!</fo:block>
		  </fo:flow>
	  </fo:page-sequence>
  </fo:root>

The resulted page will contain the text "Hello, World!" and "This is an example" in the header region written in italic.