2012-02-19 110 views
3

我有一個docbook文檔,當我創建一個PDF時,我希望它顯示章節標題前面沒有「章節」一詞。 根據this下面應該工作:如何刪除docbook章節標題中的「章節」

我的自定義樣式表:(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> 

當我使用這個文件:(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> 

這些命令:

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

由此產生的PDF仍有「章節1「在名爲」簡介「的章節前面。

我嘗試了不同的上下文名稱,如「標題」,但它不起作用。 我在做什麼錯,或者我該如何調試這個問題?

更新 我發現了這個問題。該行l:l18n應該閱讀l:i18n ...

+0

溶液導致的章節標題和TOC之間的差異因爲編號的上下文標題似乎與toc不匹配。 toc條目的正確背景是什麼? – ceving 2012-06-19 12:17:35

回答

5

我發現了這個問題。這是我發現的一個例子中的拼寫錯誤,與我和我看起來太相似的字體相結合。

解決方法是在這條線:

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

在這一行應該讀取l:i18n(帶有i而不是l