[xsl] Making sure table rows are filled?

Subject: [xsl] Making sure table rows are filled?
From: "Vic Gar" <vlg8693@xxxxxxxxxxx>
Date: Fri, 18 Oct 2002 12:13:54 -0400
Hello all,
With flat-ish xml (below), I need to
1) select the elements from a predetermined position (e.g, elems d1-d9)
<xsl:variable name="table_nodes" select="/a/b/c/*[position() &lt; 10]"/>
2) take those that have text node children
...and normalize-space{.}
3) make a table with rows of two name/value pairs (e.g., <tr><td>#9</td><td>foo</td><td>#10</td><td>bar</td></tr> )
for-each select="$table_nodes[position() mod 2 = 1]
<xsl:apply-templates select=". | ...
4) if there are an odd number of elements, only the last row of the table can be missing a <td> - all the preceding rows should have the requisite 2 name/value pairs.

I tried:
<xsl:apply-templates select=". | $table_nodes[position() &gt; $here and position() &lt; $here+2]" mode="td"/>
The nodes that made it into $table_nodes, in doc order, are
d1 & d4-9.
but for some reason it created:
d1 (d1 value} d4 (d4 value}
d5 (d5 value}
d6 (d6 value} d7 (d7 value)
d7 (d7 value} d9 (d9 value}

My understanding of what's going on here is a long way from where it should be. I get why d7 was selected twice, but as for the rest (why no d8, why single <td> at d5, how to do this properly) can anyone explain it to me?


Many thanks!

Choose an Internet access plan right for you -- try MSN! http://resourcecenter.msn.com/access/plans/default.asp

XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

Current Thread