I am creating a table from xml using xslt, and I want every other to be a different class.
Here is the xml:
<interfaces>
<interface id="250" name="112test" odd="1"></interface>
<interface id="251" name="113test" odd="0"></interface>
</interfaces>
Here is the relevant part of the xslt I’ve tried:
<xsl:template match="interfaces">
<xsl:for-each select="interface">
<xsl:choose>
<xsl:when test="@odd = '1'">
<tr class="odd">
</xsl:when>
<xsl:otherwise>
<tr>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
How do I get this working? Or is there a better way of doing this, for instance by checking if the attribute exists instead of checking its value?
The perfect solution ended up being a combination of user639175 and Matthew Wilson’s answers: