two adjacent tables in body-region each with two columns(xsl-fo)

≯℡__Kan透↙ 提交于 2019-12-02 04:01:27

You can accomplish this by using a two column table that contains the tables you would like side-by-side in a single row.

<fo:table>
    <fo:table-column column-number="1"/>
    <fo:table-column column-number="2"/>
    <fo:table-body>
        <fo:table-row>
            <fo:table-cell>
                <fo:block>
                    <TABLE 1 HERE>
                </fo:block>
            </fo:table-cell>
        </fo:table-row>
        <fo:table-row>
            <fo:table-cell>
                <fo:block>
                    <TABLE 2 HERE>
                </fo:block>
            </fo:table-cell>
        </fo:table-row>
    </fo:table-body>

With the tables in place you can use xsl:if + position() to limit the data that populates the sub-tables.

Process the elements in groups of four:

  <xsl:template match="NVELOPE">
    <fo:table>
      <fo:table-body>
        <xsl:call-template name="row" />
      </fo:table-body>
    </fo:table>
  </xsl:template>

  <xsl:template name="row">
    <xsl:param name="cells" select="*" />

    <fo:table-row>
      <fo:table-cell>
        <fo:block><xsl:apply-templates select="$cells[1]" /></fo:block>
      </fo:table-cell>
      <fo:table-cell>
        <fo:block><xsl:apply-templates select="$cells[2]" /></fo:block>
      </fo:table-cell>
      <fo:table-cell>
        <fo:block><xsl:apply-templates select="$cells[3]" /></fo:block>
      </fo:table-cell>
      <fo:table-cell>
        <fo:block><xsl:apply-templates select="$cells[4]" /></fo:block>
      </fo:table-cell>
    </fo:table-row>
    <xsl:if test="count($cells) > 4">
      <xsl:call-template name="row">
        <xsl:with-param name="cells" select="$cells[position() > 4]" />
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

If the number of elements isn't a multiple of four, this will produce fo:table-cell containing an empty fo:block for the remainder of the row.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!