我有以下要求。
我在xml中有下表。
------------------------------------------------------------
|NAME |NUMBER|<<Empty>>|NAME |NUMBER|<<Empty>>|NAME |NUMBER|
------------------------------------------------------------
|A001 | 1 | |A005 | 5 | |A009 | 9 |
-------------- -------------- --------------
|A002 | 2 | |A006 | 6 | |A010 | 10 |
-------------- -------------- --------------
|A003 | 3 | |A007 | 7 | |A011 | 11 |
-------------- -------------- --------------
|A004 | 4 | |A008 | 8 | |A011 | 12 |
------------------------------------------------------------
使用XSL FO和Rendrex,上面的XML如下所示:
案例1:如果上表出现在单页中,则应如下所示:
|NAME |NUMBER|<<Empty>>|NAME |NUMBER|<<Empty>>|NAME |NUMBER|
------------------------------------------------------------
|A001 | 1 | |A005 | 5 | |A009 | 9 |
-------------- -------------- --------------
|A002 | 2 | |A006 | 6 | |A010 | 10 |
-------------- -------------- --------------
|A003 | 3 | |A007 | 7 | |A011 | 11 |
-------------- -------------- --------------
|A004 | 4 | |A008 | 8 | |A011 | 12 |
------------------------------------------------------------
案例2:如果表格出现在两页中,它应显示如下:
-------------------------------------------------
|NAME |NUMBER| |NAME |NUMBER| |NAME |NUMBER|
-------------------------------------------------
|A001 | 1 | |A003 | 3 | |A005 | 5 | ---> Page 1
|A002 | 2 | |A004 | 4 | |A006 | 6 |
-------------------------------------------------
-------------------------------------------------
|NAME |NUMBER| |NAME |NUMBER| |NAME |NUMBER|
-------------------------------------------------
|A007 | 7 | |A009 | 9 | |A011 | 11 | ---> Page 2
|A008 | 8 | |A010 | 10 | |A012 | 12 |
-------------------------------------------------
我能够实现案例1但案例2我得到如下:
-------------------------------------------------
|NAME |NUMBER| |NAME |NUMBER| |NAME |NUMBER|
-------------------------------------------------
|A001 | 1 | |A005 | 5 | |A009 | 9 | --> Page 1
|A002 | 2 | |A006 | 6 | |A010 | 10 |
-------------------------------------------------
-------------------------------------------------
|NAME |NUMBER| |NAME |NUMBER| |NAME |NUMBER|
-------------------------------------------------
|A003 | 3 | |A007 | 7 | |A011 | 11 | --> Page 2
|A004 | 4 | |A008 | 8 | |A011 | 12 |
-------------------------------------------------
<fo:table-and-caption id="Table2" caption-side="before" >
<fo:table hyphenate="true" >
<fo:table-header> <!--- Header start -->
<fo:table-row keep-together.within-page="always">
<fo:table-cell >
<fo:block><xsl:value-of select="$headerValues[1]/para"/></fo:block> <!-- NAME-->
</fo:table-cell>
<fo:table-cell >
<fo:block><xsl:value-of select="$headerValues[2]/para"/></fo:block> <!--NUMBER -->
</fo:table-cell>
<fo:table-cell > <!--- Blank Cells in header-->
<fo:block> </fo:block>
</fo:table-cell>
<fo:table-cell >
<fo:block><xsl:value-of select="$headerValues[1]/para"/></fo:block> <!--NAME -->
</fo:table-cell>
<fo:table-cell >
<fo:block><xsl:value-of select="$headerValues[2]/para"/></fo:block> <!--NUMBER -->
</fo:table-cell>
<fo:table-cell > <!--- Blank Cells in header-->
<fo:block> </fo:block>
</fo:table-cell>
<fo:table-cell >
<fo:block><xsl:value-of select="$headerValues[1]/para"/></fo:block> <!--NAME -->
</fo:table-cell>
<fo:table-cell >
<fo:block><xsl:value-of select="$headerValues[2]/para"/></fo:block> <!--NUMBER -->
</fo:table-cell>
</fo:table-row>
</fo:table-header> <!--- Header End -->
<fo:table-body>
<xsl:for-each select="1 to $row-size">
<xsl:variable name="iterationValue" select="."/>
<fo:table-row keep-together.within-page="always">
<fo:table-cell align="left" > <!-- First Cell -->
<fo:block><xsl:value-of select="$nodeValues[$iterationValue]/entry[1]/para"/> </fo:block>
</fo:table-cell>
<fo:table-cell > <!--Second Cell -->
<fo:block><xsl:value-of select="$nodeValues[$iterationValue]/entry[2]/para"/></fo:block>
</fo:table-cell>
<xsl:choose>
<xsl:when test="$iterationValue = $row-size">
<fo:table-cell border-top = "0pt"> </fo:table-cell> <!--Third blank cell -->
</xsl:when>
<xsl:otherwise>
<fo:table-cell ></fo:table-cell>
</xsl:otherwise>
</xsl:choose>
<!-- For 2nd column in table -->
<xsl:choose>
<xsl:when test ="$iterationValue + $row-size > $rowCount">
<fo:table-cell >
<fo:block>-</fo:block> <!-- To Fill - in case of blank -->
</fo:table-cell>
</xsl:when>
<xsl:otherwise>
<fo:table-cell >
<fo:block><xsl:value-of select="$nodeValues[$iterationValue + $row-size]/entry[1]/para"/> </fo:block>
</fo:table-cell>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test ="$iterationValue + $row-size > $rowCount">
<fo:table-cell >
<fo:block>-</fo:block> <!-- To Fill - in case of blank -->
</fo:table-cell>
</xsl:when>
<xsl:otherwise>
<fo:table-cell >
<fo:block><xsl:value-of select="$nodeValues[$iterationValue + $row-size]/entry[2]/para"/></fo:block> </fo:table-cell>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$iterationValue = $row-size">
<fo:table-cell border-top = "0pt"> </fo:table-cell>
</xsl:when>
<xsl:otherwise>
<fo:table-cell ></fo:table-cell> <!-- Blank cell -->
</xsl:otherwise>
</xsl:choose>
<!-- For Third column in table -->
<xsl:choose>
<xsl:when test ="$iterationValue + (2*$row-size) > $rowCount">
<fo:table-cell >
<fo:block>-</fo:block>
</fo:table-cell>
</xsl:when>
<xsl:otherwise>
<fo:table-cell >
<fo:block><xsl:value-of select="$nodeValues[$iterationValue + (2*$row-size)]/entry[1]/para"/> </fo:block>
</fo:table-cell>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test ="$iterationValue + (2*$row-size) > $rowCount">
<fo:table-cell >
<fo:block>-</fo:block>
</fo:table-cell>
</xsl:when>
<xsl:otherwise>
<fo:table-cell >
<fo:block><xsl:value-of select="$nodeValues[$iterationValue + (2*$row-size)]/entry[2]/para"/></fo:block>
</fo:table-cell>
</xsl:otherwise>
</xsl:choose>
</fo:table-row>
</xsl:for-each >
</fo:table-body>
</fo:table>
</fo:table-and-caption>
有人可以帮我找出解决方案。
答案 0 :(得分:2)
因为您使用的是RenderX,所以可以使用rx:flow-section为表格创建流程中的三列区域。请记住将rx:extension命名空间添加到XSL中,您可以完全放弃复杂的编号。
如果您检查下面的XSL FO,它可以满足您的需求。请注意,我已将列间隙设置为&#34; 0pt&#34;所以它看起来像一个连续的表。如果所有行高都相同,这将有效。
XSL FO:
<rx:flow-section column-count="3" column-gap="0pt">
<fo:table width="100%">
<fo:table-body>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>1</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>2</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>3</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>4</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>5</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>6</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>7</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>8</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>9</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>10</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>11</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>12</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>13</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>14</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>15</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>16</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>17</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black"><fo:block>Name</fo:block></fo:table-cell>
<fo:table-cell border="1pt solid black"><fo:block>18</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</rx:flow-section>
跨越页面边界时的输出:
答案 1 :(得分:1)
您可以使用更简单的表格和更复杂的页面主页来实现几乎您所请求的输出:
fo:table-header
和fo:table-body
包含&#34;自然&#34 ;订单(1,2,3,...,12)fo:region-body
和column-count="3"
(或适当的内容)向column-gap="1cm"
定义添加列结果是一个表,其行在三个区域列中流动,最终在需要时创建其他页面。
您可以在表格后面使用空<fo:block span="all"/>
,这样就可以平衡列(例如,每列中有2行而不是第一列中的4行,2英寸第二个和第三个中的0)。
此解决方案无法满足的唯一要求是从边距到边距的连续边界。