如何从 docbook 5.0 生成 pdf

发布于 2024-08-28 13:43:18 字数 1457 浏览 7 评论 0原文

我编写了一个带有标题的 docbook 5.0 文档:

<?xml version="1.0" encoding="UTF-8"?>
<book version="5.0" xmlns="http://docbook.org/ns/docbook"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      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">

并且 Ubuntu 9.10 上的 docbook2pdf 打印了许多错误消息并且不执行任何 pdf 文档。错误是:

openjade:test.xml:2:0:E: prolog can't be omitted unless CONCUR NO and LINK EXPLICIT NO and either IMPLYDEF ELEMENT YES or IMPLYDEF DOCTYPE YES
openjade:test.xml:2:0:E: no document type declaration; will parse without validation
openjade:/usr/share/sgml/docbook/stylesheet/dsssl/modular/print/dbtitle.dsl:18:5:E: flow objects at the root must be all of class scroll or all of class page-sequence or simple-page-sequence
openjade:/usr/share/sgml/docbook/stylesheet/dsssl/modular/print/dbbibl.dsl:704:4:E: flow objects at the root must be all of class scroll or all of class page-sequence or simple-page-sequence

docbook2pdf 为 docbook 4.5 格式的文档,带有正常标题,如:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">

工作得很好。

有没有办法从 docbook 5.0 生成 pdf?

I've written a docbook 5.0 document with the header:

<?xml version="1.0" encoding="UTF-8"?>
<book version="5.0" xmlns="http://docbook.org/ns/docbook"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      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">

and docbook2pdf on Ubuntu 9.10 prints many error messages and doesn't do any pdf document. The errors are:

openjade:test.xml:2:0:E: prolog can't be omitted unless CONCUR NO and LINK EXPLICIT NO and either IMPLYDEF ELEMENT YES or IMPLYDEF DOCTYPE YES
openjade:test.xml:2:0:E: no document type declaration; will parse without validation
openjade:/usr/share/sgml/docbook/stylesheet/dsssl/modular/print/dbtitle.dsl:18:5:E: flow objects at the root must be all of class scroll or all of class page-sequence or simple-page-sequence
openjade:/usr/share/sgml/docbook/stylesheet/dsssl/modular/print/dbbibl.dsl:704:4:E: flow objects at the root must be all of class scroll or all of class page-sequence or simple-page-sequence

docbook2pdf for document in the docbook 4.5 format with normal header like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">

works quite OK.

Is there any way to generate pdf from docbook 5.0?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

不必在意 2024-09-04 13:43:18

我看到三个选项(在 Debian/Ubuntu 中可用)从 docbook 生成 pdf:

  • jade,它提供了提问者使用的 docbook2pdf 命令。 jade 很古老,并且与 SGML 一起使用,SGML 早于 XML 并且不支持 Unicode;它还缺乏对 docbook 5 的支持。

  • docbook-xsl 样式表,通过 XSL-FO。 docbook-xsl 适用于 docbook 4.5,docbook-xsl-ns 适用于 docbook5。使用 fop 从 XSL-FO 转换为 PDF。管道:docbook5 —(xsl)—> xml.fo —(fop)—> pdf 。涉及的命令:xsltproc、fop。

  • dblatex,主要针对 docbook4.5,但已针对某些 docbook5 进行了更新。

xmlto 可以驱动后两个,尽管它当前默认为 docbook-xsl 而不是 docbook-xsl-ns。


Docbook5 快速用户指南

先决条件

sudo aptitude install docbook5 docbook-xsl-ns xsltproc fop xmlto libxml2-utils xmlstarlet

验证

xmlstarlet val --err --xsd /usr/share/xml/docbook/schema/xsd/5.0/docbook.xsd book.xml

PDF 输出

xsltproc /usr/share/xml/docbook/stylesheet/docbook-xsl-ns/fo/docbook.xsl book.xml > book.fo
fop -fo book.fo -pdf book.pdf

I see three options (available in Debian/Ubuntu) to generate pdf from docbook:

  • jade, which provides the docbook2pdf command the asker used. jade is ancient and works with SGML, which predates XML and does not support Unicode; it also lacks support for docbook 5.

  • the docbook-xsl stylesheets which go through XSL-FO. docbook-xsl is for docbook 4.5, docbook-xsl-ns is for docbook5. Use fop to go from XSL-FO to PDF. Pipeline: docbook5 —(xsl)—> xml.fo —(fop)—> pdf . Commands involved: xsltproc, fop.

  • dblatex, which is primarily targeting docbook4.5 but has been updated for some of docbook5.

xmlto can drive the last two, although it currently defaults to docbook-xsl and not docbook-xsl-ns.


A quick Docbook5 user guide

Prerequisites

sudo aptitude install docbook5 docbook-xsl-ns xsltproc fop xmlto libxml2-utils xmlstarlet

Validation

xmlstarlet val --err --xsd /usr/share/xml/docbook/schema/xsd/5.0/docbook.xsd book.xml

PDF output

xsltproc /usr/share/xml/docbook/stylesheet/docbook-xsl-ns/fo/docbook.xsl book.xml > book.fo
fop -fo book.fo -pdf book.pdf
忆沫 2024-09-04 13:43:18

除了您提供的标题之外,您是否尝试过一个较小的示例,例如 DocBook 5.0:权威指南

<?xml version="1.0" encoding="UTF-8"?>

<book xmlns='http://docbook.org/ns/docbook'>
  <title>An Example Book</title>
  <titleabbrev>Example</titleabbrev>
  <info>
    <legalnotice><para>No notice is required.</para></legalnotice>
    <author><personname>
      <firstname>Norman</firstname><surname>Walsh</surname>
    </personname></author>
  </info>

  <dedication>
  <para>
      This book is dedicated to you.
  </para>
  </dedication>

  <preface>
    <title>Foreword</title>
    <para>
        Some content is always required.
    </para>
  </preface>

  <chapter>
    <title>A Chapter</title>
    <para>
        Content is required in chapters too.
    </para>
  </chapter>

  <appendix>
    <title>Optional Appendix</title>
    <para>
        Appendixes are optional.
    </para>
  </appendix>
</book>

刚刚通过我的 Maven 环境之一将其渲染为 PDF。您能否给出一个包含某些内容的小示例(或几个单独的示例),这使得需要使用所有附加名称空间。

如果上面的示例不起作用,并且您对我如何设置环境感兴趣,请阅读 使 DocBook 内容在 Maven 项目站点中可用。只需将示例替换为上面的 DocBook 5.0 示例即可。对于这个问题,只有 docbkx-maven-plugin 感兴趣。 (PS:为此需要一些 Java 和 Maven2 的基础知识。)

Apart from the header you gave, did you try a smaller example, like this one from the DocBook 5.0: The Definitive Guide ?

<?xml version="1.0" encoding="UTF-8"?>

<book xmlns='http://docbook.org/ns/docbook'>
  <title>An Example Book</title>
  <titleabbrev>Example</titleabbrev>
  <info>
    <legalnotice><para>No notice is required.</para></legalnotice>
    <author><personname>
      <firstname>Norman</firstname><surname>Walsh</surname>
    </personname></author>
  </info>

  <dedication>
  <para>
      This book is dedicated to you.
  </para>
  </dedication>

  <preface>
    <title>Foreword</title>
    <para>
        Some content is always required.
    </para>
  </preface>

  <chapter>
    <title>A Chapter</title>
    <para>
        Content is required in chapters too.
    </para>
  </chapter>

  <appendix>
    <title>Optional Appendix</title>
    <para>
        Appendixes are optional.
    </para>
  </appendix>
</book>

Just rendered it to a PDF through one of my Maven environments. Can you give a small example (or a few separated onces) containing some content, which makes the use of all the additional name spaces necessary.

In case the above example does not work, and you are interested in how I have setup my environment read Making DocBook content available in a Maven project site. Just replace the example with the above DocBook 5.0 example. Only the docbkx-maven-plugin is of interest, in relation to this question. (PS: Some basic knowledge of Java and Maven2 is required for this.)

他夏了夏天 2024-09-04 13:43:18

