checkstyle-report.xsl 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  3. <xsl:output
  4. method="xml"
  5. indent="yes"
  6. encoding="ISO-8859-1"
  7. doctype-public="-//W3C//DTD XHTML 1.1//EN"
  8. doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
  9. xalan:indent-amount="2"
  10. xmlns:xalan="http://xml.apache.org/xslt"/>
  11. <xsl:decimal-format decimal-separator="." grouping-separator="," />
  12. <xsl:template match="checkstyle">
  13. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  14. <head>
  15. <title>Orion Checkstyle Audit Report</title>
  16. <style type="text/css">
  17. .bannercell {
  18. border: 0px;
  19. padding: 0px;
  20. }
  21. body {
  22. margin-left: 10;
  23. margin-right: 10;
  24. font:normal 80% arial,helvetica,sanserif;
  25. background-color:#FFFFFF;
  26. color:#000000;
  27. }
  28. p#intro {
  29. border-bottom: 1px solid #888;
  30. }
  31. .a td {
  32. background: #efefef;
  33. }
  34. .b td {
  35. background: #fff;
  36. }
  37. td.error {
  38. background: #f00;
  39. }
  40. td.warning {
  41. background: #ff0;
  42. }
  43. td.info {
  44. background: #fff;
  45. }
  46. th, td {
  47. text-align: left;
  48. vertical-align: top;
  49. }
  50. th {
  51. font-weight:bold;
  52. background: #ccc;
  53. color: black;
  54. }
  55. table, th, td {
  56. font-size:100%;
  57. border: none
  58. }
  59. table {
  60. margin: 0px;
  61. }
  62. table.log tr td, tr th {
  63. }
  64. div.box {
  65. border: 1px solid #449;
  66. margin: 15px 0px 15px 0px;
  67. padding: 0px 0px 15px 0px;
  68. }
  69. span.source {
  70. font-size:70%;
  71. font-family: Arial, Helvetica, sans-serif;
  72. color: #888;
  73. }
  74. h2, h3 {
  75. font-size: 100%;
  76. font-weight: bold;
  77. background: #525D76;
  78. color: white;
  79. text-decoration: none;
  80. padding: 5px;
  81. margin-right: 2px;
  82. margin-left: 2px;
  83. margin-bottom: 0;
  84. }
  85. </style>
  86. </head>
  87. <body>
  88. <h1 id="top">Orion CheckStyle Audit</h1>
  89. <p id="intro">Designed for use with
  90. <a href='http://checkstyle.sourceforge.net/'>CheckStyle</a> and
  91. <a href='http://jakarta.apache.org'>Ant</a>.
  92. </p>
  93. <p><a href='#sortbyerror'>Files sorted by error count</a> --
  94. <a href='#sortbyname'>Files sorted by name</a> --
  95. <a href='#sortbycount'>Files sorted by problem count</a>
  96. </p>
  97. <!-- Summary part -->
  98. <xsl:apply-templates select="." mode="summary"/>
  99. <!-- Package List part -->
  100. <xsl:apply-templates select="." mode="filelist"/>
  101. <!-- For each package create its part -->
  102. <xsl:for-each select="file[count(error)>0]">
  103. <xsl:sort select="@name"/>
  104. <xsl:apply-templates select="."/>
  105. <br/>
  106. <br/>
  107. </xsl:for-each>
  108. </body>
  109. </html>
  110. </xsl:template>
  111. <xsl:template match="checkstyle" mode="filelist">
  112. <div class="box">
  113. <h2 id="sortbyerror">Files Sorted By Errors</h2>
  114. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  115. <tr>
  116. <th>Name</th>
  117. <th>Errors</th>
  118. <th>Warnings</th>
  119. <th>Infos</th>
  120. </tr>
  121. <xsl:for-each select="file">
  122. <xsl:sort data-type="number" order="descending" select="count(error[@severity='error'])"/>
  123. <xsl:sort data-type="number" order="descending" select="count(error[@severity='warning'])"/>
  124. <xsl:sort data-type="number" order="descending" select="count(error[@severity='info'])"/>
  125. <xsl:variable name="eCount" select="count(error[@severity='error'])"/>
  126. <xsl:variable name="wCount" select="count(error[@severity='warning'])"/>
  127. <xsl:variable name="iCount" select="count(error[@severity='info'])"/>
  128. <xsl:if test="$eCount > 0">
  129. <tr>
  130. <xsl:call-template name="alternated-row"/>
  131. <xsl:variable name="foo" select="translate(@name,':\/','___')"/>
  132. <td><a href="#f-{$foo}"><xsl:value-of select="@name"/></a></td>
  133. <td><xsl:value-of select="$eCount"/></td>
  134. <td><xsl:value-of select="$wCount"/></td>
  135. <td><xsl:value-of select="$iCount"/></td>
  136. </tr>
  137. </xsl:if>
  138. </xsl:for-each>
  139. </table>
  140. </div>
  141. <a href="#top">Back to top</a>
  142. <div class="box">
  143. <h2 id="sortbywarning">Files Sorted By Warnings</h2>
  144. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  145. <tr>
  146. <th>Name</th>
  147. <th>Errors</th>
  148. <th>Warnings</th>
  149. <th>Infos</th>
  150. </tr>
  151. <xsl:for-each select="file">
  152. <xsl:sort data-type="number" order="descending" select="count(error[@severity='warning'])"/>
  153. <xsl:sort data-type="number" order="descending" select="count(error[@severity='error'])"/>
  154. <xsl:sort data-type="number" order="descending" select="count(error[@severity='info'])"/>
  155. <xsl:variable name="eCount" select="count(error[@severity='error'])"/>
  156. <xsl:variable name="wCount" select="count(error[@severity='warning'])"/>
  157. <xsl:variable name="iCount" select="count(error[@severity='info'])"/>
  158. <xsl:if test="$wCount > 0">
  159. <tr>
  160. <xsl:call-template name="alternated-row"/>
  161. <xsl:variable name="foo" select="translate(@name,':\/','___')"/>
  162. <td><a href="#f-{$foo}"><xsl:value-of select="@name"/></a></td>
  163. <td><xsl:value-of select="$eCount"/></td>
  164. <td><xsl:value-of select="$wCount"/></td>
  165. <td><xsl:value-of select="$iCount"/></td>
  166. </tr>
  167. </xsl:if>
  168. </xsl:for-each>
  169. </table>
  170. </div>
  171. <a href="#top">Back to top</a>
  172. <div class="box">
  173. <h2 id="sortbyname">Files Sorted By Name</h2>
  174. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  175. <tr>
  176. <th>Name</th>
  177. <th>Errors</th>
  178. <th>Warnings</th>
  179. <th>Infos</th>
  180. </tr>
  181. <xsl:for-each select="file">
  182. <xsl:sort select="@name"/>
  183. <xsl:variable name="eCount" select="count(error[@severity='error'])"/>
  184. <xsl:variable name="wCount" select="count(error[@severity='warning'])"/>
  185. <xsl:variable name="iCount" select="count(error[@severity='info'])"/>
  186. <tr>
  187. <xsl:call-template name="alternated-row"/>
  188. <xsl:variable name="foo" select="translate(@name,':\/','___')"/>
  189. <td>
  190. <xsl:choose>
  191. <xsl:when test="count(error)=0">
  192. <xsl:value-of select="@name"/>
  193. </xsl:when>
  194. <xsl:otherwise>
  195. <a href="#f-{$foo}"><xsl:value-of select="@name"/></a>
  196. </xsl:otherwise>
  197. </xsl:choose>
  198. </td>
  199. <td><xsl:value-of select="$eCount"/></td>
  200. <td><xsl:value-of select="$wCount"/></td>
  201. <td><xsl:value-of select="$iCount"/></td>
  202. </tr>
  203. </xsl:for-each>
  204. </table>
  205. </div>
  206. <a href="#top">Back to top</a>
  207. <div class="box">
  208. <h2 id="sortbycount">Files Sorted By Problem Count</h2>
  209. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  210. <tr>
  211. <th>Name</th>
  212. <th>Errors</th>
  213. <th>Warnings</th>
  214. <th>Infos</th>
  215. </tr>
  216. <xsl:for-each select="file[count(error)>0]">
  217. <xsl:sort data-type="number" order="descending" select="count(error)"/>
  218. <xsl:variable name="eCount" select="count(error[@severity='error'])"/>
  219. <xsl:variable name="wCount" select="count(error[@severity='warning'])"/>
  220. <xsl:variable name="iCount" select="count(error[@severity='info'])"/>
  221. <tr>
  222. <xsl:call-template name="alternated-row"/>
  223. <xsl:variable name="foo" select="translate(@name,':\/','___')"/>
  224. <td><a href="#f-{$foo}"><xsl:value-of select="@name"/></a></td>
  225. <td><xsl:value-of select="$eCount"/></td>
  226. <td><xsl:value-of select="$wCount"/></td>
  227. <td><xsl:value-of select="$iCount"/></td>
  228. </tr>
  229. </xsl:for-each>
  230. </table>
  231. </div>
  232. <a href="#top">Back to top</a>
  233. </xsl:template>
  234. <xsl:template match="file">
  235. <div class="box">
  236. <xsl:variable name="foo" select="translate(@name,':\/','___')"/>
  237. <h2 id="f-{$foo}">File <xsl:value-of select="@name"/></h2>
  238. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  239. <tr>
  240. <th>Line</th>
  241. <th>Severity</th>
  242. <th>Error Description</th>
  243. <th>Source</th>
  244. </tr>
  245. <xsl:for-each select="error">
  246. <tr>
  247. <xsl:call-template name="alternated-row"/>
  248. <td><xsl:value-of select="@line"/></td>
  249. <td>
  250. <xsl:attribute name="class">
  251. <xsl:value-of select="@severity"/>
  252. </xsl:attribute>
  253. <xsl:value-of select="@severity"/>
  254. </td>
  255. <td><xsl:value-of select="@message"/></td>
  256. <td><span class="source"><xsl:value-of select="@source"/></span></td>
  257. </tr>
  258. </xsl:for-each>
  259. </table>
  260. </div>
  261. <a href="#top">Back to top</a>
  262. </xsl:template>
  263. <xsl:template match="checkstyle" mode="summary">
  264. <div class="box">
  265. <h2>Summary</h2>
  266. <xsl:variable name="fileCount" select="count(file)"/>
  267. <xsl:variable name="cleanCount" select="count(file[count(error)=0])"/>
  268. <xsl:variable name="probCount" select="count(file/error)"/>
  269. <xsl:variable name="errorCount" select="count(file/error[@severity='error'])"/>
  270. <xsl:variable name="warningCount" select="count(file/error[@severity='warning'])"/>
  271. <xsl:variable name="infoCount" select="count(file/error[@severity='info'])"/>
  272. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  273. <tr>
  274. <th>Files</th>
  275. <th>Clean Files</th>
  276. <th>Total Errors</th>
  277. <th>Total Warnings</th>
  278. <th>Total Infos</th>
  279. <th>Total Problems</th>
  280. </tr>
  281. <tr><xsl:call-template name="alternated-row"/>
  282. <td><xsl:value-of select="$fileCount"/></td>
  283. <td><xsl:value-of select="$cleanCount"/></td>
  284. <td><xsl:value-of select="$errorCount"/></td>
  285. <td><xsl:value-of select="$warningCount"/></td>
  286. <td><xsl:value-of select="$infoCount"/></td>
  287. <td><xsl:value-of select="$probCount"/></td>
  288. </tr>
  289. </table>
  290. </div>
  291. </xsl:template>
  292. <xsl:template name="alternated-row">
  293. <xsl:attribute name="class">
  294. <xsl:if test="position() mod 2 = 1">a</xsl:if>
  295. <xsl:if test="position() mod 2 = 0">b</xsl:if>
  296. </xsl:attribute>
  297. </xsl:template>
  298. </xsl:stylesheet>