如何在XSL FO表中查找计数/索引

时间:2018-04-11 13:29:30

标签: xsl-fo

如何在XSL FO表中查找行/列的计数/当前索引?

EG。下表的结果应该呈现

(a)中 (b)中 等...

而是表格呈现(a)(a)......

<fo:table>
   <fo:table-body>
      <fo:table-row>
         <fo:table-cell>
            <fo:block>
               <xsl:call-template name="sectionColumn">
                  <xsl:with-param name="rowIndex" select="position()"/>
               </xsl:call-template>
            </fo:block>
         </fo:table-cell>
      </fo:table-row>
      <fo:table-row>
         <fo:table-cell>
            <fo:block>
               <xsl:call-template name="sectionColumn">
                  <xsl:with-param name="rowIndex" select="position()"/>
               </xsl:call-template>
            </fo:block>
         </fo:table-cell>
      </fo:table-row>
   </fo:table-body>
</fo:table>

模板

<xsl:template name="sectionColumn">
   <xsl:param name="rowIndex"/>

   <xsl:if test="$rowIndex != ''">
      <xsl:choose>
         <xsl:when test="$rowIndex = '1'"><xsl:value-of select="'(a)'"/></xsl:when>
         <xsl:when test="$rowIndex = '2'"><xsl:value-of select="'(b)'"/></xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="'Could not resolve ' + $rowIndex"/>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:if>
</xsl:template>

0 个答案:

没有答案