XSLT Row Replication within Tables
Posted: Mon Aug 07, 2006 7:33 am
Hi,
I wanted to generate a table with a new row (tr) replicated every 4 or so elements (td's). I have found a good example using a calendar month as a data source, and would like the same design principle in my XSLT.
i.e. for:
The only problem in my application is that I want to fetch the datasource from a http: XML document (i.e. via localhost). Is it possible to do this in the code example above?
I cannot reference the $variable in the <xsl:template match=""> tag, but normally use a variable to assign the external XML datasource to be used.
Any help would be greatly appreciated, thanks
Jon
I wanted to generate a table with a new row (tr) replicated every 4 or so elements (td's). I have found a good example using a calendar month as a data source, and would like the same design principle in my XSLT.
i.e. for:
Code: Select all
<Month>
<day date="1"/>
<day date="2"/>
<day date="3"/>
<day date="4"/>
<day date="5"/>
<day date="6"/>
<day date="7"/>
<day date="8"/>
<day date="9"/>
</Month>
Code: Select all
<xsl:template match="day[position() mod 4 = 1]">
<tr>
<xsl:for-each select=". | following-sibling::day[position() < 4]">
<td><xsl:value-of select="@date"/></td>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template match="day"/> <!-- ignore the other days -->
I cannot reference the $variable in the <xsl:template match=""> tag, but normally use a variable to assign the external XML datasource to be used.
Any help would be greatly appreciated, thanks
Jon