I am doing something very similar, and having a very similar problem with XSLT. (I'm doing 2 columns, not 3)
My XML source is:
Code:
<project-news>
<news-item level="1">
<item-title>FLASHWAVE 4100 R4.1 Readies for PR1</item-title>
<item-text>Work continues to bring the 4100 Project (4.1) toward PR1</item-text>
<item-text>The NMIS has been updated and is Draft ready for PR1</item-text>
</news-item>
</project-news>
The XSLT I'm working with is:
Code:
<xsl:template match="news-item" mode="new">
<xsl:variable name="num-items" select="count(item-text)"/>
<table width="80%">
<tr>
<th>
<xsl:if test="$num-items > 1">
<xsl:attribute name="colspan">2</xsl:attribute>
</xsl:if>
<xsl:value-of select="item-title"/>
</th>
</tr>
<xsl:for-each select="item-text">
<xsl:if test="position() mod 2 != 0"><tr></xsl:if>
<td><xsl:value-of select="."/></td>
<xsl:if test="position() mod 2 = 0 or position() = last()"></tr></xsl:if>
</xsl:for-each>
</table>
</xsl:template>
Obviously, this isn't going to work as the LREs: <tr> and </tr> are not matching correctly up in the document object, the nodes are not complete.
Michael Kay says (paraphrased from his book)
Quote:
quote:It is tempting to think of this as a sequence of a <tr> tag, some text and a </tr> closing tag.
However, this is not a true picture of what is going on, and it is best not to think about it this way, because otherwise you will start wondering, for example, how to delay writing the end tag untilsome condition is encountered in the input.
|
Yup, that's what I'm doing. Unfortunatly, he doesn't go on to offer a solution.
So I am open to solutions.
------------------------
GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876
Michael Hare