Docbook: chapter number and the word "chapter" in the title

I am writing documentation in DocBook and want to publish it in PDF format with headers and footers. For this, I have this style:

<xsl:template name="header.content">
    <xsl:param name="pageclass" select="''"/>
    <xsl:param name="sequence" select="''"/>
    <xsl:param name="position" select="''"/>
    <xsl:param name="gentext-key" select="''"/>

  <fo:block>

    <!-- sequence can be odd, even, first, blank -->
    <!-- position can be left, center, right -->
    <xsl:choose>
      <xsl:when test="$sequence = 'blank'">
        <!-- nothing -->
      </xsl:when>

      <xsl:when test="$position='left'">
        <xsl:call-template name="draft.text"/>
         <xsl:apply-templates select="." mode="titleabbrev.markup"/>
        </xsl:when>
    </xsl:choose>
    <xsl:when test="$position='right'">
       <fo:page-number/>
     </xsl:when>
  </fo:block>
</xsl:template>

Using this piece of code, I get the following header:

My first chapter blah-blah            1

I want to get the following:

Chapter 1: My first chapter blah-blah            1

What patterns should I call to create such an auto text?

+3
source share
1 answer

Try the following (trying that I'm not too familiar with DocBook):

Add

<xsl:apply-templates select="." mode="object.title.markup"/>

into the template header.content. This should insert a "chapter title with section number label." See the Docbook documentation documentation here .

<xsl:template name="header.content">
    <xsl:param name="pageclass" select="''"/>
    <xsl:param name="sequence" select="''"/>
    <xsl:param name="position" select="''"/>
    <xsl:param name="gentext-key" select="''"/>

  <fo:block>

    <!-- sequence can be odd, even, first, blank -->
    <!-- position can be left, center, right -->
    <xsl:choose>
      <xsl:when test="$sequence = 'blank'">
        <!-- nothing -->
      </xsl:when>

      <xsl:when test="$position='left'">
        <xsl:call-template name="draft.text"/>
        <xsl:text>Chapter </xsl:text>
        <xsl:apply-templates select="." mode="object.title.markup"/>
        </xsl:text> </xsl:text>
        </xsl:when>
    </xsl:choose>
    <xsl:when test="$position='right'">
       <fo:page-number/>
     </xsl:when>
  </fo:block>
</xsl:template>

But note that between title.markupand titleabbrev.markupcan be the difference.

+4
source

All Articles