XSL-FO:如何添加变量页面主引用

时间:2014-04-03 15:00:04

标签: xml xslt xslt-1.0 xsl-fo

我正在处理一个双面文档,需要一个首页(带有一个图像,例如'Letterhead.jpg'),该页面的支持者(带有支持者图像,例如'Backer.jpg'),如果有的话首页流过页面边界,它流入“延续”页面(图像'延续')。此延续页面还需要在背面具有相同的“continuation.jpg”图像,然后信息流入该反向页面。

我遇到了正确设置问题。 我目前的主页工作正常,但从那里我没有按照我的意愿格式化。 如果主页面没有溢出,则反之在于默认拉动延续图形。然后当出现溢出时,数据会流到支持者(带有延续图形),然后是任何后续页面。

对不起,如果这个帖子混淆了,我不能很好地解释,我总结,我需要的是:

主页:使用 letterhead.jpg 图形流式传输数据。

反向主页:没有数据流入此处。只有 backer.jpg 图形。 (如果来自主页面的流数据溢出页面边界,那么..)

续页:使用 continuation.jpg 图形继续主数据流。

延续页面的反转:来自Continuation页面的流数据的延续,使用 continuation.jpg 图形。

结束页:最后一页的空白页。

这是我目前的代码:

 <fo:layout-master-set>
    <fo:page-sequence-master master-name="document">
        <fo:repeatable-page-master-alternatives>
              <fo:conditional-page-master-reference master-reference="continuation-even" page-position="first" odd-or-even="even"/>
              <fo:conditional-page-master-reference master-reference="letter" page-position="first"/>
              <fo:conditional-page-master-reference master-reference="continuation-odd" odd-or-even="odd"/>
              <fo:conditional-page-master-reference master-reference="continuation-rest" odd-or-even="even"/>
              <fo:conditional-page-master-reference master-reference="last" page-position="last" odd-or-even="even"/>
        </fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>      
<fo:simple-page-master master-name="letter" page-height="32.0cm" page-width="22.5cm" margin-top="1.15cm" margin-bottom="2.15cm" margin-left="0.75cm" margin-right="0.75cm">
    <fo:region-body margin-top="10.3cm" margin-bottom="2cm" margin-left="1.6cm" margin-right="2.5cm" />
        <fo:region-before region-name="letterhead graphic" extent="29.7cm"/>
                    </fo:simple-page-master>
                    <fo:simple-page-master master-name="continuation-odd" page-height="32.0cm" page-width="22.5cm" >
                        <fo:region-body margin-top="4.5cm" margin-bottom="1.8cm" margin-left="2.3cm" margin-right="2.0cm" />
                        <fo:region-before region-name="continuation graphic" extent="29.7cm"/>
                    </fo:simple-page-master>
                    <fo:simple-page-master master-name="continuation-even" page-height="32.0cm" page-width="22.5cm" >
                        <fo:region-body margin-top="32.0cm" margin-bottom="0cm" margin-left="2.5cm" margin-right="2.0cm" />
                            <fo:region-before region-name="backer" extent="29.7cm"/>
                    </fo:simple-page-master>
                    <fo:simple-page-master master-name="continuation-rest" page-height="32.0cm" page-width="22.5cm" >
                        <fo:region-body margin-top="4.5cm" margin-bottom="1.8cm" margin-left="2.3cm" margin-right="2.0cm" />
                        <fo:region-before region-name="continuation graphic" extent="29.7cm"/>
                    </fo:simple-page-master>
                    <fo:simple-page-master master-name="last" page-height="32.0cm" page-width="22.5cm" >
                        <fo:region-body margin-top="0.5cm" margin-bottom="0.5cm" margin-left="0.5cm" margin-right="2.0cm" />
                        <fo:region-before region-name="end-page" extent="29.7cm"/>
                    </fo:simple-page-master>
                    <fo:simple-page-master master-name="separator" page-height="32.0cm" page-width="22.5cm" margin-top="2.15cm" margin-bottom="1.15cm" margin-left="1.75cm" margin-right="0.75cm">
            <fo:region-body/>
    </fo:simple-page-master>
</fo:layout-master-set>

1 个答案:

答案 0 :(得分:2)

就是这样!

通过您提到的内容以及您添加的原始问题解决了问题。

以下是我们现在整理的代码,它完全符合我们的需求。

<xsl:template match="/">
    <fo:root>
        <fo:layout-master-set>
            <fo:page-sequence-master master-name="document">
                <fo:repeatable-page-master-alternatives maximum-repeats="2">
                    <fo:conditional-page-master-reference master-reference="front" odd-or-even="odd"/>
                    <fo:conditional-page-master-reference master-reference="back-special" odd-or-even="even"/>
                </fo:repeatable-page-master-alternatives>
                <fo:repeatable-page-master-alternatives>
                    <fo:conditional-page-master-reference master-reference="front" odd-or-even="odd"/>
                    <fo:conditional-page-master-reference master-reference="back" odd-or-even="even"/>
                </fo:repeatable-page-master-alternatives>
            </fo:page-sequence-master>
            <fo:simple-page-master master-name="front" page-height="29.7cm" page-width="21.0cm" margin-top="5cm" margin-bottom="5cm" margin-left="2.5cm" margin-right="2.5cm">
                <fo:region-body/>
            </fo:simple-page-master>
            <fo:simple-page-master master-name="back" page-height="29.7cm" page-width="21.0cm" margin-top="5cm" margin-bottom="5cm" margin-left="2.5cm" margin-right="2.5cm">
                <fo:region-body/>
            </fo:simple-page-master>
            <fo:simple-page-master master-name="back-special" page-height="29.7cm" page-width="21.0cm" margin-top="5cm" margin-bottom="25cm" margin-left="2.5cm" margin-right="2.5cm">
                <fo:region-body/>
                <fo:region-before region-name="special" extent="29.7cm"/>
            </fo:simple-page-master>
        </fo:layout-master-set> 

        <fo:page-sequence master-reference="document">
            <fo:static-content flow-name="special">
                <fo:block>
                    <fo:external-graphic src="url('special.jpg')"/>
                </fo:block>
            </fo:static-content>

            <fo:flow flow-name="xsl-region-body" font-family="Helvetica" font-size="14pt">
                <fo:block>
                    <xsl:for-each select="/data/item">
                        <fo:block space-after="2cm"><xsl:value-of select="."/></fo:block>
                    </xsl:for-each>
                </fo:block>
            </fo:flow>
        </fo:page-sequence>
    </fo:root>
</xsl:template>

感谢您的帮助!