1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3This report was provided by pawan52tiwari (https://github.com/pawan52tiwari)
4see https://github.com/sawilde/opencover/issues/93
5
6sample usage:
7powershell -noexit -file transform.ps1 -xsl simple_report.xslt -xml ..\results\opencovertests.xml -output ..\results\simple_output.html
8-->
9<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
10  <xsl:output method="html"/>
11  <xsl:variable name="covered.lines" select="count(/CoverageSession/Modules/Module/Classes/Class/Methods/Method/SequencePoints/SequencePoint[@vc > 0])" />
12  <xsl:variable name="uncovered.lines" select="count(/CoverageSession/Modules/Module/Classes/Class/Methods/Method/SequencePoints/SequencePoint[@vc = 0])" />
13  <xsl:variable name="coverable.Lines" select="count(/CoverageSession/Modules/Module/Classes/Class/Methods/Method/SequencePoints/SequencePoint)" />
14  <xsl:template match="/">
15  <html><body>
16    <h2 class="sectionheader">Code Coverage Report</h2>
17    <table class="overview">
18      <colgroup>
19        <col width="130" />
20        <col />
21      </colgroup>
22      <tr>
23        <td class="sectionheader">
24          Generated on:
25        </td>
26        <td>
27          <xsl:value-of select="/@date"/>
28        </td>
29      </tr>
30      <tr>
31        <td class="sectionheader">
32          Parser:
33        </td>
34        <td>
35          Pawan Tiwari's Parser
36        </td>
37      </tr>
38      <tr>
39        <td class="sectionheader">
40          Assemblies:
41        </td>
42        <td>
43          <xsl:value-of select="count(/CoverageSession/Modules/Module/ModuleName)"></xsl:value-of>
44        </td>
45      </tr>
46      <tr>
47        <td class="sectionheader">
48          Files:
49        </td>
50        <td>
51          <xsl:value-of select="count(/CoverageSession/Modules/Module/Files/File)"/>
52        </td>
53      </tr>
54      <tr>
55        <td class="sectionheader">
56          Coverage:
57        </td>
58        <td>
59          <xsl:value-of select="$covered.lines div ($uncovered.lines + $covered.lines) * 100"/>%
60        </td>
61      </tr>
62      <tr>
63        <td class="sectionheader">
64          Covered lines:
65        </td>
66        <td>
67          <xsl:value-of select="$covered.lines"/>
68        </td>
69      </tr>
70      <tr>
71        <td class="sectionheader">
72          UnCovered lines:
73        </td>
74        <td>
75          <xsl:value-of select="$uncovered.lines"/>
76        </td>
77      </tr>
78      <tr>
79        <td class="sectionheader">
80          Coverable lines:
81        </td>
82        <td>
83          <xsl:value-of select="$coverable.Lines"/>
84        </td>
85      </tr>
86      <tr>
87        <td class="sectionheader">
88          Total lines:
89        </td>
90        <td>
91          Yet To be discovered
92
93        </td>
94      </tr>
95    </table>
96    <h2 class="sectionheader">
97      Assemblies
98    </h2>
99    <p class="toggleClasses">
100      <a id="collapseAllClasses" style="text-decoration: none;color:red;font-size:10px" href="#">Collapse all classes</a> | <a id="expandAllClasses" style="text-decoration: none;color:red;font-size:10px"
101                href="#">Expand all classes</a>
102    </p>
103    <table class="overview">
104      <colgroup>
105        <col />
106        <col width="60" />
107        <col width="105" />
108      </colgroup>
109      <xsl:for-each select="/CoverageSession/Modules/Module">
110        <xsl:sort select="ModuleName" order="ascending"/>
111        <xsl:sort select="ModuleName"/>
112        <xsl:variable name="ModulenameVariable" select="ModuleName"></xsl:variable>
113        <xsl:variable name="FileLocationLink" select="."></xsl:variable>
114        <tr class="expanded">
115          <th>
116            <a href="#" class="toggleClassesInAssembly" style="text-decoration: none;color:red;font-size:10px" title="Collapse/Expand classes"></a>
117            <xsl:value-of select="ModuleName"/>
118            <a href="#" class="toggleAssemblyDetails" style="text-decoration: none;color:red;font-size:10px" title="Show details of assembly">Details</a>
119            <div class="detailspopup">
120              <table class="overview">
121                <colgroup>
122                  <col width="130" />
123                  <col />
124                </colgroup>
125                <tr>
126                  <td class="sectionheader">
127                    Classes:
128                  </td>
129                  <td>
130                    <xsl:value-of select="count(Classes/Class/FullName[not(contains(text(),'&lt;'))])"></xsl:value-of>
131                  </td>
132                </tr>
133                <tr>
134                  <td class="sectionheader">
135                    Covered lines:
136                  </td>
137                  <td>
138                    <xsl:value-of  select="count(Classes/Class/Methods/Method/SequencePoints/SequencePoint[@vc > 0])"></xsl:value-of>
139                  </td>
140                </tr>
141                <tr>
142                  <td class="sectionheader">
143                    Coverable lines:
144                  </td>
145                  <td>
146                    <xsl:value-of select="count(Classes/Class/Methods/Method/SequencePoints/SequencePoint)" />
147                  </td>
148                </tr>
149                <tr>
150                  <td class="sectionheader">
151                    Coverage:
152                  </td>
153                  <td>
154                    <xsl:choose>
155                      <xsl:when test="(count(Classes/Class/Methods/Method/SequencePoints/SequencePoint[@vc = 0]) + count(Classes/Class/Methods/Method/SequencePoints/SequencePoint[@vc > 0])) &gt; 0">
156                        <xsl:value-of select="count(Classes/Class/Methods/Method/SequencePoints/SequencePoint[@vc > 0]) div (count(Classes/Class/Methods/Method/SequencePoints/SequencePoint[@vc = 0]) + count(Classes/Class/Methods/Method/SequencePoints/SequencePoint[@vc > 0])) * 100"/>%
157                      </xsl:when>
158                      <xsl:otherwise>
159                        0
160                      </xsl:otherwise>
161                    </xsl:choose>
162                  </td>
163                </tr>
164              </table>
165            </div>
166          </th>
167          <th title="LineCoverage">
168            <xsl:if test="(Classes/Class/Methods/Method)">
169              <xsl:value-of select="round(count(Classes/Class/Methods/Method/SequencePoints/SequencePoint[@vc > 0]) div (count(Classes/Class/Methods/Method/SequencePoints/SequencePoint[@vc = 0]) + count(Classes/Class/Methods/Method/SequencePoints/SequencePoint[@vc > 0])) * 100)"/>%
170            </xsl:if>
171          </th>
172          <td>
173            <xsl:variable name="width" select="count(Classes/Class/Methods/Method/SequencePoints/SequencePoint[@vc > 0]) div (count(Classes/Class/Methods/Method/SequencePoints/SequencePoint[@vc = 0]) + count(Classes/Class/Methods/Method/SequencePoints/SequencePoint[@vc > 0])) * 100"></xsl:variable>
174            <table class="coverage">
175              <tr>
176                <td class="green" style="width: {$width}px;">
177                  &#160;
178                </td>
179                <td class="red" style="width: {100-$width}px;">
180                  &#160;
181                </td>
182              </tr>
183            </table>
184          </td>
185        </tr>
186        <xsl:for-each select="Classes/Class">
187          <xsl:if test="FullName[not(contains(text(),'&lt;'))]">
188            <tr class="classrow">
189              <td align="center">
190                <h3 class="sectionheader">
191                  Class Name:<xsl:value-of select="FullName"></xsl:value-of>
192                </h3>
193              </td>
194              <td title="LineCoverage">
195                <xsl:value-of select="round(count(Methods/Method/SequencePoints/SequencePoint[@vc > 0]) div (count(Methods/Method/SequencePoints/SequencePoint[@vc = 0]) + count(Methods/Method/SequencePoints/SequencePoint[@vc > 0])) * 100)"/>%
196              </td>
197              <td>
198                <table class="coverage">
199                  <tr width="100px">
200                    <xsl:variable name="Line.CoveragerClass" select="round(count(Methods/Method/SequencePoints/SequencePoint[@vc > 0]) div (count(Methods/Method/SequencePoints/SequencePoint[@vc = 0]) + count(Methods/Method/SequencePoints/SequencePoint[@vc > 0])) * 100)"></xsl:variable>
201                    <td class="green" style="width: {$Line.CoveragerClass +9}px;">
202                      &#160;
203                    </td>
204                    <td class="red" style="width: {100- $Line.CoveragerClass}px;">
205                      &#160;
206                    </td>
207                  </tr>
208                </table>
209              </td>
210            </tr>
211            <tr class="classrow">
212              <td colspan="3">
213                <table class="overview">
214                  <colgroup>
215                    <col width="130" />
216                    <col />
217                  </colgroup>
218                  <tr>
219                    <td class="sectionheader">
220                      Class:
221                    </td>
222                    <td>
223                      <xsl:value-of select="FullName"></xsl:value-of>
224                    </td>
225                  </tr>
226                  <tr>
227                    <td class="sectionheader">
228                      Assembly:
229                    </td>
230                    <td>
231                      <xsl:value-of select="$ModulenameVariable"></xsl:value-of>
232                    </td>
233                  </tr>
234                  <tr>
235                    <td class="sectionheader">
236                      File(s):
237                    </td>
238                    <td>
239                      <xsl:variable name="CounterForFile" select="position()"></xsl:variable>
240                      <xsl:value-of select="$FileLocationLink/Files/File[$CounterForFile]/@fullPath"/>
241                      <xsl:variable name="FilePathVariable" select="//Files/File[@uid=($CounterForFile -1)]/@fullPath"></xsl:variable>
242                      <a href="file:///{$FilePathVariable}">
243                        <!--<xsl:value-of select="$FilePathVariable"></xsl:value-of>-->
244                      </a>
245                    </td>
246                  </tr>
247                  <tr>
248                    <td class="sectionheader">
249                      Coverage:
250                    </td>
251                    <td>
252                      <xsl:variable name="Covered.lines" select="count(Methods/Method/SequencePoints/SequencePoint[@vc > 0])"></xsl:variable>
253                      <xsl:value-of select="count(Methods/Method/SequencePoints/SequencePoint[@vc > 0]) div (count(Methods/Method/SequencePoints/SequencePoint[@vc = 0]) + count(Methods/Method/SequencePoints/SequencePoint[@vc > 0])) * 100"/>%
254                    </td>
255                  </tr>
256                  <tr>
257                    <td class="sectionheader">
258                      Covered lines:
259                    </td>
260                    <td>
261                      <xsl:value-of  select="count(Methods/Method/SequencePoints/SequencePoint[@vc > 0])"></xsl:value-of>
262                    </td>
263                  </tr>
264                  <tr>
265                    <td class="sectionheader">
266                      Coverable lines:
267                    </td>
268                    <td>
269                      <xsl:value-of  select="count(Methods/Method/SequencePoints/SequencePoint)"></xsl:value-of>
270                    </td>
271                  </tr>
272                  <tr>
273                    <td class="sectionheader">
274                      Total lines:
275                    </td>
276                    <td>
277                      51
278                    </td>
279                  </tr>
280                </table>
281              </td>
282            </tr>
283            <tr class="classrow">
284              <td colspan="3">
285                <table class="overview">
286                  <tr>
287                    <td class="sectionheader">
288                      Method
289                    </td>
290                    <td class="sectionheader">
291                      Cyclomatic Complexity
292                    </td>
293                    <td class="sectionheader">
294                      Sequence Coverage
295                    </td>
296                    <td class="sectionheader">
297                      Branch Coverage
298                    </td>
299                    <td class="sectionheader">
300                      Static Method
301                    </td>
302                  </tr>
303                  <xsl:for-each select="Methods/Method[@isConstructor='false']">
304                    <tr>
305                      <td>
306                        <xsl:variable name="indexvariable" select="string-length(substring-before(Name, '::'))"/>
307                        <xsl:value-of disable-output-escaping="yes" select="substring(Name,$indexvariable +3)"></xsl:value-of>
308                      </td>
309                      <td>
310                        <xsl:value-of disable-output-escaping="yes" select="@cyclomaticComplexity"></xsl:value-of>
311                      </td>
312                      <td>
313                        <xsl:value-of disable-output-escaping="yes" select="@sequenceCoverage"></xsl:value-of>
314                      </td>
315                      <td>
316                        <xsl:value-of disable-output-escaping="yes" select="@branchCoverage"></xsl:value-of>
317                      </td>
318                      <td>
319                        <xsl:value-of disable-output-escaping="yes" select="@isStatic"></xsl:value-of>
320                      </td>
321                    </tr>
322                  </xsl:for-each>
323                </table>
324              </td>
325            </tr>
326          </xsl:if>
327        </xsl:for-each>
328      </xsl:for-each>
329    </table>
330	</body></html>
331  </xsl:template>
332</xsl:stylesheet>
333