2

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のすべてのsperatemodspecsの間にページ分割を追加するにはどうすればよいですか?

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>後に追加され、その後にセージヒルのテンプレートが追加されるようにするにはどうすればよいですか?

4

2 に答える 2

3

このスタイルシート:

<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>

したがって、架空の hard-pagebreak処理命令に一致するテンプレートをDocBooktoFOPスタイルシートに追加できます。

于 2011-01-13T00:24:24.073 に答える
2

出力でページ分割を強制する<?hard-pagebreak?>には、XMLソースドキュメントに手動で直接処理命令を追加し(既に追加したのと同じ方法で<?dbfo-need height="8in" space-before="3em"?>)、

<xsl:template match="processing-instruction('hard-pagebreak')">
  <fo:block break-after='page'/>  
</xsl:template> 

スタイルシートのカスタマイズレイヤーで。必要に応じて、追加の変換ステップを使用してPIを追加する@Alejandroの提案を使用できますが、実際には必要ありません(IMHO)。

于 2011-01-13T18:35:01.657 に答える