Search code examples
xsltxslt-2.0xsl-foapache-fop

How do i add a continued text on the first row of the table body and not the table header in xsl fo?


I am trying to create dynamic tables in my pdfs using Apache FOP. I have achieved most of it and require some fine tuning. I have used the fo:retrieve-table-marker in the table header and it works perfectly. But i do want the same continued text on the first row of the table body. When i use the fo:retrieve-table-marker in the table body i get the below error :

(Location of error unknown)org.apache.fop.fo.ValidationException: "fo:fo:retrieve-table-marker" is not a valid child of "fo:block"! An fo:retrieve-table-marker is permitted only as the descendant of an fo:table-header or an fo:table-footer. (No context info available)

how do i achieve this?

here is my sample xsl :

<fo:table>
 <fo:table-header>
  <fo:table-row keep-with-next.within-page="always">
   <fo:table-cell>
    <fo:block>
    <fo:retrieve-table-marker retrieve-class-name="fortsSectionTitle" retrieve-position- within-table="first-starting"/>
                </fo:block>
   </fo:table-cell>
   </fo:table-row>
  </fo:table-header>
  <fo:table-body>
                <fo:table-row keep-with-next.within-page="always">
                <fo:table-cell>
                    <fo:block>
                        <fo:marker marker-class-name="fortsSectionTitle"/>
                    </fo:block>
                </fo:table-cell>
            </fo:table-row>
            <fo:table-row keep-with-next.within-page="always">
                <fo:table-cell>
                    <fo:block>
                        <fo:marker marker-class-name="fortsSectionTitle">
                            <xsl:text>&#160;forts.</xsl:text>
                        </fo:marker>
                    </fo:block>
                </fo:table-cell>
            </fo:table-row>
        <!--this is my first row of table body -->
       <fo:table-row>
        <fo:table-cell>
         <fo:block>
          <fo:retrieve-table-marker retrieve-class-name="fortsSectionTitle" retrieve- 
 position-within-table="1"/>
         </fo:block>
         </fo:table-cell>
       <fo:table-row>
       <!-- rest of my table rows with details -->
       ...
     </fo:table-body>
     </fo:table>

Desired output :

PAGE 1:

HEADER
1ST ROW OF TABLE BODY
.
.
.

PAGE 2:

HEADER cont.
1ST ROW OF TABLE BODY cont.
.
.
.

Solution

  • Retrieving markers inside an fo:table-body is not supported by the XSL 1.1 spec.

    The spec says that an fo:retrieve-table-marker can be be used in place of an fo:table-header or fo:table-footer or inside an fo:table-header or fo:table-footer. (See https://www.w3.org/TR/xsl11/#fo_retrieve-table-marker)

    FWIW, Antenna House Formatter has an axf:table-cell-repeated-marker extension that can do what you want. (See https://www.antenna.co.jp/AHF/help/en/ahf-ext.html#table)