首页 > 其他分享 >4列

4列

时间:2023-07-18 17:33:08浏览次数:18  
标签: Column Row

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"                 xmlns:fo="http://www.w3.org/1999/XSL/Format">     <!-- 定义传入的参数,listSize表示列表的大小 -->   <xsl:param name="listSize"/>     <!-- 定义根节点的处理方式 -->   <xsl:template match="/">     <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">       <fo:layout-master-set>         <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm"                                margin-top="1cm" margin-bottom="1cm" margin-left="2cm" margin-right="2cm">           <fo:region-body margin-top="2cm"/>         </fo:simple-page-master>       </fo:layout-master-set>       <!-- 调用递归模板开始生成表格 -->       <fo:page-sequence master-reference="A4">         <fo:flow flow-name="xsl-region-body">           <fo:block>             <fo:table>               <fo:table-column column-width="3cm"/>               <fo:table-column column-width="3cm"/>               <fo:table-column column-width="3cm"/>               <fo:table-column column-width="3cm"/>               <fo:table-body>                 <!-- 调用递归模板生成对应行数的表格 -->                 <xsl:call-template name="generateRows">                   <xsl:with-param name="currentRow" select="1"/>                 </xsl:call-template>               </fo:table-body>             </fo:table>           </fo:block>         </fo:flow>       </fo:page-sequence>     </fo:root>   </xsl:template>     <!-- 定义递归模板处理每一行数据 -->   <xsl:template name="generateRows">     <!-- 传入的参数currentRow表示当前行号 -->     <xsl:param name="currentRow"/>     <!-- 结束条件:如果当前行号大于列表大小,则不再生成表格行 -->     <xsl:if test="$currentRow &lt;= $listSize">       <!-- 判断是否需要新的页序列 -->       <xsl:if test="($currentRow - 1) mod 18 = 0">         <!-- 结束当前页序列,并开始新的页序列 -->         <xsl:if test="$currentRow &gt; 1">           </fo:table-body>           </fo:table>           </fo:block>           </fo:flow>           </fo:page-sequence>         </xsl:if>         <fo:page-sequence master-reference="A4">           <fo:flow flow-name="xsl-region-body">             <fo:block>               <fo:table>                 <fo:table-column column-width="3cm"/>                 <fo:table-column column-width="3cm"/>                 <fo:table-column column-width="3cm"/>                 <fo:table-column column-width="3cm"/>                 <fo:table-body>       </xsl:if>       <!-- 输出当前行的表格行 -->       <fo:table-row>         <fo:table-cell border="solid black 1px">           <fo:block>Row <xsl:value-of select="$currentRow"/></fo:block>         </fo:table-cell>         <fo:table-cell border="solid black 1px">           <fo:block>Column 1</fo:block>         </fo:table-cell>         <fo:table-cell border="solid black 1px">           <fo:block>Column 2</fo:block>         </fo:table-cell>         <fo:table-cell border="solid black 1px">           <fo:block>Column 3</fo:block>         </fo:table-cell>       </fo:table-row>       <!-- 递归调用自身处理下一行数据 -->       <xsl:call-template name="generateRows">         <xsl:with-param name="currentRow" select="$currentRow + 1"/>       </xsl:call-template>     </xsl:if>   </xsl:template>   </xsl:stylesheet>  

标签:,Column,Row
From: https://www.cnblogs.com/syea/p/17563614.html

相关文章