This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: counting?


Jason Russ wrote:
> I would like to count the number of
> iterations in a for-each loop (used to
> create a table) and add in a new tag
> (to create a new table) every 15th iteration.
> 
> How do I go about counting and checking
> for the 15th iteration in XSL?

You don't. And you don't add in 'tags' either. This is a FAQ.
See http://www.dpawson.co.uk/

Iterate through every 15th node, then for each of those, create a new
table element. This should get you started:

<xsl:variable name="someNodes" select="path/to/some/nodes"/>
<xsl:for-each select="$someNodes[position() mod 15 = 1]">
  <!-- current node is now the 1st, 16th, 31st... from $someNodes -->
  <table>
   ...
  </table>
</xsl:for-each>

   - Mike
____________________________________________________________________
Mike J. Brown, software engineer at         My XML/XSL resources:
webb.net in Denver, Colorado, USA           http://www.skew.org/xml/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]