I'm trying to group a span of rows into so that I can set the background color of each set alternatively. I would also like to merge the first column into one cell. Here is what I have done so far.
XML
<Action>
<Step>
<Obj>UC_A</Obj>
</Step>
<Step>
<Obj>abc</Obj>
</Step>
<Step>
<Obj>bcd</Obj>
</Step>
<Step>
<Obj>cde</Obj>
</Step>
<Step>
<Obj>UC_B</Obj>
</Step>
<Step>
<Obj>def</Obj>
</Step>
<Step>
<Obj>efg</Obj>
</Step>
<Step>
<Obj>UC_C</Obj>
</Step>
<Step>
<Obj>abc</Obj>
</Step>
<Step>
<Obj>bcd</Obj>
</Step>
<Step>
<Obj>cde</Obj>
</Step>
</Action>
XSL
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" omit-xml-declaration="yes" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/Action">
<html>
<head>
<style type="text/css">
table { table-layout:auto; border-collapse:collapse; font-family:Arial; }
td { vertical-align:top; border:1px solid Silver; padding:0pt; font-size:9pt; padding-right:3px; padding-left:3px; }
tr.ODD { background-color:#FFFFDB; }
tr.EVEN { background-color:#E9FFFF; }
</style>
</head>
<body>
<table>
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="Step">
<xsl:variable name="UCBgColor">
<xsl:if test="starts-with(Obj, 'UC_')">
<xsl:variable name="IsOddEven">
<xsl:number count="Step[starts-with(Obj, 'UC_')]"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$IsOddEven mod 2 = 0">EVEN</xsl:when>
<xsl:otherwise>ODD</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:variable>
<tr class="{$UCBgColor}">
<td>
<xsl:if test="starts-with(Obj, 'UC_')">
<xsl:number count="Step[starts-with(Obj, 'UC_')]"/>
</xsl:if>
</td>
<td>
<xsl:value-of select="Obj" />
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
Current Output
Expected Output