Try this:
 
<xsl:for-each select="parent/child[position() mod 2 = 0]">
<tr>
<td><xsl:value-of select="preceding-sibling::child/name"/></td>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
 
and as you can see you can make this work for any number of columns: 
 
<xsl:for-each select="parent/child[position() mod 4 = 0]">
<tr>
<td><xsl:value-of select="preceding-sibling::child[3]/name"/></td>
<td><xsl:value-of select="preceding-sibling::child[2]/name"/></td>
<td><xsl:value-of select="preceding-sibling::child[1]/name"/></td>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
 
Just be aware that the preceding-sibling:: axis is a reverse axis so counting is reverse document order.
 
Perry
----- Original Message -----
Sent: Wednesday, June 27, 2001 8:22 PM
Subject: work around for <xsl:text disable-output-escaping="yes">?

Hello,

I am trying to dynamically build table rows from an xml file.  The solution
that I came across indicated that I would need to use <xsl:text
disable-output-escaping="yes">.  When I tried to apply this solution I
discovered that Cocoon does not support disable-output-escaping.  What would
be an alternative solution?  The following are example snippets:

[XML]
<parent>
<child>
<name>child1</name>
</child>
<child>
<name>child2</name>
</child>
<child>
<name>child3</name>
</child>
<child>
<name>child4</name>
</child>
<child>
<name>child5</name>
</child>
<child>
<name>child6</name>
</child>
</parent>

[OUTPUT DESIRED]
<tr>
<td>child1</td>
<td>child2</td>
</tr>
<tr>
<td>child3</td>
<td>child4</td>
</tr>
<tr>
<td>child5</td>
<td>child6</td>
</tr>

[RECOMMENDED XSL SOLUTION NOT SUPPORTED BY COCOON]
<tr>
<xsl:for-each select="parent/child">
<td><xsl:value-of select="name"/></td>
<xsl:if test="position() mod 2 = 0">
<xsl:text disable-output-escaping="yes">
<![CDATA[</tr><tr>]]>
</xsl:text>
</xsl:if>
</xsl:for-each>
</tr>




---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to