re***@hotmail.com writes:
I am new to XSL but I need to create a display where the layout is
<tr> <td> <item/ ></td> <td> <item/ ></td> </tr>
<tr> <td> <item/ ></td> <td> <item/ ></td> </tr>
and so on ..
A column table.
But inorder to this I am trying to do the following
<xsl:if test="position() mod 2 = 0">
<tr>
</xsl:if>
<xsl: something .. to add <td> <item/ ></td>
<xsl:if test="position() mod 2 = 0">
</tr>
</xsl:if>
But it wont let me use the open tag <tr>, is there a way around using
open tags. If not is there a solution to achieve what I am after ?
XSLT never works with tags, it generates a node tree, and you can't
have half a node. Also more directly, the stylesheet has to be a well
formed XML document.
You want to start a new row every second item, and in that row you want
to process this node and the next, so code that directly in xslt
in terms of this node tree, nit in trems of tags that may be used if
this node tree is ever serialised:
<xsl:for-each select="*[position() mod 2 = 0]">
<tr>
<xsl:apply-templates select=".|following-sibling::*[1]"/>
</tr>
</xsl:for-each>
<xsl:template match="abc">
<td>
<xsl:apply-templates/>
</td>
</xsl:templates>
David