My thanks to Andrew and James for their help with this problem.
There are probably more elegant ways to code this, but this is the completed
XSLT solution which I have implemented (posted to assist any fellow newbies
that may be interested).
XSLT file:
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output method="html"/>
<xsl:key name="keyTest" match="test" use="@id" />
<xsl:key name="keyPassed" match="test[(_at_)passed='T']" use="@id" />
<xsl:key name="keyFailed" match="test[(_at_)passed='F']" use="@id" />
<xsl:variable name="thetests">
<xsl:for-each select="//test">
<xsl:variable name="id" select="@id"/>
<atest id="{(_at_)id}" Unit_id="{parent::testdata/@Unit_id}">
<xsl:attribute name="pft">
<xsl:choose>
<xsl:when test="@passed='T' and
not(preceding-sibling::test[(_at_)id=$id]/@passed='F')">yes</xsl:when>
<xsl:otherwise>no</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</atest>
</xsl:for-each>
</xsl:variable>
<xsl:key name="keyPFT" match="atest[(_at_)pft='yes']" use="@id" />
<xsl:template match="/">
<html>
<head><title>Summary Report</title></head>
<body>
<table border="1">
<tr>
<th>Test</th>
<th>Total Attempts</th>
<th>Total Pass</th>
<th>Total Fail</th>
<th>Pass on First Attempt</th>
<th>First Run Ratio</th>
</tr>
<testdata>
<xsl:call-template name="summary_list"/>
</testdata>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="//testdata/test[generate-id(.) =
generate-id(key('keyTest', @id))]" name="summary_list">
<xsl:for-each select = "//testdata/test[(_at_)id and generate-id(.) =
generate-id(key('keyTest', @id))]" >
<tr>
<!-- Display the Test Name! -->
<td align="center"><b><xsl:value-of select = "@id" /></b></td>
<!-- Count all tests! -->
<td align="center"><xsl:value-of select = "count(key('keyTest',@id))"
/></td>
<xsl:variable name="tc" select="count(key('keyTest',@id))"/>
<!-- Count the passes! -->
<td align="center"><xsl:value-of select = "count(key('keyPassed',@id))"
/></td>
<!-- Count the fails! -->
<td align="center"><xsl:value-of select = "count(key('keyFailed',@id))"
/></td>
<!-- Count the first run pass! -->
<td align="center">
<xsl:variable name="id" select="@id"/>
<xsl:if test="not(msxsl:node-set($thetests)/atest[generate-id(.) =
generate-id(key('keyPFT', $id))])">
<xsl:value-of select = "'0'" />
<td align="right"><xsl:value-of select = "'0%'" /></td>
</xsl:if>
<xsl:for-each select = "msxsl:node-set($thetests)/atest[generate-id(.) =
generate-id(key('keyPFT', $id))]">
<xsl:value-of select = "count(key('keyPFT',$id))" />
<xsl:if test="count(key('keyPFT',@id))">
<!-- Calculate First Run Ratio -->
<td align="right">
<xsl:value-of select = "format-number(count(key('keyPFT',@id))
div $tc,'###.###%')" />
</td>
</xsl:if>
</xsl:for-each>
</td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Thanks Again!
John Pallister
jpallister(_at_)engenius(_dot_)com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list