当前位置: 动力学知识库 > 问答 > 编程问答 >

xslt - Apache FOP keeping two elements together not working

问题描述:

I have following xslt:

 <xsl:template match="P">

<fo:block>

1.1 First Image

</fo:block>

<xsl:apply-templates />

</xsl:template>

<xsl:template match="figure">

<fo:block margin-top="-0.30in" keep-with-previous.within-page="always">

<fo:external-graphic>

<xsl:attribute name="src"> <xsl:value-of select="abc.svg" />

</xsl:attribute>

</fo:external-graphic>

</fo:block>

</xsl:template>

Both these templates will be called in a recursive method.

My output is :

P tag is coming in one page where it has space. Since figures are big, it shows in the next page. I want them to be together.

Tried solutions: keep-with, break-after, page-break-after.

Keep-with is not working. Others are creating new page for every P tag though there is space in the previous tag.

I am generating PDF output using FOP1.0.

Please help.

Thanks in advance.

网友答案:

change

<xsl:template match="P">
    <fo:block>
        1.1 First Image
    </fo:block>
    <xsl:apply-templates />
</xsl:template>

to

<xsl:template match="P">
    <fo:block keep-with-next.within-page="always">
        1.1 First Image
    </fo:block>
    <xsl:apply-templates />
</xsl:template>
分享给朋友:
您可能感兴趣的文章:
随机阅读: