Entering data to dynamic table cells
I am using xsl to create reports in HTML and RTF from a textfile. I am using an xml mapping file in the following format.
<mappings>
<mapping pos="0" name="title" type="Element" />
<mapping pos="1" name="surname" type="Element" />
<mapping pos="2" name="extsurname" type="Element" />
<mapping pos="3" name="forename" type="Element" />
<mapping pos="4" name="initial" type="Element" />
<mapping pos="5" name="ref" type="Element" />
</mappings>
I have created the reports easily, but I have to create a title page, which includes listing the references in the report. I would like to display these in a dynamic table, as there will be an unknown quantity of referances used.
I have tried to produce a 5 columned table as follows but to no avail. It correctly creates the required rows, but I am not able to enter the data into the cells after the first value of the row.
<xsl:key name="ref-key" match="mappings" use="ref" />
<xsl:template match="/">
<xsl:variable name="unique-ref" select="/mappings/mapping[generate-id(.) = generate-id(key('ref-key', ref))]/ref" />
<table align="center" cellspacing="5" cellpadding="5">
<xsl:for-each select="$unique-gpref[position() mod 5 = 1]">
<tr>
<td>
<xsl:value-of select="." />
</td>
<xsl:for-each select="current()[position()]/following::$unique-gpref[position() < 5]">
<td>
<xsl:value-of select="." />
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>
I don't think it is possible to use following as i am not using nodes. Is there any other way to read through the variable while maintaing the correct position?
|