Příklad 12. Řešení pomocí režimů
<xsl:template match="/">
...
<fo:block>Obsah</fo:block>
<xsl:apply-templates mode="toc"/>
<xsl:apply-templates/>
...
</xsl:template>
<xsl:template match="kapitola">
<fo:block ... id="{generate-id(.)}">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="podkapitola">
<fo:block ... id="{generate-id(.)}">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="kapitola" mode="toc">
<fo:block text-align-last="justify">
<fo:basic-link internal-destination="{generate-id(.)}">
<xsl:value-of select="název"/>
</fo:basic-link>
<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="{generate-id(.)}"/>
</fo:block>
<xsl:apply-templates mode="toc"/>
</xsl:template>
<xsl:template match="podkapitola" mode="toc">
<fo:block start-indent="1em" text-align-last="justify">
<fo:basic-link internal-destination="{generate-id(.)}">
<xsl:value-of select="název"/>
</fo:basic-link>
<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="{generate-id(.)}"/>
</fo:block>
</xsl:template>
<xsl:template match="text()" mode="toc"/>