Search code examples
xslt-1.0xsl-fo

How to keep rows together on a page xsl fo?


I want code and its description to be displayed on same page. If the description is long then code and description both should be displayed on next page.

<xsl:template match="LineOfTastingNote">
<fo:table-row font-family="Avenir" keep-together.within-page="always" >
  
  <fo:table-cell padding-bottom="0.5mm" padding-left="0.1cm" >
    <fo:block font-size="8pt" text-align="left" font-weight="bold">
   <xsl:value-of select="Code" /> 
    </fo:block>
  </fo:table-cell>
  
</fo:table-row>

 <fo:table-row font-family="Avenir" >
  
  
  <fo:table-cell padding-left="0.1cm" padding-bottom="0.5mm" padding-right="8cm" >
    <fo:block font-size="8pt" text-align="left">
    <xsl:value-of select="Description" /> 
    </fo:block>
  </fo:table-cell>

</fo:table-row>



 </xsl:template>

Example:

product1
Apple Cider vineger1
product2
Apple Cider vineger2
*
*
*

productlastofpage
-------------------------------end of page 1 
-------------------------------start of page 2
Apple Cider vinegerend


 -------------------------------endof page 2

I want code productlastofpage to be displayed on page 2 with its description 'Apple Cider vinegerend', tried keep-together.within-page="always" but no luck.


Solution

  • You want keep-with-next.within-page (see https://www.w3.org/TR/xsl11/#keep-with-next), not keep-together.within-page.

    Your keep-together.within-page="always" just kept that table row together on the one page and didn't say anything about the next row.

    There's also keep-with-previous (including keep-with-previous.within-page).