Question

I have a docbook document and when I create a PDF I want it to display the chapter title without the word "Chapter" in front of it. According to this the following should work:

My custom stylesheet: (doc.xsl)

<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:fo="http://www.w3.org/1999/XSL/Format"
  version="1.0">
<xsl:import
  href="/usr/share/xml/docbook/stylesheet/docbook-xsl-ns/fo/docbook.xsl"/>
<xsl:param name="local.l10n.xml" select="document('')"/> 

<l:l18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
  <l:l10n language="en"> 
    <l:context name="title-numbered"> 
      <l:template name="chapter" text="%n.&#160;%t"/> 
    </l:context>    
  </l:l10n>
</l:l18n>
</xsl:stylesheet>

When I use this document: (doc.xml)

<book xmlns="http://docbook.org/ns/docbook" version="5.0"
     xml:lang="en">
  <title>Doc</title>
  <chapter>
    <title>Introduction</title>
    <section>
      <title>Purpose of the document</title>  
      <para></para>    
    </section>
  </chapter>
</book>

and these commands:

xsltproc doc.xsl doc.xml > doc.fo
fop -fo doc.fo -pdf fo.pdf

the resulting PDF still has "Chapter 1" in front of the chapter named "Introduction".

I tried different context names like "title" but it does not work. What am I doing wrong or how can I debug this problem?

Update I found the problem. The line l:l18n should read l:i18n...

Was it helpful?

Solution

I found the problem. It was a typo in one of the examples I found combined with a font where the i and the l look too similar.

The fix is in this line:

<l:l18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">

In this line it should read l:i18n (with an i and not an l)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top