Coverage.xsl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
  2. <!-- saved from url=(0022)http://www.ncover.org/ -->
  3. <!-- created by Yves Lorphelin, largely inspired by the nunitsumary.xsl (see nantcontrib.sourceforge.net)-->
  4. <xsl:template match="coverage">
  5. <html>
  6. <head>
  7. <title>NCover Code Coverage Report</title>
  8. <style>
  9. BODY {
  10. font: small verdana, arial, helvetica;
  11. color:#000000;
  12. }
  13. P {
  14. line-height:1.5em;
  15. margin-top:0.5em; margin-bottom:1.0em;
  16. }
  17. H1 {
  18. MARGIN: 0px 0px 5px;
  19. FONT: bold larger arial, verdana, helvetica;
  20. }
  21. H2 {
  22. MARGIN-TOP: 1em; MARGIN-BOTTOM: 0.5em;
  23. FONT: larger verdana,arial,helvetica
  24. }
  25. H3 {
  26. MARGIN-BOTTOM: 0.5em; FONT: bold 13px verdana,arial,helvetica
  27. }
  28. H4 {
  29. MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica
  30. }
  31. H5 {
  32. MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica
  33. }
  34. H6 {
  35. MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica
  36. }
  37. .notVisited { background:red; }
  38. .excluded { background: skyblue; }
  39. .visited { background: #90ee90; }
  40. .title { font-size: 12px; font-weight: bold; }
  41. .assembly { font-size: normal; font-weight: bold; font-size: 11px}
  42. .class {font-size:normal; cursor: hand; color: #444444; font-size: 11px}
  43. .module { color: navy; font-size: 12px; }
  44. .method {cursor: hand; color: ; font-size: 10px; font-weight: bold; }
  45. .subtitle { color: black; font-size: 10px; font-weight: bold; }
  46. .hdrcell {font-size:9px; background-color: #DDEEFF; }
  47. .datacell {font-size:9px; background-color: #FFFFEE; text-align: right; }
  48. .hldatacell {font-size:9px; background-color: #FFCCCC; text-align: right; }
  49. .exdatacell {font-size:9px; background-color: #DDEEFF; text-align: right; }
  50. .detailPercent { font-size: 9px; font-weight: bold; padding-top: 1px; padding-bottom: 1px; padding-left: 3px; padding-right: 3px;}
  51. </style>
  52. <script language="JavaScript"><![CDATA[
  53. function toggle (field)
  54. { field.style.display = (field.style.display == "block") ? "none" : "block"; }
  55. function SwitchAll(how)
  56. { var len = document.all.length-1;
  57. for(i=0;i!=len;i++) {
  58. var block = document.all[i];
  59. if (block != null && block.id != '')
  60. { block.style.display=how;}
  61. }
  62. }
  63. function ExpandAll()
  64. {SwitchAll('block');}
  65. function CollapseAll()
  66. {SwitchAll('none');}
  67. ]]></script>
  68. </head>
  69. <body>
  70. <a name="#top"></a>
  71. <xsl:call-template name="header" />
  72. <xsl:call-template name="ModuleSummary" />
  73. <xsl:call-template name="module" />
  74. <xsl:call-template name="footer" />
  75. <script language="JavaScript">CollapseAll();</script>
  76. </body>
  77. </html>
  78. </xsl:template>
  79. <xsl:template name="module">
  80. <xsl:for-each select="//module">
  81. <xsl:sort select="@assembly" />
  82. <xsl:variable name="module" select="./@assembly" />
  83. <div class="assembly">
  84. <a name="#{generate-id($module)}">Module
  85. <xsl:value-of select="$module" />
  86. </a>
  87. </div>
  88. <xsl:for-each select="./method[not(./@class = preceding-sibling::method/@class)]">
  89. <xsl:sort select="@class" />
  90. <xsl:sort select="@name" />
  91. <xsl:call-template name="ClassSummary">
  92. <xsl:with-param name="module" select="$module" />
  93. <xsl:with-param name="class" select="./@class" />
  94. </xsl:call-template>
  95. </xsl:for-each>
  96. </xsl:for-each>
  97. <xsl:variable name="totalMod" select="count(./method/seqpnt[@excluded='false'])" />
  98. <xsl:variable name="notvisitedMod" select="count( ./method/seqpnt[ @visitcount='0'][@excluded='false'] ) div $totalMod * 100 " />
  99. <xsl:variable name="visitedMod" select="count(./method/seqpnt[not(@visitcount='0')] ) div $totalMod * 100" />
  100. </xsl:template>
  101. <xsl:template name="Methods">
  102. <xsl:param name="module" />
  103. <xsl:param name="class" />
  104. <xsl:for-each select="//method[(@class = $class) and (parent::module/@assembly=$module)]">
  105. <xsl:sort select="@name" />
  106. <xsl:variable name="total" select="count(./seqpnt[@excluded='false'])" />
  107. <xsl:variable name="notvisited" select="count(./seqpnt[@visitcount='0'][@excluded='false'] ) " />
  108. <xsl:variable name="visited" select="count(./seqpnt[not(@visitcount='0')])" />
  109. <xsl:variable name="methid" select="generate-id(.)" />
  110. <table cellpadding="3" cellspacing="0" width="90%">
  111. <tr>
  112. <td width="45%" class='method'>
  113. <xsl:attribute name="onclick">javascript:toggle(
  114. <xsl:value-of select="$methid" />)
  115. </xsl:attribute>
  116. <xsl:value-of select="@name" />
  117. </td>
  118. <td width="55%">
  119. <xsl:call-template name="detailPercent">
  120. <xsl:with-param name="visited" select="$visited" />
  121. <xsl:with-param name="notVisited" select="$notvisited" />
  122. <xsl:with-param name="total" select="$total" />
  123. </xsl:call-template>
  124. </td>
  125. </tr>
  126. </table>
  127. <xsl:call-template name="seqpnt">
  128. <xsl:with-param name="module" select="$module" />
  129. <xsl:with-param name="class" select="$class" />
  130. <xsl:with-param name="id" select="$methid" />
  131. </xsl:call-template>
  132. </xsl:for-each>
  133. </xsl:template>
  134. <xsl:template name="seqpnt">
  135. <xsl:param name="module" />
  136. <xsl:param name="class" />
  137. <xsl:param name="id" />
  138. <table cellpadding="3" cellspacing="0" border='1' width="90%" bordercolor="black" style="display: block;">
  139. <xsl:attribute name="id">
  140. <xsl:value-of select="$id" />
  141. </xsl:attribute>
  142. <tr>
  143. <td class="hdrcell">Visits</td>
  144. <td class="hdrcell">Line</td>
  145. <td class="hdrcell">End</td>
  146. <td class="hdrcell">Column</td>
  147. <td class="hdrcell">End</td>
  148. <td class="hdrcell">Document</td>
  149. </tr>
  150. <xsl:for-each select="./seqpnt">
  151. <xsl:sort select="@line" />
  152. <tr>
  153. <td class="datacell">
  154. <xsl:attribute name="class">
  155. <xsl:choose>
  156. <xsl:when test="@excluded = 'true'">exdatacell</xsl:when>
  157. <xsl:when test="@visitcount = 0">hldatacell</xsl:when>
  158. <xsl:otherwise>datacell</xsl:otherwise>
  159. </xsl:choose>
  160. </xsl:attribute>
  161. <xsl:choose>
  162. <xsl:when test="@excluded = 'true'">---</xsl:when>
  163. <xsl:otherwise><xsl:value-of select="@visitcount" /></xsl:otherwise>
  164. </xsl:choose>
  165. </td>
  166. <td class="datacell">
  167. <xsl:value-of select="@line" />
  168. </td>
  169. <td class="datacell">
  170. <xsl:value-of select="@endline" />
  171. </td>
  172. <td class="datacell">
  173. <xsl:value-of select="@column" />
  174. </td>
  175. <td class="datacell">
  176. <xsl:value-of select="@endcolumn" />
  177. </td>
  178. <td class="datacell">
  179. <xsl:value-of select="@document" />
  180. </td>
  181. </tr>
  182. </xsl:for-each>
  183. </table>
  184. </xsl:template>
  185. <!-- Class Summary -->
  186. <xsl:template name="ClassSummary">
  187. <xsl:param name="module" />
  188. <xsl:param name="class" />
  189. <xsl:variable name="total" select="count(//seqpnt[(parent::method/parent::module/@assembly=$module) and (parent::method/@class=$class) and (@excluded='false') ])" />
  190. <xsl:variable name="notvisited" select="count(//seqpnt[(parent::method/parent::module/@assembly=$module)and (parent::method/@class=$class) and (@visitcount='0') and (@excluded='false')] )" />
  191. <xsl:variable name="visited" select="count(//seqpnt[(parent::method/parent::module/@assembly=$module) and (parent::method/@class=$class) and (not(@visitcount='0'))] )" />
  192. <xsl:variable name="newid" select="concat (generate-id(), 'class')" />
  193. <table width='90%'>
  194. <tr>
  195. <td width="40%" class="class">
  196. <xsl:attribute name="onclick">javascript:toggle(
  197. <xsl:value-of select="$newid" />)
  198. </xsl:attribute>
  199. <xsl:value-of select="$class" />
  200. </td>
  201. <td width="60%">
  202. <xsl:call-template name="detailPercent">
  203. <xsl:with-param name="visited" select="$visited" />
  204. <xsl:with-param name="notVisited" select="$notvisited" />
  205. <xsl:with-param name="total" select="$total" />
  206. </xsl:call-template>
  207. </td>
  208. </tr>
  209. <tr>
  210. <table style="display: block;" width="100%">
  211. <tr>
  212. <td>
  213. <xsl:attribute name="id">
  214. <xsl:value-of select="$newid" />
  215. </xsl:attribute>
  216. <xsl:call-template name="Methods">
  217. <xsl:with-param name="module" select="$module" />
  218. <xsl:with-param name="class" select="$class" />
  219. </xsl:call-template>
  220. </td>
  221. </tr>
  222. </table>
  223. </tr>
  224. </table>
  225. <hr size="1" width='90%' align='left' style=" border-bottom: 1px dotted #999;" />
  226. </xsl:template>
  227. <xsl:template name="ClassSummaryDetail">
  228. <xsl:param name="module" />
  229. <xsl:variable name="total" select="count(./method/seqpnt[ @excluded='false' ])" />
  230. <xsl:variable name="notVisited" select="count( ./method/seqpnt[ @visitcount='0'][ @excluded='false' ] )" />
  231. <xsl:variable name="visited" select="count(./method/seqpnt[not(@visitcount='0')] )" />
  232. <td width="35%">
  233. <div class="assembly">
  234. <a href="#{generate-id($module)}">
  235. <xsl:value-of select="$module" />
  236. </a>
  237. </div>
  238. </td>
  239. <td width="65%">
  240. <xsl:call-template name="detailPercent">
  241. <xsl:with-param name="visited" select="$visited" />
  242. <xsl:with-param name="notVisited" select="$notVisited" />
  243. <xsl:with-param name="total" select="$total" />
  244. </xsl:call-template>
  245. </td>
  246. </xsl:template>
  247. <!-- Modules Summary -->
  248. <xsl:template name="ModuleSummary">
  249. <H2>Modules summary</H2>
  250. <xsl:for-each select="//module">
  251. <xsl:sort select="@assembly" />
  252. <table width='90%'>
  253. <tr>
  254. <xsl:call-template name="ModuleSummaryDetail">
  255. <xsl:with-param name="module" select="./@assembly" />
  256. </xsl:call-template>
  257. </tr>
  258. </table>
  259. </xsl:for-each>
  260. <hr size="1" />
  261. </xsl:template>
  262. <xsl:template name="ModuleSummaryDetail">
  263. <xsl:param name="module" />
  264. <xsl:variable name="total" select="count(./method/seqpnt[@excluded='false'])" />
  265. <xsl:variable name="notVisited" select="count( ./method/seqpnt[ @visitcount='0' ][ @excluded='false' ] )" />
  266. <xsl:variable name="visited" select="count(./method/seqpnt[not(@visitcount='0')] )" />
  267. <td width="30%">
  268. <div class="assembly">
  269. <a href="#{generate-id($module)}">
  270. <xsl:value-of select="$module" />
  271. </a>
  272. </div>
  273. </td>
  274. <td width="70%">
  275. <xsl:call-template name="detailPercent">
  276. <xsl:with-param name="visited" select="$visited" />
  277. <xsl:with-param name="notVisited" select="$notVisited" />
  278. <xsl:with-param name="total" select="$total" />
  279. </xsl:call-template>
  280. </td>
  281. </xsl:template>
  282. <!-- General Header -->
  283. <xsl:template name="header">
  284. <h1>
  285. <b>NCover</b> Code Coverage Report
  286. </h1>
  287. <table>
  288. <tr>
  289. <td class="class">
  290. <a onClick="ExpandAll();">Expand</a>
  291. </td>
  292. <td> | </td>
  293. <td class="class">
  294. <a onClick="CollapseAll();">Collapse</a>
  295. </td>
  296. </tr>
  297. </table>
  298. <hr size="1" />
  299. </xsl:template>
  300. <xsl:template name="footer">
  301. <hr size="1" />
  302. <a class="detailPercent" href="#{top}">Top</a>
  303. </xsl:template>
  304. <!-- draw % table-->
  305. <xsl:template name="detailPercent">
  306. <xsl:param name="visited" />
  307. <xsl:param name="notVisited" />
  308. <xsl:param name="total" />
  309. <table width="100%" class="detailPercent">
  310. <tr>
  311. <xsl:if test="($notVisited=0) and ($visited=0)">
  312. <td class="excluded" width="100%">Excluded</td>
  313. </xsl:if>
  314. <xsl:if test="not($notVisited=0)">
  315. <td class="notVisited">
  316. <xsl:attribute name="width">
  317. <xsl:value-of select="concat($notVisited div $total * 100,'%')" />
  318. </xsl:attribute>
  319. <xsl:value-of select="concat (format-number($notVisited div $total * 100,'#.##'),'%')" />
  320. </td>
  321. </xsl:if>
  322. <xsl:if test="not ($visited=0)">
  323. <td class="visited">
  324. <xsl:attribute name="width">
  325. <xsl:value-of select="concat($visited div $total * 100,'%')" />
  326. </xsl:attribute>
  327. <xsl:value-of select="concat (format-number($visited div $total * 100,'#.##'), '%')" />
  328. </td>
  329. </xsl:if>
  330. </tr>
  331. </table>
  332. </xsl:template>
  333. </xsl:stylesheet>