Is there a way to use the equivalent of 'rowspan' in XSL-FO?

Niklas picture Niklas · Nov 11, 2009 · Viewed 16.3k times · Source

I want to display a text with a bigger font in the leftmost column of an <fo:table>. The columns to the right however should consist of a couple of rows with smaller text.

This is how the XSL code looks like before adding any leftmost column with larger text:

<xsl:template name="printAddress">
  <xsl:param name="subDocument" />
  <fo:table table-layout="fixed" background-color="#e0e0e0" keep-with-next.within-page="always">
    <fo:table-column column-width="7.0cm" />
    <fo:table-column column-width="7.0cm" />
    <fo:table-column column-width="2.0cm" />
    <fo:table-body>
      <!-- Begin Row 1 -->
      <fo:table-row keep-with-previous="always">
        <fo:table-cell margin-left="0.2cm" padding-before="0.1cm" padding-after="0.1cm">
          <fo:block>Value 1</fo:block>
        </fo:table-cell>
        <fo:table-cell margin-left="0.2cm" padding-before="0.1cm" padding-after="0.1cm">
          <fo:block>Value 2</fo:block>
        </fo:table-cell>
        <fo:table-cell margin-left="0.2cm" padding-before="0.1cm" padding-after="0.1cm">
          <fo:block />
        </fo:table-cell>
      </fo:table-row>
      <!-- Begin Row 2 -->
      <fo:table-row keep-with-previous="always">
        <fo:table-cell margin-left="0.2cm" padding-before="0.1cm" padding-after="0.1cm">
          <fo:block>
            <xsl:value-of select="$subDocument/someAttribute" />
          </fo:block>
        </fo:table-cell>
        <fo:table-cell margin-left="0.2cm" padding-before="0.1cm" padding-after="0.1cm">
          <fo:block>
            <xsl:value-of select="$subDocument/someOtherAttribute" />
          </fo:block>
        </fo:table-cell>
        <fo:table-cell margin-left="0.2cm" padding-before="0.1cm" padding-after="0.1cm">
          <fo:block />
        </fo:table-cell>
      </fo:table-row>
      <!-- Begin Row 3 -->
      <fo:table-row keep-with-previous="always">
        <fo:table-cell margin-left="0.2cm" padding-before="0.1cm" padding-after="0.1cm">
          <fo:block>value 3</fo:block>
        </fo:table-cell>
        <fo:table-cell margin-left="0.2cm" padding-before="0.1cm" padding-after="0.1cm">
          <fo:block>Value 4</fo:block>
        </fo:table-cell>
        <fo:table-cell margin-left="0.2cm" padding-before="0.1cm" padding-after="0.1cm">
          <fo:block>Value 5</fo:block>
        </fo:table-cell>
      </fo:table-row>
    </fo:table-body>
  </fo:table>
</xsl:template>

I want to add a column to the left but I can't find the syntax for it. In HTML the above would be written something like this:

<tr>
    <td>Value 1</td>
    <td>Value 2</td>
    <td></td>
</tr>   
<tr>
    <td>{someAttribute}</td>
    <td>{someOtherAttribute}</td>
    <td></td>
</tr>   
<tr>
    <td>Value 3</td>
    <td>Value 4</td>
    <td>Value 5</td>
</tr>

And to accomplish what I want we would only need to modify it like this:

<tr>
    <td rowspan="3" style="font-weight:bold;font-size:14pt">New Text</td>
    <td>Value 1</td>
    <td>Value 2</td>
    <td></td>
</tr>   
<tr>
    <td>{someAttribute}</td>
    <td>{someOtherAttribute}</td>
    <td></td>
</tr>   
<tr>
    <td>Value 3</td>
    <td>Value 4</td>
    <td>Value 5</td>
</tr>

But how would that be best done with for XSL-FO?

Answer

carillonator picture carillonator · Nov 14, 2009

<fo:table-cell number-rows-spanned="3">

don't you just love how wordy XSL is?