summaryrefslogtreecommitdiffstats
path: root/tools/PartCover/xslt/Report By Assembly.xslt
blob: 99d3c6711060855ab31389934e5fc95b2a88ba0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?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="/PartCoverReport/Assembly"/>
			<xsl:for-each select="$asms">
				<xsl:variable name="current-asm-node" select="."/>
				<tr>

					<xsl:element name="td">
						<xsl:attribute name="style">background:ghostwhite; padding: 5px  30px 5px  5px;</xsl:attribute>
						<xsl:value-of select="$current-asm-node/@name"/>
					</xsl:element>

					<xsl:variable name="codeSize" select="sum(/PartCoverReport/Type[@asmref=$current-asm-node/@id]/Method/pt/@len)+0"/>
					<xsl:variable name="coveredCodeSize" select="sum(/PartCoverReport/Type[@asmref=$current-asm-node/@id]/Method/pt[@visit>0]/@len)+0"/>

					<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 &gt; 0">
							<xsl:variable name="coverage" select="ceiling(100 * $coveredCodeSize div $codeSize)"/>
							<xsl:if test="$coverage &gt;=  0 and $coverage &lt; 20">
								<xsl:attribute name="style">
									<xsl:value-of select="$cov20style"/>
								</xsl:attribute>
							</xsl:if>
							<xsl:if test="$coverage &gt;= 20 and $coverage &lt; 40">
								<xsl:attribute name="style">
									<xsl:value-of select="$cov40style"/>
								</xsl:attribute>
							</xsl:if>
							<xsl:if test="$coverage &gt;= 40 and $coverage &lt; 60">
								<xsl:attribute name="style">
									<xsl:value-of select="$cov60style"/>
								</xsl:attribute>
							</xsl:if>
							<xsl:if test="$coverage &gt;= 60 and $coverage &lt; 80">
								<xsl:attribute name="style">
									<xsl:value-of select="$cov80style"/>
								</xsl:attribute>
							</xsl:if>
							<xsl:if test="$coverage &gt;= 80">
								<xsl:attribute name="style">
									<xsl:value-of select="$cov100style"/>
								</xsl:attribute>
							</xsl:if>
							<xsl:value-of select="$coverage"/>%
						</xsl:if>
					</xsl:element>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>
</xsl:stylesheet>