| 
 
Subject: Re: [xsl] Using Position() to display results in groups From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Mon, 20 Aug 2001 15:43:53 +0100  | 
Hi Andrew,
> Writing ten or so 'when' tests probably isnt the best way to go
> about this. What is required is some code to iterate through the
> list, decide if it as the 10th item ( or a multiple of 10) and
> output some code.
I think that you want to group a load of items into card elements by
position. I would select the first of each group of 10 to process (the
1st, 11th, 21st etc.), using the mod operator to select them:
  <xsl:for-each select="item[position() mod 10 = 1]">
    <card id="{position()}">
      ...
      <a href="#{position() + 10}">next 10</a>
    </card>
  </xsl:for-each>
Within that xsl:for-each, to get the 10 items that should be displayed
on the card, you want this item and its following 9 siblings, e.g.:
  <xsl:for-each select=".|following-sibling::item
                            [position() < 10]">
    ...
  </xsl:for-each>
Actually, I'd be a bit wary of using numbers for IDs like that -- IDs
in XML should start with a letter, and you might have validity
and linking problems if you use something a number. You can just do:
  <card id="card{position()}">
    ...
  </card>
instead.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| Current Thread | 
|---|
  | 
| <- Previous | Index | Next -> | 
|---|---|---|
| RE: [xsl] Using Position() to displ, Andrew Welch | Thread | [xsl] Teaching Recursion and named , Adam Van Den Hoven | 
| Re: [xsl] Assigning values to varia, Goetz Bock | Date | Re: [xsl] fo:table, ronald heller | 
| Month |