lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] help with orphan-control in xsl-fo


From: Vaclav Slavik
Subject: Re: [lmi] help with orphan-control in xsl-fo
Date: Fri, 24 Apr 2009 21:05:56 +0200

On Wed, 2009-04-22 at 18:05 -0400, Wendy Boutin wrote:
> and found these comments:
>   <!--
>   Ensure that a group of 5 rows is never split across multiple pages.
>   Add a dummy cell, that spans 5 rows. Since FOP avoids breaking cells,
>   this cell remains on one page, so will the group of 5 rows.
>   -->
> in 'fo_common.xsl', but we just don't know enough about xsl
> to see how to fix the problem the right way.

XSL-FO has dedicated keep-with-next and keep-with-previous properties
[1] that can be used to implement this grouping cleanly, as is done in
this patch:


=== modified file 'fo_common.xsl'
--- fo_common.xsl       2008-12-27 02:57:00 +0000
+++ fo_common.xsl       2009-04-24 17:38:42 +0000
@@ -663,6 +663,13 @@
     <xsl:param name="add-dummy-row-if-empty" select="boolean(1)"/>
     <xsl:if test="$counter &lt;= $max-counter">
       <fo:table-row>
+        <!-- Ensure that a group of 5 rows is never split across multiple 
pages -->
+        <xsl:if test="($counter + $inforceyear) mod 5 != 0">
+          <!-- but only if it's not the last row of the table -->
+          <xsl:if test="$counter &lt; $max-counter">
+            <xsl:attribute name="keep-with-next">always</xsl:attribute>
+          </xsl:if>
+        </xsl:if>
         <xsl:for-each select="$columns">
           <fo:table-cell padding="1pt .5pt 0">
             <!-- Add some space after each 5th year -->
@@ -698,16 +705,6 @@
             </fo:block>
           </fo:table-cell>
         </xsl:for-each>
-        <!--
-        Ensure that a group of 5 rows is never split across multiple pages.
-        Add a dummy cell, that spans 5 rows. Since FOP avoids breaking cells,
-        this cell remains on one page, so will the group of 5 rows.
-        -->
-        <xsl:if test="($counter + $inforceyear) mod 5 = 1">
-          <fo:table-cell number-rows-spanned="5">
-            <fo:block/>
-          </fo:table-cell>
-        </xsl:if>
       </fo:table-row>
       <xsl:call-template name="generate-table-values">
         <xsl:with-param name="columns" select="$columns"/>


Unfortunately, even though Apache FOP has limited support for these
properties [2], it doesn't seem to implement keep-with-next correctly in
the 0.20.5 release we use. Upgrading to 0.95 (or even 0.93, which is
what I have installed on my workstation) helps and the stylesheet
produces results that are as far as I can tell correct.

To be precise, no 5-rows groups are page boundaries anymore (the cell
hack used previously didn't prevent this with FOP 0.93) and there are no
text overlaps, even though cells' text can touch footer text (missing
padding for the footer?).

Regards,
Vaclav

[1] http://www.ibm.com/developerworks/xml/library/x-tippgbk/index.html
[2] http://xmlgraphics.apache.org/fop/compliance.html#fo-property-keep-with-next





reply via email to

[Prev in Thread] Current Thread [Next in Thread]