gpt4 book ai didi

xml - XSL-FO:在每个 之间强制分页

转载 作者:数据小太阳 更新时间:2023-10-29 02:59:14 28 4
gpt4 key购买 nike

我正在尝试生成带有 pdf 生成的模组规范。我生成它的方式是使用如下所示的 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>

以便它拾取 <?hard-pagebreak?>在 .xml 文件中。我想让解决方案尽可能紧凑,那么我该如何编辑我的样式表,以便第一遍添加 <?hard-pagebreak?>在每个 <xi:include> 之后后面是给我的 sagehill 的模板?

最佳答案

这个样式表:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude">
<xsl:template match="@*|node()" name="identity">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xi:include">
<xsl:call-template name="identity"/>
<xsl:processing-instruction name="hard-pagebreak"/>
</xsl:template>
</xsl:stylesheet>

输出:

<article 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"
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">
<title>Mod Spec</title>
<?dbfo-need height="8in" space-before="3em" ?>
<xi:include href="first.xml"></xi:include>
<?hard-pagebreak?>
<section>
<title>View Stuff</title>
<xi:include href="./stuff/panel.xml"></xi:include>
<?hard-pagebreak?>
</section>
<section>
<title>Nav things</title>
<xi:include href="./things/about.xml"></xi:include>
<?hard-pagebreak?>
<xi:include href="./things/control.xml"></xi:include>
<?hard-pagebreak?>
<xi:include href="./things/launch.xml"></xi:include>
<?hard-pagebreak?>
</section> ...(more sections with includes)
</article>

那么,您可以将匹配 fictitious hard-pagebreak 处理指令的模板添加到 DocBook 到 FOP 样式表中强>

关于xml - XSL-FO:在每个 <xi:include> 之间强制分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4674978/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com