docbook-apps

  • 1.  Part titlepage customization

    Posted 12-10-2012 20:37
    I have created an extensive customization of the part titlepage that
    gives choices for changing the order of the part toc and partintro, and
    whether they occur on the title page recto or verso.

    I noticed that when the toc appears on the part titlepage verso, the
    page number generated in the book toc was where the toc appeared – so it
    would be an even page number, whereas it should be the page where the
    title is (i.e. the first page of the titlepage. The ID attribute that
    generates the page numbers is by default applied to the coding that
    generates the toc. But if someone wants the toc to appear on the verso,
    the page number in the book toc will be incorrect. So I had to move the
    fo: block containing the ID to be applied to the *title* for those
    options (highlighted in the following). Is this a customization that
    should be in the standard stylesheets?
    -----


    <xsl:variablename="parttocorder"xml:id="p5-201">1</xsl:variable>


    <xsl:templatename="part.titlepage.before.verso"priority="1">
    <xsl:variablename="toc.params">
    <xsl:call-templatename="find.path.params">
    <xsl:with-paramname="table"
    select="normalize-space($generate.toc)"/>
    </xsl:call-template>
    </xsl:variable>

    <xsl:iftest="contains($toc.params, 'toc')">
    <xsl:call-templatename="division.toc">
    <xsl:with-paramname="toc.context"select="."/>
    </xsl:call-template>
    </xsl:if>

    </xsl:template>




    <xsl:templatematch="d:part"mode="part.titlepage.mode">

    <xsl:paramname="additional.content"/>

    <xsl:variablename="id">
    <xsl:call-templatename="object.id"/>
    </xsl:variable>

    <xsl:variablename="titlepage-master-reference">
    <xsl:call-templatename="select.pagemaster">
    <xsl:with-paramname="pageclass"select="'titlepage'"/>
    </xsl:call-template>
    </xsl:variable>

    <fo:page-sequencehyphenate="{$hyphenate}"
    master-reference="{$titlepage-master-reference}">
    <xsl:attributename="language">
    <xsl:call-templatename="l10n.language"/>
    </xsl:attribute>
    <xsl:attributename="format">
    <xsl:call-templatename="page.number.format">
    <xsl:with-paramname="master-reference"
    select="$titlepage-master-reference"/>
    </xsl:call-template>
    </xsl:attribute>

    <xsl:attributename="initial-page-number">
    <xsl:call-templatename="initial.page.number">
    <xsl:with-paramname="master-reference"
    select="$titlepage-master-reference"/>
    </xsl:call-template>
    </xsl:attribute>

    <xsl:attributename="force-page-count">
    <xsl:call-templatename="force.page.count">
    <xsl:with-paramname="master-reference"
    select="$titlepage-master-reference"/>
    </xsl:call-template>
    </xsl:attribute>

    <xsl:attributename="hyphenation-character">
    <xsl:call-templatename="gentext">
    <xsl:with-paramname="key"select="'hyphenation-character'"/>
    </xsl:call-template>
    </xsl:attribute>
    <xsl:attributename="hyphenation-push-character-count">
    <xsl:call-templatename="gentext">
    <xsl:with-paramname="key"select="'hyphenation-push-character-count'"/>
    </xsl:call-template>
    </xsl:attribute>
    <xsl:attributename="hyphenation-remain-character-count">
    <xsl:call-templatename="gentext">
    <xsl:with-paramname="key"select="'hyphenation-remain-character-count'"/>
    </xsl:call-template>
    </xsl:attribute>

    <xsl:apply-templatesselect="."mode="running.head.mode">
    <xsl:with-paramname="master-reference"select="$titlepage-master-reference"/>
    </xsl:apply-templates>

    <xsl:apply-templatesselect="."mode="running.foot.mode">
    <xsl:with-paramname="master-reference"select="$titlepage-master-reference"/>
    </xsl:apply-templates>

    <fo:flowflow-name="xsl-region-body">
    <xsl:call-templatename="set.flow.properties">
    <xsl:with-paramname="element"select="local-name(.)"/>
    <xsl:with-paramname="master-reference"
    select="$titlepage-master-reference"/>
    </xsl:call-template>


    <xsl:choose>

    <xsl:whentest="$parttocorder = '1'">

    <fo:blockid="{$id}">
    <xsl:call-templatename="part.titlepage"/>
    </fo:block>

    <xsl:copy-ofselect="$additional.content"/>
    </xsl:when>

    <xsl:whentest="$parttocorder = '2'">
    <xsl:call-templatename="part.titlepage.recto"/>
    <xsl:copy-ofselect="$additional.content"/>
    <fo:blockid="{$id}">
    <xsl:call-templatename="part.titlepage"/>
    </fo:block>

    </xsl:when>

    <xsl:whentest="$parttocorder = '3'">

    <fo:blockid="{$id}">
    <xsl:call-templatename="part.titlepage"/>
    </fo:block>
    <fo:blockbreak-after="page"/>
    <xsl:copy-ofselect="$additional.content"/>



    </xsl:when>

    <xsl:whentest="$parttocorder = '4'">

    <fo:blockid="{$id}">
    <xsl:call-templatename="part.titlepage.recto"/>
    </fo:block>
    <xsl:copy-ofselect="$additional.content"/>
    <fo:blockbreak-after="page"/>

    <xsl:call-templatename="part.titlepage"/>


    </xsl:when>

    <xsl:whentest="$parttocorder = '5'">

    <fo:blockid="{$id}">
    <xsl:call-templatename="part.titlepage.recto"/>
    </fo:block>
    <fo:blockbreak-after="page"/>
    <xsl:call-templatename="part.titlepage"/>
    <xsl:copy-ofselect="$additional.content"/>




    </xsl:when>

    <xsl:whentest="$parttocorder = '6'">

    <fo:blockid="{$id}">
    <xsl:call-templatename="part.titlepage.recto"/>
    </fo:block>
    <fo:blockbreak-after="page"/>
    <xsl:copy-ofselect="$additional.content"/>
    <xsl:call-templatename="part.titlepage"/>




    </xsl:when>

    <xsl:otherwise>
    <xsl:call-templatename="part.titlepage.recto"/>
    <fo:blockid="{$id}">
    <xsl:call-templatename="part.titlepage"/>
    </fo:block>

    <xsl:copy-ofselect="$additional.content"/>
    </xsl:otherwise>


    </xsl:choose>
    </fo:flow>
    </fo:page-sequence>
    </xsl:template>

    <xsl:templatename="part.titlepage">
    <fo:blockxmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:variablename="recto.content">
    <xsl:call-templatename="part.titlepage.before.recto"/>
    <xsl:iftest="$parttocorder = '1' or $parttocorder = '3'">
    <xsl:call-templatename="part.titlepage.recto"/>
    </xsl:if>

    <xsl:iftest="$parttocorder = '2' or $parttocorder = '4'">

    </xsl:if>

    </xsl:variable>
    <xsl:variablename="recto.elements.count">
    <xsl:choose>
    <xsl:whentest="function-available('exsl:node-set')"><xsl:value-ofselect="count(exsl:node-set($recto.content)/*)"/></xsl:when>
    <xsl:whentest="contains(system-property('xsl:vendor'), 'Apache Software
    Foundation')">
    <xsl:value-ofselect="count(exsl:node-set($recto.content)/*)"/></xsl:when>
    <xsl:otherwise>1</xsl:otherwise>
    </xsl:choose>
    </xsl:variable>
    <xsl:iftest="(normalize-space($recto.content) != '') or
    ($recto.elements.count > 0)">
    <fo:block><xsl:copy-ofselect="$recto.content"/></fo:block>
    </xsl:if>
    <xsl:variablename="verso.content">
    <xsl:call-templatename="part.titlepage.before.verso"/>
    <xsl:call-templatename="part.titlepage.verso"/>
    </xsl:variable>
    <xsl:variablename="verso.elements.count">
    <xsl:choose>
    <xsl:whentest="function-available('exsl:node-set')"><xsl:value-ofselect="count(exsl:node-set($verso.content)/*)"/></xsl:when>
    <xsl:whentest="contains(system-property('xsl:vendor'), 'Apache Software
    Foundation')">
    <xsl:value-ofselect="count(exsl:node-set($verso.content)/*)"/></xsl:when>
    <xsl:otherwise>1</xsl:otherwise>
    </xsl:choose>
    </xsl:variable>
    <xsl:iftest="(normalize-space($verso.content) != '') or
    ($verso.elements.count > 0)">
    <fo:block><xsl:copy-ofselect="$verso.content"/></fo:block>
    </xsl:if>
    <xsl:call-templatename="part.titlepage.separator"/>
    </fo:block>
    </xsl:template>


    <xsl:templatename="generate.part.toc">

    </xsl:template>


    --
    *Dave Gardiner*




  • 2.  Re: [docbook-apps] Part titlepage customization – ID ref

    Posted 12-10-2012 21:38
    Hi Dave,

    > Is this a customization that should be in the standard stylesheets?

    Are you offering this whole customization as a contribution to DocBook XSL? If so, then yes, this would be a very nice addition that would address several complaints about part title pages. I can discuss any questions I have about integration offline.

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net


    From: Xmplar
    Sent: Monday, December 10, 2012 12:36 PM
    To: DocBook Apps
    Subject: [docbook-apps] Part titlepage customization – ID ref


    I have created an extensive customization of the part titlepage that gives choices for changing the order of the part toc and partintro, and whether they occur on the title page recto or verso.

    I noticed that when the toc appears on the part titlepage verso, the page number generated in the book toc was where the toc appeared – so it would be an even page number, whereas it should be the page where the title is (i.e. the first page of the titlepage. The ID attribute that generates the page numbers is by default applied to the coding that generates the toc. But if someone wants the toc to appear on the verso, the page number in the book toc will be incorrect. So I had to move the fo: block containing the ID to be applied to the *title* for those options (highlighted in the following). Is this a customization that should be in the standard stylesheets?
    -----






    <xsl:variable name="parttocorder" xml:id="p5-201">1</xsl:variable>






    <xsl:template name="part.titlepage.before.verso" priority="1">
    <xsl:variable name="toc.params">
    <xsl:call-template name="find.path.params">
    <xsl:with-param name="table"
    select="normalize-space($generate.toc)"/>
    </xsl:call-template>
    </xsl:variable>

    <xsl:if test="contains($toc.params, 'toc')">
    <xsl:call-template name="division.toc">
    <xsl:with-param name="toc.context" select="."/>
    </xsl:call-template>
    </xsl:if>

    </xsl:template>




    <xsl:template match="d:part" mode="part.titlepage.mode">

    <xsl:param name="additional.content"/>

    <xsl:variable name="id">
    <xsl:call-template name="object.id"/>
    </xsl:variable>

    <xsl:variable name="titlepage-master-reference">
    <xsl:call-template name="select.pagemaster">
    <xsl:with-param name="pageclass" select="'titlepage'"/>
    </xsl:call-template>
    </xsl:variable>

    <fo:page-sequence hyphenate="{$hyphenate}"
    master-reference="{$titlepage-master-reference}">
    <xsl:attribute name="language">
    <xsl:call-template name="l10n.language"/>
    </xsl:attribute>
    <xsl:attribute name="format">
    <xsl:call-template name="page.number.format">
    <xsl:with-param name="master-reference"
    select="$titlepage-master-reference"/>
    </xsl:call-template>
    </xsl:attribute>

    <xsl:attribute name="initial-page-number">
    <xsl:call-template name="initial.page.number">
    <xsl:with-param name="master-reference"
    select="$titlepage-master-reference"/>
    </xsl:call-template>
    </xsl:attribute>

    <xsl:attribute name="force-page-count">
    <xsl:call-template name="force.page.count">
    <xsl:with-param name="master-reference"
    select="$titlepage-master-reference"/>
    </xsl:call-template>
    </xsl:attribute>

    <xsl:attribute name="hyphenation-character">
    <xsl:call-template name="gentext">
    <xsl:with-param name="key" select="'hyphenation-character'"/>
    </xsl:call-template>
    </xsl:attribute>
    <xsl:attribute name="hyphenation-push-character-count">
    <xsl:call-template name="gentext">
    <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
    </xsl:call-template>
    </xsl:attribute>
    <xsl:attribute name="hyphenation-remain-character-count">
    <xsl:call-template name="gentext">
    <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
    </xsl:call-template>
    </xsl:attribute>

    <xsl:apply-templates select="." mode="running.head.mode">
    <xsl:with-param name="master-reference" select="$titlepage-master-reference"/>
    </xsl:apply-templates>

    <xsl:apply-templates select="." mode="running.foot.mode">
    <xsl:with-param name="master-reference" select="$titlepage-master-reference"/>
    </xsl:apply-templates>

    <fo:flow flow-name="xsl-region-body">
    <xsl:call-template name="set.flow.properties">
    <xsl:with-param name="element" select="local-name(.)"/>
    <xsl:with-param name="master-reference"
    select="$titlepage-master-reference"/>
    </xsl:call-template>


    <xsl:choose>

    <xsl:when test="$parttocorder = '1'">

    <fo:block id="{$id}">
    <xsl:call-template name="part.titlepage"/>
    </fo:block>

    <xsl:copy-of select="$additional.content"/>
    </xsl:when>

    <xsl:when test="$parttocorder = '2'">
    <xsl:call-template name="part.titlepage.recto"/>
    <xsl:copy-of select="$additional.content"/>
    <fo:block id="{$id}">
    <xsl:call-template name="part.titlepage"/>
    </fo:block>

    </xsl:when>

    <xsl:when test="$parttocorder = '3'">

    <fo:block id="{$id}">
    <xsl:call-template name="part.titlepage"/>
    </fo:block>
    <fo:block break-after="page"/>
    <xsl:copy-of select="$additional.content"/>



    </xsl:when>

    <xsl:when test="$parttocorder = '4'">

    <fo:block id="{$id}">
    <xsl:call-template name="part.titlepage.recto"/>
    </fo:block>
    <xsl:copy-of select="$additional.content"/>
    <fo:block break-after="page"/>

    <xsl:call-template name="part.titlepage"/>


    </xsl:when>

    <xsl:when test="$parttocorder = '5'">

    <fo:block id="{$id}">
    <xsl:call-template name="part.titlepage.recto"/>
    </fo:block>
    <fo:block break-after="page"/>
    <xsl:call-template name="part.titlepage"/>
    <xsl:copy-of select="$additional.content"/>




    </xsl:when>

    <xsl:when test="$parttocorder = '6'">

    <fo:block id="{$id}">
    <xsl:call-template name="part.titlepage.recto"/>
    </fo:block>
    <fo:block break-after="page"/>
    <xsl:copy-of select="$additional.content"/>
    <xsl:call-template name="part.titlepage"/>




    </xsl:when>

    <xsl:otherwise>
    <xsl:call-template name="part.titlepage.recto"/>
    <fo:block id="{$id}">
    <xsl:call-template name="part.titlepage"/>
    </fo:block>

    <xsl:copy-of select="$additional.content"/>
    </xsl:otherwise>


    </xsl:choose>
    </fo:flow>
    </fo:page-sequence>
    </xsl:template>

    <xsl:template name="part.titlepage">
    <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:variable name="recto.content">
    <xsl:call-template name="part.titlepage.before.recto"/>
    <xsl:if test="$parttocorder = '1' or $parttocorder = '3'">
    <xsl:call-template name="part.titlepage.recto"/>
    </xsl:if>

    <xsl:if test="$parttocorder = '2' or $parttocorder = '4'">

    </xsl:if>

    </xsl:variable>
    <xsl:variable name="recto.elements.count">
    <xsl:choose>
    <xsl:when test="function-available('exsl:node-set')"><xsl:value-of select="count(exsl:node-set($recto.content)/*)"/></xsl:when>
    <xsl:when test="contains(system-property('xsl:vendor'), 'Apache Software Foundation')">
    <xsl:value-of select="count(exsl:node-set($recto.content)/*)"/></xsl:when>
    <xsl:otherwise>1</xsl:otherwise>
    </xsl:choose>
    </xsl:variable>
    <xsl:if test="(normalize-space($recto.content) != '') or ($recto.elements.count > 0)">
    <fo:block><xsl:copy-of select="$recto.content"/></fo:block>
    </xsl:if>
    <xsl:variable name="verso.content">
    <xsl:call-template name="part.titlepage.before.verso"/>
    <xsl:call-template name="part.titlepage.verso"/>
    </xsl:variable>
    <xsl:variable name="verso.elements.count">
    <xsl:choose>
    <xsl:when test="function-available('exsl:node-set')"><xsl:value-of select="count(exsl:node-set($verso.content)/*)"/></xsl:when>
    <xsl:when test="contains(system-property('xsl:vendor'), 'Apache Software Foundation')">
    <xsl:value-of select="count(exsl:node-set($verso.content)/*)"/></xsl:when>
    <xsl:otherwise>1</xsl:otherwise>
    </xsl:choose>
    </xsl:variable>
    <xsl:if test="(normalize-space($verso.content) != '') or ($verso.elements.count > 0)">
    <fo:block><xsl:copy-of select="$verso.content"/></fo:block>
    </xsl:if>
    <xsl:call-template name="part.titlepage.separator"/>
    </fo:block>
    </xsl:template>


    <xsl:template name="generate.part.toc">

    </xsl:template>





    --
    Dave Gardiner