You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Sam Fuqua <sa...@gmail.com> on 2009/03/26 19:23:47 UTC
break-after, Exclude last page
I'm generating a PDF from an xml feed. The feed has a list of items, and I
want each new item on a new page, but I don't want the last page to break
onto a new blank page. How would I do this?
Right now, I have the following:
<fo:page-sequence initial-page-number="1" master-reference="PageMaster">
<fo:static-content flow-name="xsl-region-before">
<fo:block font-size="8pt"
text-align="right"><fo:page-number/>/<fo:page-number-citation
ref-id="last-page"/></fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates/>
<fo:block id="last-page"/>
</fo:flow>
</fo:page-sequence>
<xsl:template match="item">
<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"
break-after="page">
<-- call other templates -->
</fo:block>
</xsl:template>
--
Sam Fuqua
ΣΝ ΘΗ 454
Re: break-after, Exclude last page
Posted by Sam Fuqua <sa...@gmail.com>.
Thanks, this worked perfectly.
2009/3/26 Amick, Eric <Er...@mail.house.gov>
> One possible solution, assuming no item contains another item, would be
> this:
>
> <xsl:template match="item">
> <fo:block xmlns:fo= <http://www.w3.org/1999/XSL/Format>
> http://www.w3.org/1999/XSL/Format <http://www.w3.org/1999/XSL/Format%22>">
> <xsl:if test="following::item">
> <xsl:attribute name="break-after">page</xsl:attribute>
> </xsl:if>
> <-- call other templates -->
> </fo:block>
> </xsl:template>
>
> If my assumption is wrong, you should be able to use "following::item |
> descendant::item" for the test.
>
> Eric Amick
> Legislative Computer Systems
> Office of the Clerk
>
>
> ------------------------------
> *From:* Sam Fuqua [mailto:samfuqua@gmail.com]
> *Sent:* Thursday, March 26, 2009 14:24
> *To:* fop-users@xmlgraphics.apache.org
> *Subject:* break-after, Exclude last page
>
> I'm generating a PDF from an xml feed. The feed has a list of items, and I
> want each new item on a new page, but I don't want the last page to break
> onto a new blank page. How would I do this?
> Right now, I have the following:
>
>
> <fo:page-sequence initial-page-number="1"
> master-reference="PageMaster">
> <fo:static-content flow-name="xsl-region-before">
> <fo:block font-size="8pt"
> text-align="right"><fo:page-number/>/<fo:page-number-citation
> ref-id="last-page"/></fo:block>
> </fo:static-content>
>
> <fo:flow flow-name="xsl-region-body">
> <xsl:apply-templates/>
> <fo:block id="last-page"/>
> </fo:flow>
> </fo:page-sequence>
>
> <xsl:template match="item">
> <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"
> break-after="page">
> <-- call other templates -->
> </fo:block>
> </xsl:template>
>
> --
> Sam Fuqua
> ΣΝ ΘΗ 454
>
--
Sam Fuqua
ΣΝ ΘΗ 454
RE: break-after, Exclude last page
Posted by "Amick, Eric" <Er...@mail.house.gov>.
One possible solution, assuming no item contains another item, would be this:
<xsl:template match="item">
<fo:block xmlns:fo= <http://www.w3.org/1999/XSL/Format> http://www.w3.org/1999/XSL/Format <http://www.w3.org/1999/XSL/Format"> ">
<xsl:if test="following::item">
<xsl:attribute name="break-after">page</xsl:attribute>
</xsl:if>
<-- call other templates -->
</fo:block>
</xsl:template>
If my assumption is wrong, you should be able to use "following::item | descendant::item" for the test.
Eric Amick
Legislative Computer Systems
Office of the Clerk
________________________________
From: Sam Fuqua [mailto:samfuqua@gmail.com]
Sent: Thursday, March 26, 2009 14:24
To: fop-users@xmlgraphics.apache.org
Subject: break-after, Exclude last page
I'm generating a PDF from an xml feed. The feed has a list of items, and I want each new item on a new page, but I don't want the last page to break onto a new blank page. How would I do this?
Right now, I have the following:
<fo:page-sequence initial-page-number="1" master-reference="PageMaster">
<fo:static-content flow-name="xsl-region-before">
<fo:block font-size="8pt" text-align="right"><fo:page-number/>/<fo:page-number-citation ref-id="last-page"/></fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates/>
<fo:block id="last-page"/>
</fo:flow>
</fo:page-sequence>
<xsl:template match="item">
<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" break-after="page">
<-- call other templates -->
</fo:block>
</xsl:template>
--
Sam Fuqua
ΣΝ ΘΗ 454
Re: break-after, Exclude last page
Posted by Andreas Delmelle <an...@telenet.be>.
On 26 Mar 2009, at 19:23, Sam Fuqua wrote:
Hi
An XSLT question that, strictly speaking does not belong on this list,
but anyway...
> I'm generating a PDF from an xml feed. The feed has a list of
> items, and I want each new item on a new page, but I don't want the
> last page to break onto a new blank page. How would I do this?
>
> Right now, I have the following:
>
> <xsl:template match="item">
> <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" break-
> after="page">
> <-- call other templates -->
> </fo:block>
> </xsl:template>
Do something like:
<xsl:template match="item">
<fo:block>
<xsl:if test="not(position()=last())">
<xsl:attribute name="break-after">page</xsl:attribute>
</xsl:if>
<!-- call other templates -->
</fo:block>
</xsl:template>
Careful, because you're using a plain 'apply-templates' on the higher
level, and that would include possible text-nodes... If the above
doesn't work, try using: <xsl:apply-templates select="*"/> instead.
That only selects the element nodes, and hence produces 'expected'
results for position() and last().
HTH!
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org