Publican

您可以使用 Publican 以 PDF、html 和 html-single 格式发布 DocBook XML。 Publican 被红帽用作其内部文档工具链的一部分,并且是由 Fedora 项目托管的开源应用程序。该工具使用“品牌”来实现将样式应用于所发布内容的模块化。这种预设方式模拟了各种 CMS 或文档工具。

JBoss 文档指南

JBoss Press Gang 文档 是该工具的一个很好的示例,它本身就是一个很好的资源,为文档社区提供有关在 JBoss 文档中使用 DocBook XML 的指导。 html 和 PDF 版本是用 Publican 生成的。

Publican

You can use Publican to publish your DocBook XML in PDF, html, and html-single formats. Publican is used by Red Hat as part of its internal documentation toolchain, and is an open source application hosted by the Fedora project. The tool uses "brands" to achieve a modularity in applying styles to the content being published. This preset manner simusing a wide variety of CMS or documentation tools.

JBoss Documentation Guide

A good example of the tool in action is the JBoss Press Gang documentation, which is itself a great resource the gives documentation community guidance on the use of DocBook XML in JBoss documentation. The html and PDF versions were generated with Publican.

橘寄 2024-09-04 13:43:18

Docbook 4.5 和 5.0 之间存在显着差异。这些差异可能会阻止您的文档被转换。

如果你想检查你的5.0文档的有效性,你可以使用以下命令行工具:

  1. 它是一个java工具,所以你需要有一个最新的java运行环境。

  2. 工具是Jing。您可以从 thaiopensource 网站下载它:
    http://www.thaiopensource.com/relaxng/jing.html

  3. 您还需要 docbook 5.0 的relax ng 文件。它随 docbook 5 发行版提供。

  4. 使用以下命令行运行验证测试:
    java -jar path_to_Jing/jing.jar -t -i path_to_docbook5/docbook.rng document.xml

如果有一些失败,应该这样返回:Error at URL "file:...../document.xml",第 211 行,第 59 列:命名空间“http:// 中的属性“id”值错误www.w3.org/XML/1998/namespace
经过时间 968+166=1134 毫秒

There are significant differences between Docbook 4.5 and 5.0. And those differences can prevent your document from being transformed.

If you want to check the validity of your 5.0 document, you can use the following command line tool:

  1. it's a java tool, so you need to have a recent java runtime environment.

  2. the tool is Jing. You can download it from thaiopensource web site:
    http://www.thaiopensource.com/relaxng/jing.html

  3. you will also need the relax ng file for docbook 5.0. It is provided with the docbook 5 distribution.

  4. run the validation test with the following command line:
    java -jar path_to_Jing/jing.jar -t -i path_to_docbook5/docbook.rng document.xml

If there are some failures, they should be returned this way: Error at URL "file:...../document.xml", line number 211, column number 59: bad value for attribute "id" from namespace "http://www.w3.org/XML/1998/namespace"
Elapsed time 968+166=1134 milliseconds

[旋木] 2024-09-04 13:43:18

http://docbookpublishing.com 支持 DocBook 5.0 文档。它是 DocBook 到 PDF 格式的在线服务。您还可以通过 REST API 提交 DocBook 文档。

http://docbookpublishing.com supports DocBook 5.0 documents. It is an online service for DocBook to PDF formatting. You can also submit your DocBook documents via the REST API.

誰認得朕 2024-09-04 13:43:18

转到 Eclipse 并安装 DocBook 编辑和处理 Eclipse (DEP4E) 插件。您可以通过进入市场并在那里搜索文档来找到它。该插件将创建一个示例文档书,并可以以 html、pdf 甚至电子书的形式发布。

或者查看 DEP4E 网站,阅读 快速入门指南部分3.入门,了解它的可能性。

Go to Eclipse and install DocBook Editing and Processing for Eclipse (DEP4E) plugin. You can find it by going into marketplace and search for docbook there. This plugin will create an example docbook and can publish in html, pdf, and even ebook.

Or check out the DEP4E web site, read the Quick Starter Guide section 3. Getting Started, to get an idea of it's possibilities.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文