xsltapache-fopdocbookdocbook-xsl

Generate page citations with chapter numbers using DocBook/XLST-FO


I'm able to generate a page number given an ID passed: <fo:page-number-citation ref-id="{$id}"/>.

However, I'm unable to find a reliable way to fetch the chapter number.

Ideally, I would like to have all calls to fo:page-number-citation to be of the format ChapterNum-PageNum.


Solution

  • The link to the DocBook wiki helps.

    For example, the following snippet displays the chapter number: <xsl:number count="chapter" from="book" level="any"/> when under the chapter element.

    <fo:basic-link internal-destination="{$refname.id}">
      <xsl:number count="chapter" from="book" level="any"/>
      <xsl:text>-</xsl:text>
      <fo:page-number-citation ref-id="{$refname.id}"/>
    </fo:basic-link>