I haven't tried Michael Sulyaev's suggestion about page-sequence-master on this problem. However, using <fo:marker/>
and <fo:retrieve-marker/>
seemed to work. I'm not sure if this is a valid XSL-FO solution, but it works with Apache fop.
It seems to be important that the <fo:retrieve-marker/>
is a <fo:static-content/>
descendant, according to the w3.org specification. It cannot be part of the table itself.
<fo:static-content flow-name="xsl-region-before">
<fo:table>
<!-- Render <fo:table-column/> elements -->
<xsl:call-template name="TableColumns"/>
<!-- fo:table-body, fo:table-row, fo:table-cell, fo:block
omitted for the example -->
<fo:retrieve-marker retrieve-class-name="carryover-label"/>
</fo:table>
</fo:static-content>
Then, the <fo:marker/>
elements are positioned in the data table itself:
<fo:flow flow-name="xsl-region-body">
<fo:table>
<!-- Render the same <fo:table-column/> elements -->
<xsl:call-template name="TableColumns"/>
<fo:table-body>
<xsl:for-each select="/data-path">
<!-- fo:table-row, fo:table-cell, fo:block
omitted for the example -->
<xsl:choose>
<xsl:when test="position() = 1">
<fo:marker marker-class-name="carryover-label">
Last month's balance</fo:marker>
</xsl:when>
<xsl:otherwise>
<fo:marker marker-class-name="carryover-label">
Last page's balance</fo:marker>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:flow>
Now the two tables only have to be positioned exactly one on top of the other. For my problem, that's a valid workaround.