2
votes

I'm working with XSL-FO (processed using Apache FOP).

My xsl code for tables looks like this:

<!-- ... Some xsl fo code with data occupying 1/2 page ... -->
<fo:table>
   <fo:table-header>
      Item Name 
   </fo:table-header>
   <fo:table-footer>
      Total: 
         <xsl:value-of select="total" />
   </fo:table-footer>
   <fo:table-body>
      <fo:table-row>
         <xsl:value-of select="itemName" />
      </fo:table-row> 
   </fo:table-body>
</fo:table>

I want to have a table footer at the bottom of every page (I tried using fo:table-footer).

I also want a footnote on the pages following the first one: if content requires more than a single page I need the footnote "Continuation of previous page" after the table footer.

The table footer must show the total value only on the last page (I mean if I've 6 pages of table content every page except last must have footer with total value as blank and last page footer with value).

XML source:

<itemDetail>
   <itemName>Car1</itemName>
   <itemName>Car2</itemName>
   <itemName>Car3</itemName>
   <itemName>Car4</itemName>
   <itemName>Car5</itemName>
   <itemName>Car6</itemName>
   <itemName>Car7</itemName>
   <itemName>Car8</itemName>
   <itemName>Car9</itemName>
   <itemName>Car10</itemName>
   <itemName>Car11</itemName>
   <itemName>Car12</itemName>
   <itemName>Car13</itemName>
   <itemName>Car14</itemName>
   <itemName>Car15</itemName>
   <itemName>Car16</itemName>
   <itemName>Car17</itemName>
   <itemName>Car18</itemName>
   <itemName>Car19</itemName>
   <itemName>Car20</itemName> 
</itemDetail>
<total>20</total>

Required sample output of page 1: Required sample output of page 1

Required sample output of Page 2: Required sample output of page 2

1
So you want 'Total" displayed at the bottom of every page but to display 'continuation of previous page' instead of the total on the page, then have the total display on last page of the document? ie you wont do this for multiple tables within a document?adam5990
If the table rows are all one row high and perfectly fit on the page, you can do what you want only in a page sequence where you define the footers in a marker and pull that marker to the footer. You can try with products that support table-markers too but don;t know if FOP supports that.Kevin Brown
Yes Adam . Actually I need the Total value in last Page Only (I've checked If condition in table footer but its not working .. Any Suggestions ??)Vamsi Krishna DS
Hey Kevin thanks for your reply . Can You Please Send the Tutorial Link for table Marker So that I Can go through and solve my issue according to your comment.Vamsi Krishna DS

1 Answers

1
votes

After re-reading your question, I would do this. You should have page templates for first, rest and last.

This is for two reasons --- (1) you want those table footers at the bottom and (2) many products (FOP included) do not support retrieve-table-marker. Retrieving markers into table-rows is very problematic for formatters, especially is the content retrieved is of such a size that it causes the table to reformat (like the row does not fit anymore).

The first page template region-after would have a single table-row with the "Total:" in it blank.

The rest page template region-after would have a single table-row with the "Total:" blank, followed by the "* Continuation of previous page".

The last page template would have nothing in the region-after for the Total:, just the "* Continuation of previous page".

When creating your table, add the "Total:" row in the table after adding all the other rows with the appropriate total in it. You could either just add at the end (without those blank rows) or if you are putting in the blank rows, then make the region-after one row smaller to accommodate this row. I would not recommend this this though, unless you must have the blank rows and all the tables must be the same height. You could also just leave in the footer and pull a marker to the footer without retrieve-table-marker.

The only caveat to this is whether the row size and page dimensions are chosen so that the "Total:" row that is placed in the region-after area matches up well with the rest of the table.

See How to position a block at the bottom in the region-body for page template setup and order. You could use the only page template in this case to put nothing in the region-after as you would not want the "*Continuation" line in that case.