Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!



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

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

share|improve this question
just to clarify things: you have a text in docbook format and are now developing the .xsl file to transform it via fop to xyz? – akira Jun 3 '10 at 4:06
yes. i've imported the default docbook 5 xslt to my sheet and i'm over riding the defaults. I've seen strings for printing the section or chapter name, but nothing about the book name or title. – Mica Jun 3 '10 at 16:09
provide that snippet in your question, where you "fop" the header of the page ... – akira Jun 3 '10 at 20:54
up vote 1 down vote accepted

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>

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'?>

After this line you can import the docbook.xsl.

Sample beginning of the docbook with book title:

<?xml version="1.0"?>
<book xmlns="" version="5.0">
share|improve this answer
This looks like it should work, but I've long moved on from that project. Thanks for the answer. – Mica Aug 28 '14 at 2:35 might help. provide the snippet and maybe i can help more.

share|improve this answer

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"/>

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.

share|improve this answer

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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .