2009-11-11 152 views
11

我想在<fo:table>的最左邊一列顯示一個字體較大的文字。但是,右側的列應該包含幾行較小的文本。有沒有辦法在XSL-FO中使用'rowspan'的等價物?

這是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?

+0

不應該提及XSL:FO而不是XSLT嗎? – ndim 2009-11-11 07:58:40

+0

正如你可能已經意識到我是XSL的初學者,我可以看到你是對的。問題是關於XSL:FO而不是XSLT。謝謝! – Niklas 2009-11-11 09:37:32

回答

30

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

你不愛XSL如何羅嗦是什麼?

0

使用跨行數或跨列數的行。但爲什麼不使用視覺設計師? 我使用的是Ecrion XF Designer,它做得很好。

+1

*編號欄跨度 – 2012-05-01 16:31:12

+0

Ecrion的任何免費替代品? – 2016-11-30 12:38:37

3

上面選擇的答案是正確的,您將「number-rows-spanned =」子句添加到表格單元格的定義中。

但是,與HTML不同,您不會在下面跨區行中的佔位符單元格中留下空位。如果你這樣做,FO會抱怨行中定義的單元太多。

相關問題