2

What is the proper string to use in my XSLT to make FOP print the title of the book in the header? I haven't been able to find this anywhere, and any help is appreciated!

Edit:

So,

<xsl:when test="$sequence = 'even' and $position = 'right'">
        <xsl:apply-templates select="." mode="titleabbrev.markup"/> 
      </xsl:when>

will print abbreviated section/chapter name. I want to do the same, but for the title of the book.

Mica
  • 399

4 Answers4

2

Use this:

<xsl:when test="$sequence = 'even' and $position = 'right'">
 <xsl:value-of select="ancestor-or-self::d:book/d:bookinfo/d:title"></xsl:value-of>
</xsl:when>

The title in this case is nested under <bookinfo>. The d: label is required. But to do this ensure that you have imported the namespace in the begining of the stylesheet:

<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:d="http://docbook.org/ns/docbook"
exclude-result-prefixes="d"
version="1.0">

After this line you can import the docbook.xsl.

Sample beginning of the docbook with book title:

<?xml version="1.0"?>
<book xmlns="http://docbook.org/ns/docbook" version="5.0">
<bookinfo>
<title>THIS IS THE TITLE OF THE BOOK</title>
</bookinfo>
...
...
</book>
Rajib
  • 3,156
1

http://www.sagehill.net/docbookxsl/PrintHeaders.html might help. provide the snippet and maybe i can help more.

akira
  • 63,447
1

A bit late but I came across your question while I was looking for a way to do this.

After some searching I ended up with :

in the <xsl:template name="header.content"> section:

<xsl:when test="$position = 'left'">
   <xsl:value-of select="//d:book/d:title"/>, 
   <xsl:value-of select="//d:book/d:subtitle"/>
</xsl:when>

When the title does not fit in the left part of the header you can make the left part wider (100% in this example) by using :

<xsl:param name="header.column.widths">1 0 0</xsl:param>

somewhere in you config xslt.

rve
  • 101
0

A header could be displayed in <fo:region-before> what defines the top region of a page.

I can see in your example that you test for 'even'. I gees that you only need this title on even pages. You can do this by defining different page masters (<fo:simple-page-master master-name="even">) – look for <fo:page-sequence-master> and <fo:conditional-page-master-reference> to have odd/even pages. In this page master you define the different regions of the page.

jonsca
  • 4,084
chrwahl
  • 111