docbook-apps

Re: [docbook-apps] How do I customize docbook/fo stylesheet to do custom page breaks on sections?

  • 1.  Re: [docbook-apps] How do I customize docbook/fo stylesheet to do custom page breaks on sections?

    Posted 10-08-2011 06:45
    Hi Jon,
    Unless global params, an attribute-set is evaluated each time it is used, in the context of the element being processed. So putting an xsl:choose inside the body of an xsl:attribute element works, but be sure to include an xsl:otherwise so you don't get an empty attribute.

    In your case, I would recommend adding a role attribute to the special chapter, rather than relying on its position in the document (which can change). If you used <chapter role="StatementDefs">, then your stylesheet could use:

    <xsl:attribute-set name="section.level1.properties">
    <xsl:attribute name="break-before">
    <xsl:choose>
    <xsl:when test="ancestor::chapter/@role = 'StatementDefs'">page</xsl:when>
    <xsl:otherwise>auto</xsl:otherwise>
    </xsl:choose>
    </xsl:attribute>
    </xsl:attribute-set>

    This feature of XSLT is very handy for stuff like this.

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net