|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Using Position() to display results in groups
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








