Increment each 2 entries
This is an open discussion with 2 replies, filed under General.
Search
Something similar to the following:
<xsl:template match="data"> <ul> <xsl:apply-templates select="photoset/photo[position() mod 2 = 1]"/> </ul> </xsl:template> <xsl:template match="photoset/photo"> <li> <xsl:apply-templates select=". | following-sibling::photo[position() = 1]" mode="content"/> </li> </xsl:template> <xsl:template match="photoset/photo" mode="content"> <div> Entry <xsl:value-of select="position()"/> </div> </xsl:template>
This has come up a few times, and there are several approaches people take. Here are some useful discussions:
- Ninja Grouping
- How to write “After every 3”?
- XSLT: How do I group entries and wrap them in containers?
- Newbie XSLT Recursion Helps
- Recursive three column list
The two approaches are broadly: use recursive templates, or XPath axes (following-sibling).
Create an account or sign in to comment.
Hi guys, any idea of how to implement each 2 entries. In example:
XML
Expected output