This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathstyle.xsl
147 lines (144 loc) · 4.9 KB
/
style.xsl
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>
<xsl:param name="link-suffix" select="'.xml'"/>
<xsl:template match="/">
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<style type="text/css">
table th { text-align: center }
.hit { background-color: lime; vertical-align: middle }
.missed { background-color: red; vertical-align: middle }
.sourceHit { color: green }
.sourceMissed { color: red }
</style>
<title>Coverage Data</title>
<body>
<!-- navbar -->
<div align="center">
<a href="project{$link-suffix}">Project</a>
<xsl:call-template name="nbsp">
<xsl:with-param name="count" select="3"/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="class and class/@namespace != ''">
<a href="namespace-{class/@namespace}{$link-suffix}">Namespace</a>
</xsl:when>
<xsl:otherwise>
Namespace
</xsl:otherwise>
</xsl:choose>
</div>
<hr/>
<!-- caption -->
<h1 align="center">
<xsl:if test="project">
Project
</xsl:if>
<xsl:if test="namespace">
Namespace <xsl:value-of select="namespace/@name"/>
</xsl:if>
<xsl:if test="class">
Class <xsl:value-of select="class/@fullname"/>
</xsl:if>
</h1>
<!-- summary -->
<table border="2" width="100%">
<tr>
<th></th>
<th>Hit</th>
<th>Missed</th>
<th>Coverage</th>
<th width="50%"></th>
</tr>
<!-- root item -->
<xsl:apply-templates select="./project | ./namespace | ./class"/>
<!-- child items -->
<xsl:apply-templates select="/*//project | /*//namespace | /*//class">
<xsl:sort select="@name"/>
</xsl:apply-templates>
</table>
<!-- source -->
<xsl:apply-templates select="*/source"/>
</body>
</html>
</xsl:template>
<xsl:template match="project | namespace | class">
<tr>
<td>
<xsl:call-template name="nbsp">
<xsl:with-param name="count" select="3"/>
</xsl:call-template>
<xsl:variable name="url">
<xsl:if test="name()='project'">project<xsl:value-of select="$link-suffix"/>
</xsl:if>
<xsl:if test="name()='namespace'">namespace-<xsl:value-of select="@name"/><xsl:value-of select="$link-suffix"/>
</xsl:if>
<xsl:if test="name()='class'">class-<xsl:value-of select="@fullname"/><xsl:value-of select="$link-suffix"/>
</xsl:if>
</xsl:variable>
<xsl:if test="count(..|/)=1">
<xsl:value-of select="@name"/>
</xsl:if>
<xsl:if test="count(..|/)>1">
<a href="{$url}">
<xsl:value-of select="@name"/>
</a>
</xsl:if>
</td>
<td align="center"><xsl:value-of select="coverage/@hit"/></td>
<td align="center"><xsl:value-of select="coverage/@missed"/></td>
<td align="center"><xsl:value-of select="coverage/@coverage"/>%</td>
<td>
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<td>
<img class="hit" width="{coverage/@coverage}%" src="trans.gif" height="12" alt=""/>
<img class="missed" width="{100 - coverage/@coverage}%" src="trans.gif" height="12" alt=""/>
</td>
</tr>
</table>
</td>
</tr>
</xsl:template>
<xsl:template match="source">
<hr/>
<pre>
<code>
<xsl:apply-templates select="l"/>
</code>
</pre>
</xsl:template>
<xsl:template match="l">
<span>
<xsl:attribute name="class">
<xsl:if test="@count>0">
sourceHit
</xsl:if>
<xsl:if test="@count=0">
sourceMissed
</xsl:if>
</xsl:attribute>
<xsl:value-of select="."/>
<xsl:text disable-output-escaping='yes'>
</xsl:text>
</span>
</xsl:template>
<xsl:template name="nbsp">
<xsl:param name="count"/>
<!-- The Mozilla XSL processor converts & ' into the string
' ' which is then displayed ??? -->
<xsl:if test="$count > 0">
<xsl:choose>
<xsl:when test="$link-suffix='.html'">
<xsl:text disable-output-escaping='yes'>&nbsp;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="nbsp">
<xsl:with-param name="count" select="$count - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>