0

我想创建一篇文章,其标题页包含标题和副标题,第二页包含标题、法律声明和版权,第三页包含目录。

我用 asciidoc 编写,然后转换为 docbook,然后使用 xsltproc 和 fop 生成 pdf。全部在 centos 6.4 系统上。据我了解,我必须创建一个自定义标题页 xsl 文件来实现我想要的。我按照doccookbook创建了我的xsl。但不知何故,这并不像我想要的那样工作,我根本没有得到单独的标题页。

我的 asciidoc myreport.txt 是

    My super duper report
    =====================
    :toc:

    My subtitle

    //copyright notice
     +
    by acme

    Publication date 102013 +
    Copyright (c) 2013 acme

    Permission to use, copy, modify and distribute this report and its accompanying
    documentation for any purpose and without fee is hereby granted in perpetuity,
    provided that the above copyright notice and this paragraph appear in all copies.

    First Chapter
    -------------
    bla bla

    Second Chapter
    --------------
    tables and foo bar

然后我创建我的 xml 标题页模板 articletitlepage.xml

<!DOCTYPE t:templates [
<!ENTITY hsize0 "10pt">
<!ENTITY hsize1 "12pt">
<!ENTITY hsize2 "14.4pt">
<!ENTITY hsize3 "17.28pt">
<!ENTITY hsize4 "20.736pt">
<!ENTITY hsize5 "24.8832pt">
<!ENTITY hsize0space "7.5pt"> <!-- 0.75 * hsize0 -->
<!ENTITY hsize1space "9pt"> <!-- 0.75 * hsize1 -->
<!ENTITY hsize2space "10.8pt"> <!-- 0.75 * hsize2 -->
<!ENTITY hsize3space "12.96pt"> <!-- 0.75 * hsize3 -->
<!ENTITY hsize4space "15.552pt"> <!-- 0.75 * hsize4 -->
<!ENTITY hsize5space "18.6624pt"> <!-- 0.75 * hsize5 -->
]>
<t:templates xmlns:t="http://nwalsh.com/docbook/xsl/template/1.0"
             xmlns:param="http://nwalsh.com/docbook/xsl/template/1.0/param"
             xmlns:fo="http://www.w3.org/1999/XSL/Format"
             xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- ==================================================================== -->

<t:titlepage t:element="article" t:wrapper="fo:block"
             font-family="{$title.fontset}">
<!-- ==================================================================== -->
  <t:titlepage-content t:side="recto"
             start-indent="0pt"
             text-align="center">

    <title t:named-template="component.title"
           param:node="ancestor-or-self::article[1]"
           keep-with-next.within-column="always"
           font-size="&hsize5;"
           font-weight="bold"/>

    <subtitle/>

  </t:titlepage-content>

<!-- ==================================================================== -->
  <t:titlepage-content t:side="verso">
    <title t:named-template="component.title" 
           param:node="ancestor-or-self::article[1]"
           keep-with-next.within-column="always"
           font-size="&hsize2;"
           font-weight="bold"/>
    <copyright space-before="0.5em"/>
    <legalnotice text-align="start"
                 margin-left="0.5in"
                 margin-right="0.5in"
                 font-family="{$body.fontset}"/>

  </t:titlepage-content>

  <t:titlepage-separator>
  </t:titlepage-separator>

  <t:titlepage-before t:side="recto">
    </t:titlepage-before>

  <t:titlepage-before t:side="verso">
    </t:titlepage-before>

</t:titlepage>


<!-- ==================================================================== -->

</t:templates>

我把它翻译成xsl

xsltproc --output articletitlepage.xsl  /usr/share/sgml/docbook/xsl-stylesheets-1.75.2/template/titlepage.xsl articletitlepage.xml;

然后我创建 myarticletitlepage.xsl 作为

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:import href="/etc/asciidoc/docbook-xsl/fo.xsl"/>
  <xsl:import href="articletitlepage.xsl"/>
</xsl:stylesheet>

然后我发出

xsltproc  --stringparam callout.graphics 0         --stringparam navig.graphics 0         --stringparam admon.textlabel 1         --stringparam admon.graphics 0 --nonet         "/home/isaac/code/testing/myarticletitlepage.xsl" "./myreport.xml" >"./myreport.fo"
fop  -fo "./myreport.fo" -pdf "./myreport.pdf"

这会生成一个pdf,它的标题有两次不同的字体大小(所以我的标题页模板是有效的)。但这一切都在一页上。我知道对于版权和法律问题,我在 asciidoc 中遗漏了一些东西(欢迎提示),但现在如果我能得到单独的页面,我会很高兴。

4

0 回答 0