【问题标题】:Is there a way to use the equivalent of 'rowspan' in XSL-FO?有没有办法在 XSL-FO 中使用等效的“rowspan”?
【发布时间】:2010-12-15 09:11:13
【问题描述】:

我想在<fo:table> 的最左列显示一个更大字体的文本。但是,右侧的列应包含几行较小的文本。

这是在添加任何带有较大文本的最左侧列之前 XSL 代码的样子:

<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>

我想在左侧添加一列,但找不到它的语法。在 HTML 中,上面会写成这样:

<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>

要完成我想要的,我们只需要像这样修改它:

<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>

但是对于 XSL-FO,如何最好地做到这一点呢?

【问题讨论】:

  • 标题不应该提到 XSL:FO 而不是 XSLT?
  • 您可能已经意识到我是 XSL 的初学者,我可以看到您是对的。问题是关于 XSL:FO 而不是 XSLT。谢谢!

标签: xslt xsl-fo


【解决方案1】:

&lt;fo:table-cell number-rows-spanned="3"&gt;

你不喜欢 XSL 的冗长吗?

【讨论】:

    【解决方案2】:

    上面选择的答案是对的,你在表格单元格的定义中添加“number-rows-spanned="子句。

    但是,与 HTML 不同的是,您不会将占位符单元格留在下面的跨行中。如果这样做,FO 会抱怨该行中定义的单元格太多。

    【讨论】:

      【解决方案3】:

      使用 number-rows-spanned 或 number-column-spanned。但是为什么不使用视觉设计师呢? 我正在使用Ecrion XF Designer,它做得很好。

      【讨论】:

      • Ecrion 的任何免费替代品?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-01
      • 1970-01-01
      • 2014-05-29
      • 2022-01-19
      • 2020-07-14
      • 2021-08-12
      • 2010-11-01
      相关资源
      最近更新 更多