0

我有以下文件树

mainfolder
|-assembly.xml
|
|-chapters
| |-introduction.xml
|
|-source
  |-example01
    |-main.cpp

assembly.xml是我的文档的汇编文件。它包含对 的引用introduction.xml

这是组装:

<?xml version="1.0" encoding="UTF-8"?>
<assembly version="5.1"
  xmlns="http://docbook.org/ns/docbook">
  <resources xml:base="chapters/">
    <resource href="introduction.xml" xml:id="introduction" />
  </resources>
  <structure xml:id="main-book">
    <info>
      <description>Book chapters</description>
    </info>
    <output renderas="book"/>
    <module resourceref="introduction"/>
  </structure>
</assembly>

introduction.xml是 docbook chapter。我想在其中插入一个示例,包括main.cpp.

<?xml version="1.0" encoding="UTF-8"?>
<chapter version="5.1"
  xmlns="http://docbook.org/ns/docbook"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xila="http://www.w3.org/2001/XInclude/local-attributes"
  xmlns:xi="http://www.w3.org/2001/XInclude"
  xmlns:trans="http://docbook.org/ns/transclusion"
  xmlns:svg="http://www.w3.org/2000/svg"
  xmlns:m="http://www.w3.org/1998/Math/MathML"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns:db="http://docbook.org/ns/docbook">
  <info>
    <title>Introduction</title>
  </info>
  <section>
    <info>
      <title>Chapter title</title>
    </info>
    <para>
    You can see an example:
    </para>
    <example>
    <title>main example</title>
      <programlisting language="c++">
        <xi:include href="./../source/example01/maiin.cpp" parse="text" />
      </programlisting>
    </example>
  </section>
</chapter>

无论如何,当我编写这本书时(我使用的是 XMLMind 的个人版),我什么也没看到。在 PDF 中打印了示例,但main.cpp我看到的不是源代码

<xi:include></xi:include>

我做错了什么?如何包含文件中的源代码?

4

1 回答 1

2

我以不同的方式重现了您的情况,并且在这两种情况下都可以正常工作。

您没有提到使用 XMLMind XML Editor(简称 XXE)构建一本书的具体步骤,但以下步骤确实运行良好。

无 1:我使用过 XXE 专业版,但据我所知,如果从个人版生成 PDF,版本之间的区别仅在于将随机字符放入文本中。

注意 2:XXE 表示<description>Book chapters</description>您的上下文中不允许使用该元素。尽管如此,仍然可以成功生成程序集。

1. 让事情在 XXE 中工作

  1. 在 XXE 中打开一个程序集文件。
  2. 选择“转换” > “转换文档” > “转换为 PDF”
  3. 选择保存pdf文件的路径,然后按OK按钮。

2. 在命令行中手动运行

  1. 使用您的确切文件和 DIR 结构(我包含我自己的.c 文件示例用于我自己的测试)。

  2. 使用 XXE 汇编处理器:http ://www.xmlmind.com/xmleditor/assembly.shtml - 它与 XXE 用于处理来自 XXE GUI 的汇编的代码库相同。

  3. 从程序集中获取 docbook 文件:assembly-1_0_2_01/bin/assembly -v assembly.xml docbook_book.xml在我的测试中,我.c包含了示例文件 - 这证明程序集实用程序可以很好地与 XInclude 配合使用。

  4. .pdf手动获取:fop -c <config_file> -xsl <path_to_docbook_ns_stylesheets>/fo/docbook.xsl -xml docbook_book.xml -pdf docbook_book.pdf

我已经得到了.c两种情况下都包含样本的最终结果。

于 2018-02-12T07:42:33.750 回答