Avatar of jsm11482
 asked on

XSLT for-each conditional table rows

Bad title, I know.  I have a XML file part of which contains a bunch of "Nutrient" elements. I want to display these in a table, 2 nutrients per row. My current XSL is:

            <xsl:for-each select="Nutrient[@Type=2]">
                  <xsl:if test="position() mod 2 != 0">
                  <td colspan="2" style="font-size: 10pt; font-family: Arial; background-color: #deebde; border-bottom: solid 1px #000000;">
                        <xsl:value-of select="@Name"/> <xsl:value-of select="@Amount"/>
                  <xsl:if test="position() mod 2 = 0 or position() = last()">

I put the <tr> and </tr> in CDATA because otherwise it would be angry that I didnt have a closing </tr>. This does not work of course and is also not correct, what is?


Avatar of undefined
Last Comment
Gertone (Geert Bormans)

8/22/2022 - Mon
Gertone (Geert Bormans)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Looks good, thanks!
Gertone (Geert Bormans)

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.