使用 docbook 从 XML 和 CSS 生成输出 - 适用于 HTML,适用于 PDF

发布于 2024-09-29 22:18:26 字数 3023 浏览 0 评论 0原文

从一系列 xml 文件和样式表开始,我使用 docbook-xsl-ns-1.73、libxslt-1.1.22.win32 和 fop-0.94 生成 HTML 文件。样式表规定代码块必须具有编号行和灰色背景。 这是将 xml 转换为 html 的任务的一部分:

<exec executable="${XSLTPROC_EXECUTABLE}">
     <arg value="--output" />
     <arg value="${target.html.dir}/${book}_toc.xml" />

     <arg value="--xinclude" />

     <arg value="--param" />
     <arg value="html.stylesheet" />
     <arg value="'css/visixd-docbook.css'" />

     <arg value="--param" />         
     <arg value="chunk.separate.lots" />
     <arg value="1" />

     <arg value="--param" />         
     <arg value="chunk.first.sections" />
     <arg value="1" />

     <arg value="--param" />
     <arg value="chunk.section.depth" />
     <arg value="8" />

     <arg value="--param" />         
     <arg value="toc.section.depth" />
     <arg value="3" />

     <arg value="--param" />         
     <arg value="navig.graphics" />
     <arg value="1" />

     <arg value="--param" />         
     <arg value="ignore.image.scaling" />
     <arg value="1" />

     <arg value="src/reusable/xsl/makeCustomToc.xsl" />
     <arg value="src/workspace/${book}/${language}/${book}.xml" />
    </exec> 

现在该任务工作得很好,产生了所需的输出。

用于将 xml 转换为 pdf 的类似任务具有以下参数:

<exec executable="${XSLTPROC_EXECUTABLE}">
     <arg value="--output" />
     <arg value="${target.fo.dir}/${book}.fo" />

     <arg value="--param" />
     <arg value="paper.type" />
     <arg value="'USletter'" />         

     <arg value="--param" />
     <arg value="img.src.path" />
     <arg value="'src/workspace/${book}/${language}/'" />

     <arg value="--param" />
     <arg value="fop.extensions" />
     <arg value="0" />

     <arg value="--param" />
     <arg value="fop1.extensions" />
     <arg value="1" />

     <arg value="--param" />
     <arg value="pdf.stylesheet" />
     <arg value="'css/visixd-docbook.css'" />

     <arg value="--xinclude" />

     <arg value="--param" />         
     <arg value="chunk.separate.lots" />
     <arg value="1" />

     <arg value="--param" />         
     <arg value="chunk.first.sections" />
     <arg value="1" />

     <arg value="--param" />
     <arg value="chunk.section.depth" />
     <arg value="8" />

     <arg value="--param" />         
     <arg value="toc.section.depth" />
     <arg value="3" />

     <arg value="${DOCBOOK_XSL_HOME}/fo/docbook.xsl" />
     <arg value="src/workspace/${book}/${language}/${book}.xml" />
    </exec>

问题是我的 pdf 转换 ant 任务无法按照样式表中的说明格式化代码行。 有什么问题吗?考虑到到 html 的转换使用相同的样式表并且有效。 我应该去哪里寻找解决方案? 提前致谢。

Starting from a series of xml files and a stylesheet I generate a HTML file using docbook-xsl-ns-1.73, libxslt-1.1.22.win32 and fop-0.94. the stylesheet says that code chunks must have numbered lines and a gray background.
here is the piece of the and task that converts xmls to html:

<exec executable="${XSLTPROC_EXECUTABLE}">
     <arg value="--output" />
     <arg value="${target.html.dir}/${book}_toc.xml" />

     <arg value="--xinclude" />

     <arg value="--param" />
     <arg value="html.stylesheet" />
     <arg value="'css/visixd-docbook.css'" />

     <arg value="--param" />         
     <arg value="chunk.separate.lots" />
     <arg value="1" />

     <arg value="--param" />         
     <arg value="chunk.first.sections" />
     <arg value="1" />

     <arg value="--param" />
     <arg value="chunk.section.depth" />
     <arg value="8" />

     <arg value="--param" />         
     <arg value="toc.section.depth" />
     <arg value="3" />

     <arg value="--param" />         
     <arg value="navig.graphics" />
     <arg value="1" />

     <arg value="--param" />         
     <arg value="ignore.image.scaling" />
     <arg value="1" />

     <arg value="src/reusable/xsl/makeCustomToc.xsl" />
     <arg value="src/workspace/${book}/${language}/${book}.xml" />
    </exec> 

now this task works perfectly fine, producing the desired output.

the similar task used for converting xmls to pdf has these parameters:

<exec executable="${XSLTPROC_EXECUTABLE}">
     <arg value="--output" />
     <arg value="${target.fo.dir}/${book}.fo" />

     <arg value="--param" />
     <arg value="paper.type" />
     <arg value="'USletter'" />         

     <arg value="--param" />
     <arg value="img.src.path" />
     <arg value="'src/workspace/${book}/${language}/'" />

     <arg value="--param" />
     <arg value="fop.extensions" />
     <arg value="0" />

     <arg value="--param" />
     <arg value="fop1.extensions" />
     <arg value="1" />

     <arg value="--param" />
     <arg value="pdf.stylesheet" />
     <arg value="'css/visixd-docbook.css'" />

     <arg value="--xinclude" />

     <arg value="--param" />         
     <arg value="chunk.separate.lots" />
     <arg value="1" />

     <arg value="--param" />         
     <arg value="chunk.first.sections" />
     <arg value="1" />

     <arg value="--param" />
     <arg value="chunk.section.depth" />
     <arg value="8" />

     <arg value="--param" />         
     <arg value="toc.section.depth" />
     <arg value="3" />

     <arg value="${DOCBOOK_XSL_HOME}/fo/docbook.xsl" />
     <arg value="src/workspace/${book}/${language}/${book}.xml" />
    </exec>

the problem is my ant task for pdf conversion fails to format code lines as stated in the stylesheet.
what can be wrong? considering that the conversion to html uses the same stylesheet and works.
where should i look for a solution?
thanks in advance.

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

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

发布评论

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

评论(1

笑,眼淚并存 2024-10-06 22:18:26

您正在尝试使用 CSS 格式化 FO/PDF 输出。那是行不通的。

常用的 DocBook XSL 样式表没有名为 pdf.stylesheet 的参数。 chunk.* 参数仅用于 HTML 输出。

“代码块”和“代码行”是什么意思?您是指 XML 源中的 元素吗?

您应该查阅有关使用 DocBook XSL 的权威参考: http://www.sagehill.net/docbookxsl/索引.html

You are trying to format FO/PDF output using CSS. That does not work.

The stock DocBook XSL stylesheets do not have a parameter called pdf.stylesheet. And the chunk.* parameters are for HTML output only.

What do you mean by "code chunks" and "code lines"? Do you mean <programlisting> elements in the XML source?

You should consult the definitive reference for using DocBook XSL: http://www.sagehill.net/docbookxsl/index.html.

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