xsl:fo retrieve-marker not valid child

你。 提交于 2019-12-02 00:47:21

(disclosure: I'm a FOP developer)

This example has dynamic table header and table footer, so it should cover your requirements:

  • if the table fits in a single page, both table header and table footer are empty
  • if the table is split over several pages
    • the table header is empty for the first page, and in the following ones it says "(continued)"
    • the table footer is empty for the last page, and in the previous ones it says "(continues on the next page)"
  • tested with FOP 2.0 (older versions did not support table markers); due to FOP's current limitations, the non-breaking space   in the table header and table footer is a necessary "placeholder" (the header / footer dimensions are computed just once, without marker content)
  • no formatter-specific extensions, so this could work with other formatters too (XslFormatter supports table markers; XEP has alternative workarounds)

FO fragment:

  <fo:table table-layout="fixed" width="100%">
    <fo:table-column column-width="100%"/>
    <fo:table-header>
      <fo:table-row>
        <fo:table-cell>
          <fo:block>
            <fo:retrieve-table-marker retrieve-class-name="mc1" 
                retrieve-position-within-table="first-starting" 
                retrieve-boundary-within-table="table-fragment"/>
            &#x00A0;
          </fo:block>
        </fo:table-cell>
      </fo:table-row>
    </fo:table-header>
    <fo:table-footer>
      <fo:table-row>
        <fo:table-cell>
          <fo:block>
            <fo:retrieve-table-marker retrieve-class-name="mc2" 
                retrieve-position-within-table="last-ending" 
                retrieve-boundary-within-table="table-fragment"/>
            &#x00A0;
          </fo:block>
        </fo:table-cell>
      </fo:table-row>
    </fo:table-footer>
    <fo:table-body>
      <!-- first row -->
      <fo:table-row>
        <fo:table-cell>
          <fo:block>
            <fo:marker marker-class-name="mc1"></fo:marker>
            <fo:marker marker-class-name="mc2">(continues on the next page)</fo:marker>
            cell1
          </fo:block>
        </fo:table-cell>
      </fo:table-row>
      <!-- middle row -->
      <fo:table-row>
        <fo:table-cell>
          <fo:block>
            <fo:marker marker-class-name="mc1">(continued)</fo:marker>
            <fo:marker marker-class-name="mc2">(continues on the next page)</fo:marker>
            cell2
          </fo:block>
        </fo:table-cell>
      </fo:table-row>
      <!-- ... other similar rows ... -->
      <!-- last row -->
      <fo:table-row>
        <fo:table-cell>
          <fo:block>
            <fo:marker marker-class-name="mc1">(continued)</fo:marker>
            <fo:marker marker-class-name="mc2"></fo:marker>
            cell9
          </fo:block>
        </fo:table-cell>
      </fo:table-row>
    </fo:table-body>
  </fo:table>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!