We are using this XSL-FO to generate entries in the Table of Contents page:
<fo:block text-align-last="justify">
<xsl:value-of select="@title" />
<fo:leader leader-pattern="dots" />
<fo:page-number-citation ref-id="{@id}" />
</fo:block>
When pages have very long titles, the page number is bumped onto a new line. If the page title is long enough to bump the page number onto a new line but not long enough to go onto a new line itself, the page number will be left aligned when it should be right aligned.
As far as I can tell, the XML is correct and this is an issue with XSL-FO itself. Is there a way to get all of the page numbers right aligned without redesigning anything else about the layout?
Update:
Thanks for the response Tony Graham, unfortunately it doesn't seem for me for some reason. On lines that should have a single continuous leader I would end up with two sets of leader dots separated by a small gap that I could not get rid of. But it did inspire this solution that works well enough for me:
<fo:block text-align-last="justify">
<xsl:value-of select="@title" />
<fo:leader leader-pattern="dots" />
<fo:page-number-citation keep-with-previous="always" ref-id="{@id}" />
</fo:block>
You essentially have examples 1, 3, and 5 from the axf:leader-expansion
documentation at https://www.antenna.co.jp/AHF/help/v70e/ahf-ext.html#axf.leader-expansion
As others have pointed out, you can't handle every possible ToC or index variant with vanilla XSL-FO, but you can achieve a result for the sample that you showed:
<fo:flow flow-name="xsl-region-body"
leader-alignment="reference-area"
text-align-last="justify">
<fo:block>Page with very short title<fo:leader leader-pattern="dots" keep-with-previous.within-line="always" /><fo:leader leader-pattern="dots" />3</fo:block>
<fo:block>Page with very very very very very very very very long title<fo:leader leader-pattern="dots" keep-with-previous.within-line="always" /><fo:leader leader-pattern="dots" />4</fo:block>
<fo:block>Page with very very very very very very very very very very very very long title<fo:leader leader-pattern="dots" keep-with-previous.within-line="always" /><fo:leader leader-pattern="dots" />5</fo:block>
</fo:flow>
Tested with AH Formatter V7.0.