|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Making sure table rows are filled?
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() < 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] <tr> <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() > $here and position() < $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? xml:
<a>
<b>
<c>
<d1>one</d1>
<d2></d2>
<d3></d3>
<d4>four</d4>
<d5>five</d5>
<d6>six</d6>
<d7>seven</d7>
<d8>eight</d8>
<d9>nine</d9>
<d10>ten</d10>
</c>
</b>
</a>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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








