Created
June 26, 2012 08:06
-
-
Save marcel-valdez/2994289 to your computer and use it in GitHub Desktop.
XSLT for transforming ReportGenerator output from OpenCover coverage report
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt"> | |
<xsl:output method="html" indent="yes"/> | |
<xsl:template match="/"> | |
<xsl:variable name="cov0style" select="'background:#E79090;text-align:right;'"/> | |
<xsl:variable name="cov20style" select="'background:#D79797;text-align:right;'"/> | |
<xsl:variable name="cov40style" select="'background:#D7A0A0;text-align:right;'"/> | |
<xsl:variable name="cov60style" select="'background:#C7A7A7;text-align:right;'"/> | |
<xsl:variable name="cov80style" select="'background:#C0B0B0;text-align:right;'"/> | |
<xsl:variable name="cov100style" select="'background:#D7D7D7;text-align:right;'"/> | |
<table style="border-collapse: collapse;"> | |
<tr style="font-weight:bold; background:whitesmoke;"> | |
<td colspan="2">Coverage by assembly</td> | |
</tr> | |
<xsl:variable name="asms" select="//Assembly"/> | |
<xsl:for-each select="$asms"> | |
<xsl:variable name="codeSize" select="./@coverablelines"/> | |
<xsl:variable name="coveredCodeSize" select="./@coveredlines"/> | |
<xsl:variable name="codeCoverage" select="./@coverage"/> | |
<tr> | |
<xsl:element name="td"> | |
<xsl:attribute name="style">background:ghostwhite; padding: 5px 30px 5px 5px;</xsl:attribute> | |
<xsl:value-of select="./@name"/> | |
</xsl:element> | |
<xsl:element name="td"> | |
<xsl:if test="$codeSize = 0"> | |
<xsl:attribute name="style"> | |
<xsl:value-of select="$cov0style"/> | |
</xsl:attribute> | |
0% | |
</xsl:if> | |
<xsl:if test="$codeSize > 0"> | |
<xsl:if test="$codeCoverage >= 0 and not($codeCoverage >= 20)"> | |
<xsl:attribute name="style"> | |
<xsl:value-of select="$cov20style"/> | |
</xsl:attribute> | |
</xsl:if> | |
<xsl:if test="$codeCoverage >= 20 and not($codeCoverage >= 40)"> | |
<xsl:attribute name="style"> | |
<xsl:value-of select="$cov40style"/> | |
</xsl:attribute> | |
</xsl:if> | |
<xsl:if test="$codeCoverage >= 40 and not($codeCoverage >= 60)"> | |
<xsl:attribute name="style"> | |
<xsl:value-of select="$cov60style"/> | |
</xsl:attribute> | |
</xsl:if> | |
<xsl:if test="$codeCoverage >= 60 and not($codeCoverage >= 80)"> | |
<xsl:attribute name="style"> | |
<xsl:value-of select="$cov80style"/> | |
</xsl:attribute> | |
</xsl:if> | |
<xsl:if test="$codeCoverage >= 80"> | |
<xsl:attribute name="style"> | |
<xsl:value-of select="$cov100style"/> | |
</xsl:attribute> | |
</xsl:if> | |
Covered <xsl:value-of select="$coveredCodeSize"/> LOC out of <xsl:value-of select="$codeSize"/> LOC. | |
Coverage is: <xsl:value-of select="$codeCoverage"/>% | |
</xsl:if> | |
</xsl:element> | |
</tr> | |
</xsl:for-each> | |
</table> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment