有没有办法使用“rowspan”的等效项?在 XSL-FO 中?

发布于 2024-08-11 00:06:57 字数 3640 浏览 2 评论 0原文

我想在 的最左列中显示更大字体的文本。然而,右侧的列应由几行较小的文本组成。

这是在添加具有较大文本的任何最左侧列之前 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 来说,如何最好地完成呢?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

桃扇骨 2024-08-18 00:06:57

您不喜欢 XSL 的冗长吗?

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

don't you just love how wordy XSL is?

梦里的微风 2024-08-18 00:06:57

上面选择的答案是正确的,您将“number-rows-spanned=”子句添加到表格单元格的定义中。

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

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.

巷雨优美回忆 2024-08-18 00:06:57

使用跨行数或跨列数。但为什么不使用视觉设计师呢?
我正在使用 Ecrion XF Designer,它做得非常好。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文