Page 1 of 1

How to control widows and orphans in a Docbook FO XSL customization layer?

Posted: Fri Dec 13, 2019 12:51 am
by rmcilvride
WidowOrphanOutput.png
WidowOrphanOutput.png (111.02 KiB) Viewed 1958 times
Dear friends,

I need to know how to remove widow/orphan constraints from blocks in formatted output (FO) for Docbook source, because the default setting of "2" is leaving too much white space in my documents in certain places. For example, please see the attached screenshot.

A code snippet for some of this output is:

Code: Select all

...
		<listitem>
			<formalpara>
				<title><guilabel>14 Pause before reading data</guilabel></title>
				<para>This parameter specifies a time for the DataHub to pause before
					reading the OPC server's data set. Some OPC DA servers report
					that they are running, but have not yet received the full data
					set from the process. If the DataHub attempts to connect right away,
					it might get a partial data set. The pause is fixed; it will
					always last for the full time specified.</para>
			</formalpara>
		</listitem>
	</itemizedlist>
</step>
<step>
	<para>Finally, you can specify how the OPC items get selected. You can select
		them manually or load all of them. </para>
	<mediaobject>
		<imageobject>
			<imagedata fileref="../cdh-prop-opcdefine-4.gif" align="center"/>
		</imageobject>
	</mediaobject> 
	<variablelist>
		<varlistentry>
			<term><guilabel>Manually Select Items</guilabel></term>
			<listitem>
				<para>Check the <guibutton>Manually Select Items</guibutton> box and
					press the <guibutton>Configure Items</guibutton> button to open
					the OPC Item Selection window, where you can specify exactly
					which points you wish to use:</para>
...									
I have tried adding this to my FO XSL customization file:

Code: Select all

    
<xsl:attribute-set name="block">
    <xsl:attribute name="widows">1</xsl:attribute>
    <xsl:attribute name="orphans">1</xsl:attribute>
</xsl:attribute-set>
But get no results. What am I doing wrong?

Re: How to control widows and orphans in a Docbook FO XSL customization layer?

Posted: Fri Dec 13, 2019 11:51 am
by Radu
Hi,

If you use Oxygen's "Find Replace in Files" tool to search in the folder "OXYGEN_INSTALL_DIR/frameworks/docbook/xsl/fo" for "keep-together" you will find all places in the stylesheets where "keep-together" attributes are set on xsl-fo elements. You probably need to look in the XSLT stylesheet "OXYGEN_INSTALL_DIR/frameworks/docbook/xsl/fo/lists.xsl" if you are interested in controlling this for lists. But if there is no attribute set defined for this in the XSLTs you canno overwrite it in a custom XSLT, you will need to overwrite the entire template.

More about page breaks in DocBook:

http://www.sagehill.net/docbookxsl/PageBreaking.html

As we (the Oxygen team) do not use DocBook much internally maybe you can also register and ask around on the DocBook users list:

https://docbook.org/help

Regards,
Radu

Re: How to control widows and orphans in a Docbook FO XSL customization layer?

Posted: Wed Dec 18, 2019 12:32 am
by rmcilvride
Hi Radu,

Thank you for your suggestions. As it turns out, I was able to include them in setting attributes for list.block.spacing and list.item.spacing, which is where the problems were occurring.

For example:

Code: Select all

<!-- Reduces spacing for list items, overrides widow/orphan control -->
<xsl:attribute-set name="list.item.spacing">
    <xsl:attribute name="space-before.optimum">.5em</xsl:attribute>
    <xsl:attribute name="space-before.minimum">.4em</xsl:attribute>
    <xsl:attribute name="space-before.maximum">.6em</xsl:attribute>
    <xsl:attribute name="space-after.optimum">.2em</xsl:attribute>
    <xsl:attribute name="space-after.minimum">.1em</xsl:attribute>
    <xsl:attribute name="space-after.maximum">.3em</xsl:attribute>
    <xsl:attribute name="widows">1</xsl:attribute>
    <xsl:attribute name="orphans">1</xsl:attribute>
</xsl:attribute-set>
And it's working now. I appreciate your feedback.

Re: How to control widows and orphans in a Docbook FO XSL customization layer?

Posted: Wed Dec 18, 2019 10:28 am
by Radu
Hi,

Great, thanks for updating the post with the solution.

Regards,
Radu