fo:list-block alignment problem, (40051)

Here should go questions about transforming XML with XSLT and FOP.
DanL
Posts: 4
Joined: Wed May 08, 2024 12:40 am

fo:list-block alignment problem, (40051)

Post by DanL »

Good afternoon!

I have this little snipped of XSL:

Good afternoon!

Thanks for looking. I have some lovely MIL-STD-40051 XML (DTD 6.5.3) and a style sheet question.

Style sheet:

Code: Select all

<xsl:template match="tsindx.messageword-entry">
	<fo:list-block>
		<fo:list-item>
			<fo:list-item-label>
				<fo:block start-indent="6pt">
					<xsl:number count="tsindx.messageword-entry" format="1." from="tsindxwp" level="any"/>
					<xsl:text disable-output-escaping="no">&#x2003;</xsl:text>
					<xsl:apply-templates select="messageword"/>
					<fo:leader leader-pattern="dots"/>
				</fo:block>
			</fo:list-item-label>
			<fo:list-item-body relative-align="baseline">
				<xsl:apply-templates select="action | xref | extref | link"/>
			</fo:list-item-body>
		</fo:list-item>
	</fo:list-block>
</xsl:template>

This is my first encounter with a list-block and I found this helpful to get my head around the concept.
https://www.data2type.de/en/xml-xslt-xs ... tion/lists

This image in particular:
Image


PDF output looks like this:
2024-06-25_15-27-01_output.png
2024-06-25_15-27-01_output.png (25.23 KiB) Viewed 377 times


Which is mostly OK, except ... for item 1, the list-item-label (generated by apply-templates select="messageword") is "Air System Does Not Reach Operating Pressure, Or Loses Pressure During Operation" which is really long, and wraps down to a second line. The leader of dots goes out to the right. Which is normal and correct.

but

The list-item-body "WP 0021" (generated by apply-templates select="xref") is aligned with the TOP of the list-item-label, which means the leader line on long list-item-labels just leads to empty space.

It looks like this:
1. Air System Does Not Reach Operating Pressure, Or Loses Pressure WP 0021
During Operation . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . .

When what it should look like is:
1. Air System Does Not Reach Operating Pressure, Or Loses Pressure
During Operation . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . .. . . WP 0021


If this was a table, the fix would be to have both cells align bottom rather than align top.

Unfortunately, it's a list. I have no idea how to get the the alignment corrected.

I looked at the style sheet in Oxygen, tsindxwp-v6_5.xsl. There are a bewildering number of possible attributes that can be applied, and so far, I have not found the winning combination. (I've tried about 15 different combinations of attributes so far, no luck. )

I would also like to maybe buffer the line length on generated by apply-templates select="messageword" so that if the list-item-label (messageword) is so long that there is no room for a leader, the style sheet line-breaks the last word to make the list-item-label two lines. So instead of this,

3. Trailer Brakes Unevenly, Pulls To One Side, Or Brakes Do Not Apply WP 0026

something more like this:

3. Trailer Brakes Unevenly, Pulls To One Side, Or Brakes Do Not
Apply . . . . . . . . . . . .. . . . . . . . . . . .. . . . . . . . . . . .. . . . . . . . . . . .. . . . . . . . . . . .. . . . WP 0026

but that is a much lower priority issue, and contingent on getting the first problem solved.

Any ideas would be greatly appreciated.

Thanks,

Dan
Attachments
image.png
image.png (6.09 KiB) Viewed 377 times
julien_lacour
Posts: 573
Joined: Wed Oct 16, 2019 3:47 pm

Re: fo:list-block alignment problem, (40051)

Post by julien_lacour »

Hello,

Could you indicate which FO processor you are using to obtain your PDF? (Apache FOP, Antenna House, etc.)

I think the structure should look more like this, with the actual content in the <fo:list-item-body> element:

Code: Select all

<fo:list-block provisional-label-separation="6pt" provisional-distance-between-starts="24pt">
    <fo:list-item>
        <fo:list-item-label end-indent="label-end()">
            <fo:block>1.&#x2003;</fo:block>
        </fo:list-item-label>
        <fo:list-item-body start-indent="body-start()">
            <fo:block>
                <fo:inline>
                    Air System Does Not Reach Operating Pressure, Or Loses Pressure During Operation
                </fo:inline>
                <fo:leader leader-pattern="dots"/>
                <fo:inline>
                    WP 0021
                </fo:inline>
            </fo:block>
        </fo:list-item-body>
    </fo:list-item>
</fo:list-block>
You should maybe try to create a <fo:inline-container> for your content, it should help you aligning the texts.

For the "3. Trailer Brakes Unevenly, Pulls To One Side, Or Brakes Do Not Apply WP 0026" structure I don't think there's an easy way to force the leader to display and to add a line-break in the text.

Regards,
Julien
Post Reply