Preventing contents of the row from disappering

Here should go questions about transforming XML with XSLT and FOP.
shiney_98
Posts: 12
Joined: Thu Sep 09, 2021 12:03 pm

Preventing contents of the row from disappering

Post by shiney_98 »

Hi,

I want to keep my contents of the row on the same page , so I've used keep-together.within-page="always" on fo:table-row and I'm getting expected output i.e. when the contents of the row are more, it is moving to next page with the header rows.

But, when the contents of the row exceeds more than one page, the contents are getting disappeared. I want the contents to move to next page if it exceeds more than one page i.e. page break inside those rows are acceptable but when the contents are small it should move to next page. Any Ideas?
julien_lacour
Posts: 495
Joined: Wed Oct 16, 2019 3:47 pm

Re: Preventing contents of the row from disappering

Post by julien_lacour »

Hello,

Usually in DITA Map PDF - based on XSL-FO transformation, table rows are generated like this:

Code: Select all

<xsl:template match="*[contains(@class, ' topic/tbody ')]/*[contains(@class, ' topic/row ')]">
  <fo:table-row xsl:use-attribute-sets="tbody.row">
    <xsl:call-template name="commonattributes"/>
    <xsl:apply-templates/>
  </fo:table-row>
</xsl:template>
...
<xsl:attribute-set name="tbody.row">
  <!--Table body row-->
  <xsl:attribute name="keep-together.within-page">always</xsl:attribute>
</xsl:attribute-set>
 
By adding the following template you can create rows without the keep-together.within-page="always" attribute:

Code: Select all

<xsl:template match="*[contains(@class, ' topic/tbody ')]/*[contains(@class, ' topic/row ') 
  and @outputclass='break-on-two-pages')]">
  <fo:table-row>
    <xsl:call-template name="commonattributes"/>
    <xsl:apply-templates/>
  </fo:table-row>
</xsl:template>
After adding the previous template, in your DITA source you must add the @outputclass="break-on-two-pages" attribute on the rows that must not be kept on the same page.

You can run the transformation with the 'clean.temp=no' parameter then check the topic.fo file.
It must not contain <fo:table-row keep-together.within-page="always"> on the rows marked with the outputclass.

Regards,
Julien
Post Reply