如下代码定义了一个循环模板的例子:

 <xsl:template name="for-loop">
 <xsl:param name="i"/>
 <xsl:param name="count"/>
 <xsl:if test="$i &lt;= $count">
    <xsl:value-of select="$i" disable-output-escaping = "yes" />
 </xsl:if>
 <xsl:if test="$i &lt;= $count">
  <xsl:call-template name="for-loop">
   <xsl:with-param name="i">
    <xsl:value-of select="$i + 1"/>
   </xsl:with-param>
   <xsl:with-param name="count">
    <xsl:value-of select="$count"/>
   </xsl:with-param>
  </xsl:call-template>
 </xsl:if>
</xsl:template>

调用方法:

<xsl:call-template name="for-loop">
 <xsl:with-param name="i">1</xsl:with-param>
 <xsl:with-param name="count">10</xsl:with-param>
</xsl:call-template>

结果输出1-10这10个数字。

 

相关文章:

  • 2022-12-23
  • 2022-02-02
  • 2021-05-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2020-02-29
相关资源
相似解决方案