|
Subject: Re: [xsl] Different footer in fo:region-after From: Brandon Ibach <brandon.ibach@xxxxxxxxxxxxxxxxxxx> Date: Fri, 28 Jan 2011 08:16:15 -0500 |
Put another <fo:marker marker-class-name="footfields"> inside the
<fo:block id="{generate-id(.)}"/> at the end of your stylesheet. The
contents of this marker should show up on the last page (though you
may need to play with the "retrieve-position" attribute on the
fo:retrieve-marker to get it just right).
-Brandon :)
On Fri, Jan 28, 2011 at 7:37 AM, Arjan Bokx <abokx@xxxxxxxxxxx> wrote:
>
> Hello,
>
> I have XML data in the following format:
> There's one batch, which can contain multiple invoices, which can contain
multiple detail lines.
>
>
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> <batch>
> <invoice>
> <id>Invoice1</id>
> <date>28-01-2011</date>
> <detail>
> <spec>Smurfs</spec>
> <amount>10.00</amount>
> </detail>
> <detail>
> <spec>LCD screen</spec>
> <amount>155.50</amount>
> </detail>
> </invoice>
> <invoice>
> <id>Invoice2</id>
> <date>27-01-2011</date>
> <detail>
> <spec>Rice</spec>
> <amount>5.00</amount>
> </detail>
> <detail>
> <spec>Wheat</spec>
> <amount>27.00</amount>
> </detail>
> </invoice>
> </batch>
>
>
> I have written XSL to make every invoice start on a new page. Detail lines
may spill over to extra pages, on which the same header and footer are
printed. So far, so good. It even has page numbers; numbering starts at 1 for
every new invoice.
> I use Apache fop 1.0.
> The XSL I have so far is (minimized but working example):
>
>
>
> <?xml version="1.0"
> encoding="ISO-8859-1" ?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fo="http://www.w3.org/1999/XSL/Format">
> <xsl:output method="xml"
> indent="yes" />
> <xsl:strip-space elements="*" />
> <xsl:template match="/">
> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
> <fo:layout-master-set>
> <fo:simple-page-master master-name="A4"
> page-height="29.7cm"
> page-width="21cm"
> margin-top="6mm"
> margin-bottom="18mm"
> margin-left="6mm"
> margin-right="0.25cm">
> <fo:region-body region-name="xsl-region-body"
> margin-top="73mm"
> margin-bottom="29mm"/> <!-- page body
-->
> <fo:region-before region-name="xsl-region-before"
> extent="73mm"/> <!-- page
header -->
> <fo:region-after region-name="xsl-region-after"
> extent="29mm"/> <!-- page
footer -->
> </fo:simple-page-master>
> </fo:layout-master-set>
> <xsl:apply-templates select="/batch" />
> </fo:root>
> </xsl:template>
> <xsl:template match="invoice">
> <fo:page-sequence master-reference="A4"
> initial-page-number="1"
> force-page-count="no-force">
> <fo:static-content flow-name="xsl-region-before">
> <fo:block>
> <fo:retrieve-marker retrieve-class-name="headfields"/>
> </fo:block>
> </fo:static-content>
> <fo:static-content flow-name="xsl-region-after">
> <fo:block>
> <fo:retrieve-marker retrieve-class-name="footfields"/>
> </fo:block>
> </fo:static-content>
> <fo:flow flow-name="xsl-region-body">
> <fo:block break-before="page">
> <xsl:call-template name="invoice-lines" />
> </fo:block>
> </fo:flow>
> </fo:page-sequence>
> </xsl:template>
>
> <xsl:template name="invoice-lines">
>
> <fo:marker marker-class-name="headfields">
> <fo:block>
> <fo:page-number />
> <xsl:text> / </xsl:text>
> <fo:page-number-citation ref-id="{generate-id(.)}" />
> </fo:block>
> <!-- other header stuff -->
> </fo:marker>
>
> <fo:marker marker-class-name="footfields">
> <!-- footer stuff -->
> </fo:marker>
>
> <xsl:for-each select="detail">
> <fo:block>
> <xsl:value-of select="spec" />
> </fo:block>
> </xsl:for-each>
> <fo:block id="{generate-id(.)}" />
> </xsl:template>
> </xsl:stylesheet>
>
>
> What I want now, but fail to accomplish, is:
> Only on the last page of every invoice, there must be an extra field in the
footer with, say, the contents of batch.invoice.id
> Have you any hints or directions?
>
>
> Thanks in advance,
> Arjan
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Different footer in fo:region, Arjan Bokx | Thread | RE: [xsl] Different footer in fo:re, Arjan Bokx |
| Re: [xsl] Re: XPath related query, Brandon Ibach | Date | RE: [xsl] Different footer in fo:re, Arjan Bokx |
| Month |