[Home] [By Thread] [By Date] [Recent Entries]
Hi Allen,
I had some additional thoughts, see below Abel Braaksma wrote:
Because it looks as if you want to output several thumbnails of pictures where you specify the row-size and you use XSLT for the logic, here's is a generalized example of what you can use by using templates (instead of for-each). Note the use of modes, it makes it easier to apply a template multiple times to an input node, without getting into infinite recursion. Input file: <input> <thumbnail url="http://someurl/bla1.gif" /> <thumbnail url="http://someurl/bla2.gif" /> <thumbnail url="http://someurl/bla3.gif" /> <thumbnail url="http://someurl/bla4.gif" /> <thumbnail url="http://someurl/bla5.gif" /> <thumbnail url="http://someurl/bla6.gif" /> <thumbnail url="http://someurl/bla7.gif" /> <thumbnail url="http://someurl/bla8.gif" /> <thumbnail url="http://someurl/bla9.gif" /> <thumbnail url="http://someurl/bla10.gif" /> <thumbnail url="http://someurl/bla11.gif" /> <thumbnail url="http://someurl/bla12.gif" /> <thumbnail url="http://someurl/bla13.gif" /> <thumbnail url="http://someurl/bla14.gif" /> </input> XSLT file: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:template match="/input"> <html><body> <table> <xsl:apply-templates select="thumbnail" /> </table> </body></html> </xsl:template> <xsl:template match="thumbnail[position() mod 5 = 1]"> <xsl:variable name="pos" select="position()" /> <tr> <xsl:apply-templates mode="makethumb" select=". | following-sibling::thumbnail[position() < 5]" /> </tr> </xsl:template> <xsl:template match="thumbnail" mode="makethumb"> <td> <img src="{@url}" /> </td> </xsl:template> </xsl:stylesheet>
|

Cart



