Rover Posted December 6, 2011 Share Posted December 6, 2011 I'm trying to count preceing sibbling <row> elements, but don't want to include all preceding-siblings. I'd like to stop counting as soon as I hit a row that contains a "rowsep" attribute. I'm doing this so that I can alternate background colors on the table rows, but need to start over with the colors each time I hit a <row> with a rowsep attribute. Example XML: <row rowsep="1"><entry/></row> <row><entry/></row> <row rowsep="1"><entry></row> <row><entry/></row> For this row, I'd like my preceding siblings to be zero because the preceding row has a rowsep attr.. <row><entry/></row> <row><entry/></row> <row rowsep="1"><entry></row> <row><entry/></row> For this row, I'd like my preceding siblings to be zero because the preceding row has a rowsep attr.. <row><entry/></row> <row><entry/></row> Thank you! Link to comment Share on other sites More sharing options...
Martin Honnen Posted December 6, 2011 Share Posted December 6, 2011 Consider to show us the result sample you want to create for the input sample you posted. And please tell us whether you want to use XSLT 1.0 or 2.0 (as implemented in XSLT 2.0 processors like Saxon 9, AltovaXML or XQSharp). Link to comment Share on other sites More sharing options...
Rover Posted December 6, 2011 Author Share Posted December 6, 2011 I'd like to use XSLT 1.0 Output is HTML. Given the XML above, I'd like the following HTML.<tr style="rowsep"><td/></tr> This is start of table.<tr style="red"><td/></tr><tr style="rowsep"><td/></tr><tr style="red"><td/></tr><tr><td/></tr><tr style="red"><td/></tr><tr style="rowsep"><td/></tr><tr style="red"><td/></tr><tr><td/></tr><tr style="red"><td/></tr> I need to have style="red" on the row folowing a row with a "rowsep" and then style="red" on every other row until I hit another row with "rowsep". A row with style "rowsep" starts a new section of rows. The row following the "rowsep" row should be "red" and this needs to alternate rows.I'm trying to use a count preceding-sibling and "mod" function to determin if the row should be "red".Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.