Search code examples
xsltxslt-1.0xslt-2.0xsl-fo

Dynamic columns quantity on FO:XSL


Is there any way to make for example 2 colums in a row, and then 3 on the next row?

      <fo:block font-size="16pt" font-weight="bold" space-after="5mm">Company employees: <xsl:value-of select="companyname"/>
      </fo:block>
      <fo:block font-size="10pt">
      <fo:table table-layout="fixed" width="100%" border-collapse="separate">    
        <fo:table-column column-width="4cm"/>
        <fo:table-column column-width="4cm"/>
        <fo:table-column column-width="5cm"/>
        <fo:table-body>
          <xsl:apply-templates select="client"/>
        </fo:table-body>
      </fo:table>
      </fo:block>
    </fo:flow>

Solution

  • If you want one table cell to span two columns, that's the number-columns-spanned property (see https://www.w3.org/TR/xsl11/#number-columns-spanned, and don't let it ever be said that XSL-FO is terse). For example:

    <fo:table-cell number-columns-spanned="2">...</fo:table-cell>
    

    If you want either two equal columns or three equal columns in any row, then either you can make a six-column table and have every fo:table-cell span two or three columns or you can make a single-column table and put a separate two-column or three-column table in the single fo:table-cell in each row of the outer table.

    If you are using AH Formatter, then you may be able to do something with axf:tab (see https://www.antenna.co.jp/AHF/help/v70e/ahf-ext.html#text-tab) and setting the appropriate tab stops, but I haven't tried that.