Loop baseado em contador


/ Published in: XSLT
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <xsl:call-template name="loop">
  2. <xsl:with-param name="cycles" select="5"/>
  3. <xsl:with-param name="Tag" >td</xsl:with-param>
  4. </xsl:call-template>
  5.  
  6. <xsl:template name="loop">
  7. <xsl:param name="cycles" />
  8. <xsl:param name="Tag" />
  9.  
  10. <xsl:choose>
  11. <xsl:when test="number($cycles) &gt; 0">
  12.  
  13. <xsl:element name="{$Tag}">blank</xsl:element>
  14.  
  15. <xsl:call-template name="loop">
  16. <xsl:with-param name="cycles" select="number($cycles)-1" />
  17. <xsl:with-param name="Tag" >
  18. <xsl:value-of select="$Tag"/>
  19. </xsl:with-param>
  20. </xsl:call-template>
  21.  
  22. </xsl:when>
  23. </xsl:choose>
  24.  
  25. </xsl:template>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.