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.

3
  • 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, 2010 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, 2010 at 16:09
  • provide that snippet in your question, where you "fop" the header of the page ...
    – akira
    Jun 3, 2010 at 20:54

4 Answers 4

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>
1
  • This looks like it should work, but I've long moved on from that project. Thanks for the answer.
    – Mica
    Aug 28, 2014 at 2:35
1

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

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.

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.

You must log in to answer this question.

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