Jump to content

Counting Preceding-Sibling Rows, But Not All Of Them.


Recommended Posts

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 post
Share on other sites

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...