XSL-FO:在每个之间强制分页。
我正在尝试使用 pdf 生成功能生成 mod 规范。我生成它的方式是使用一个contents.xml文件,它看起来像这样...
<?xml version="1.0" encoding="UTF-8"?>
<article xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xi="http://www.w3.org/2001/XInclude"
xsi:schemaLocation="http://docbook.org/ns/docbook http://schema.5d.ca/docbook/docbook.xsd
http://www.w3.org/2001/XInclude http://schema.5d.ca/docbook/XInclude.xsd">
<title>Mod Spec</title>
<?dbfo-need height="8in" space-before="3em" ?>
<xi:include href="first.xml"/>
<section>
<title>View Stuff</title>
<xi:include href="./stuff/panel.xml"/>
</section>
<section>
<title>Nav things</title>
<xi:include href="./things/about.xml"/>
<xi:include href="./things/control.xml"/>
<xi:include href="./things/launch.xml"/>
</section>
...(more sections with includes)
</article>
现在我还有一个样式表,在上面的xml发送给XSL-FO之前设置页眉、页脚和表格样式内容,并且该样式表需要添加分页符。
所以我的问题是:如何在contents.xml 中的所有单独的modspec 之间添加分页符?
编辑 http://www.sagehill.net/docbookxsl/PageBreaking.html 我应该添加的状态将其添加到我的 XSLT:
<xsl:template match="processing-instruction('hard-pagebreak')">
<fo:block break-after='page'/>
</xsl:template>
以便它在 .xml 文件中获取 。我希望使解决方案尽可能紧凑,那么如何编辑样式表,以便第一遍在每个
< 之后添加
后跟给定我的 sagehill 的模板? xi:include>
I'm trying to generate a mod spec with pdf generation. The way I have it be generated is using a contents.xml file which looks like this...
<?xml version="1.0" encoding="UTF-8"?>
<article xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xi="http://www.w3.org/2001/XInclude"
xsi:schemaLocation="http://docbook.org/ns/docbook http://schema.5d.ca/docbook/docbook.xsd
http://www.w3.org/2001/XInclude http://schema.5d.ca/docbook/XInclude.xsd">
<title>Mod Spec</title>
<?dbfo-need height="8in" space-before="3em" ?>
<xi:include href="first.xml"/>
<section>
<title>View Stuff</title>
<xi:include href="./stuff/panel.xml"/>
</section>
<section>
<title>Nav things</title>
<xi:include href="./things/about.xml"/>
<xi:include href="./things/control.xml"/>
<xi:include href="./things/launch.xml"/>
</section>
...(more sections with includes)
</article>
Now I also have a stylesheet that sets header, footer, and table style stuff before the above xml is sent off for XSL-FO, and this stylesheet will need to add the page breaks.
So my question is: How do do I add a page break between all my sperate modspecs in contents.xml?
EDIT
http://www.sagehill.net/docbookxsl/PageBreaking.html States I should add this to my XSLT:
<xsl:template match="processing-instruction('hard-pagebreak')">
<fo:block break-after='page'/>
</xsl:template>
So that it picks up <?hard-pagebreak?>
in the .xml files. I would like to keep the solution as compact as possible, so how do I edit my stylesheet so that a first pass will add the <?hard-pagebreak?>
after each <xi:include>
followed by the template given my sagehill?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此样式表:
输出:
因此,您可以将匹配虚构
硬分页
处理指令的模板添加到到 DocBook 到 FOP 样式表中This stylesheet:
Output:
So, then you can add that template matching fictitious
hard-pagebreak
processing instruction into the DocBook to FOP stylesheet要在输出中强制分页,您应该直接手动添加
处理指令到 XML 源文档(与您已经添加的方式相同)添加了
),并放入
样式表自定义层。如果您愿意,您可以使用 @Alejandro 的建议,该建议使用额外的转换步骤添加 PI,但您实际上并不需要(恕我直言)。
To force page breaks in the output, the idea is that you should add
<?hard-pagebreak?>
processing instructions directly, by hand, to the XML source document (the same way you have already added<?dbfo-need height="8in" space-before="3em"?>
), and putin the stylesheet customization layer. If you want, you could use @Alejandro's suggestion which adds the PIs using an extra transformation step, but you don't really need that (IMHO).