[xsl] Using Position() to display results in groups

Subject: [xsl] Using Position() to display results in groups
From: "Andrew Welch" <andrew@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 17 Aug 2001 16:29:49 +0100
Hi,

This may be a newbie question im afraid...

I am trying to display a results list on a WAP phone.  These phones have
limited memory so its not possible to display the whole result list on one
'page', so Im trying to break the list into groups of 10 and put a 'next 10'
at the bottom of each page - just like search engine results.

The desired output is something like:

<card id="firstpage">
(results 1-10)
<a href="#secondpage">next10</a>
</card>

<card id="secondpage">
(results 11-20)
<a href="#thirdpage">
</a>

...and so on until the whole list has been broken up in this way.  The list
could be anything from 1 to well over a hundred items.

Heres some code to help explain what I mean:

<card id="firstpage">             //the opening card tag
<xsl:for-each select="$results">  //iterate through the results tree

  <xsl:if test="position()=10">   //if at the tenth item
     <a href="#next10">next 10</a>//output link to next card
     </card>                      //output a close card tag
     <card id="next10">           //output opening tag of new card
  </xsl:if>

  <xsl:value-of select="name"/><br/>  //output search results

  </xsl:for-each>                 //close for-each
</card>                           //closing card tag for final page

The test needs to work out when it is at every tenth item - i think this can
be done using MOD but I cant find an example anywhere.  As the card names
will be dynamic, the current position() can be used as the names when the
test is true, something like (but completely wrong):

<a href="#position()">next 10</a>
</card>
<card id="position()">
(so when say position is 10, both values will be 10 and the link will work)

If anyone understands what I mean then thats the first hurdle passed :) and
if anyone could help me in any way that would be excellent!

Thanks

andrew

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.265 / Virus Database: 137 - Release Date: 18/07/2001


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


Current Thread