开发者

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

开发者 https://www.devze.com 2022-12-10 22:23 出处:网络
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.

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开发者_C百科.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?


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

don't you just love how wordy XSL is?


The selected answer above is right, you add the "number-rows-spanned=" clause to the definition of the table cell.

However, unlike HTML, you don't leave in placeholder cells in the spanned rows below. If you do that, FO will complain about there being too many cells defined in the row.


Use number-rows-spanned or number-column-spanned. But why not use a visual designer? I'm using the Ecrion XF Designer and it's doing a pretty good job.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号