Click to See Complete Forum and Search --> : XSLT : Write New trs in a for-each


mparker1113
06-17-2008, 03:04 PM
I have a number of image information nodes stored in a parent element, and am for-eaching through the parent node, and printing out the image information to the screen. I would like to be able to write </tr><tr> when i have written 4 pieces of information to the screen, but i get an error when trying to do (<xsl:if test="position() mod 4 = 0> </tr> </xsl:if>

The reason is that the xslt doesn't like for me to put in a badly formed end of tr tag.

Anyone know an answer around this?

(thanks)

Alain COUTHURES
06-17-2008, 05:02 PM
Any XSLT has to be a well-formed XML ! Hopefully, a well-formed solution can usually be found...

rpgfan3233
06-18-2008, 09:49 AM
Why does your XSLT need to use an end tag before a start tag? That is one thing that I don't understand.

jkmyoung
06-18-2008, 04:51 PM
A possible solution is like


<xsl:for-each select="node[position() mod 4 = 0]">
<tr>
<xsl:apply-templates select="."/>
<xsl:apply-templates select="following-sibling::node[position() &lt; 4]"/>
</tr>
</xsl:for-each>
...
...
<xsl:template match="node">
<td>
....Process node here ...
</td>
</xsl:template>