You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

checkstyle-frames.xsl 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  2. xmlns:lxslt="http://xml.apache.org/xslt"
  3. xmlns:redirect="org.apache.xalan.lib.Redirect"
  4. extension-element-prefixes="redirect">
  5. <!--
  6. Copyright 2002-2004 The Apache Software Foundation
  7. Licensed under the Apache License, Version 2.0 (the "License");
  8. you may not use this file except in compliance with the License.
  9. You may obtain a copy of the License at
  10. http://www.apache.org/licenses/LICENSE-2.0
  11. Unless required by applicable law or agreed to in writing, software
  12. distributed under the License is distributed on an "AS IS" BASIS,
  13. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. See the License for the specific language governing permissions and
  15. limitations under the License.
  16. -->
  17. <xsl:output method="html" indent="yes" encoding="US-ASCII"/>
  18. <xsl:decimal-format decimal-separator="." grouping-separator="," />
  19. <xsl:param name="output.dir" select="'.'"/>
  20. <xsl:param name="basedir" select="'.'"/>
  21. <xsl:template match="checkstyle">
  22. <!-- create the index.html -->
  23. <redirect:write file="{$output.dir}/index.html">
  24. <xsl:call-template name="index.html"/>
  25. </redirect:write>
  26. <!-- create the stylesheet.css -->
  27. <redirect:write file="{$output.dir}/stylesheet.css">
  28. <xsl:call-template name="stylesheet.css"/>
  29. </redirect:write>
  30. <!-- create the overview-summary.html at the root -->
  31. <redirect:write file="{$output.dir}/overview-frame.html">
  32. <xsl:apply-templates select="." mode="overview"/>
  33. </redirect:write>
  34. <!-- create the all-classes.html at the root -->
  35. <redirect:write file="{$output.dir}/allclasses-frame.html">
  36. <xsl:apply-templates select="." mode="all.classes"/>
  37. </redirect:write>
  38. <!-- process all files -->
  39. <xsl:apply-templates select="file[count(error) != 0]"/>
  40. </xsl:template>
  41. <xsl:template name="index.html">
  42. <html>
  43. <head>
  44. <title>CheckStyle Audit</title>
  45. </head>
  46. <frameset cols="20%,80%">
  47. <frame src="allclasses-frame.html" name="fileListFrame"/>
  48. <frame src="overview-frame.html" name="fileFrame"/>
  49. </frameset>
  50. <noframes>
  51. <h2>Frame Alert</h2>
  52. <p>
  53. This document is designed to be viewed using the frames feature.
  54. If you see this message, you are using a non-frame-capable web client.
  55. </p>
  56. </noframes>
  57. </html>
  58. </xsl:template>
  59. <xsl:template name="pageHeader">
  60. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  61. <tr>
  62. <td class="text-align:right"><h2>CheckStyle Audit</h2></td>
  63. </tr>
  64. <tr>
  65. <td class="text-align:right">Designed for use with
  66. <a href='http://checkstyle.sourceforge.net/'>CheckStyle</a> and
  67. <a href='http://ant.apache.org/'>Ant</a>.</td>
  68. </tr>
  69. </table>
  70. <hr size="1"/>
  71. </xsl:template>
  72. <xsl:template match="checkstyle" mode="overview">
  73. <html>
  74. <head>
  75. <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
  76. </head>
  77. <body>
  78. <!-- page header -->
  79. <xsl:call-template name="pageHeader"/>
  80. <!-- Summary part -->
  81. <xsl:apply-templates select="." mode="summary"/>
  82. <hr size="1" width="100%" align="left"/>
  83. <!-- File list part -->
  84. <xsl:apply-templates select="." mode="filelist"/>
  85. </body>
  86. </html>
  87. </xsl:template>
  88. <xsl:template name="stylesheet.css">
  89. .bannercell {
  90. border: 0px;
  91. padding: 0px;
  92. }
  93. body {
  94. margin-left: 10;
  95. margin-right: 10;
  96. font:normal 80% arial,helvetica,sanserif;
  97. background-color:#FFFFFF;
  98. color:#000000;
  99. }
  100. .oddrow td {
  101. background: #efefef;
  102. }
  103. .evenrow td {
  104. background: #fff;
  105. }
  106. th, td {
  107. text-align: left;
  108. vertical-align: top;
  109. }
  110. th {
  111. font-weight:bold;
  112. background: #ccc;
  113. color: black;
  114. }
  115. table, th, td {
  116. font-size:100%;
  117. border: none
  118. }
  119. table.log tr td, tr th {
  120. }
  121. h2 {
  122. font-weight:bold;
  123. font-size:140%;
  124. margin-bottom: 5;
  125. }
  126. h3 {
  127. font-size:100%;
  128. font-weight:bold;
  129. background: #525D76;
  130. color: white;
  131. text-decoration: none;
  132. padding: 5px;
  133. margin-right: 2px;
  134. margin-left: 2px;
  135. margin-bottom: 0;
  136. }
  137. </xsl:template>
  138. <!--
  139. Creates an all-classes.html file that contains a link to all files.
  140. -->
  141. <xsl:template match="checkstyle" mode="all.classes">
  142. <html>
  143. <head>
  144. <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
  145. </head>
  146. <body>
  147. <h2>Files</h2>
  148. <p>
  149. <table width="100%">
  150. <!-- For each file create its part -->
  151. <xsl:apply-templates select="file[count(error) != 0]" mode="all.classes">
  152. <xsl:sort select="substring-after(@name, $basedir)"/>
  153. </xsl:apply-templates>
  154. </table>
  155. </p>
  156. </body>
  157. </html>
  158. </xsl:template>
  159. <xsl:template match="checkstyle" mode="filelist">
  160. <h3>Files</h3>
  161. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  162. <tr>
  163. <th>Name</th>
  164. <th>Errors</th>
  165. </tr>
  166. <xsl:apply-templates select="file[count(error) != 0]" mode="filelist">
  167. <xsl:sort select="count(error)" order="descending" data-type="number"/>
  168. </xsl:apply-templates>
  169. </table>
  170. </xsl:template>
  171. <xsl:template match="file" mode="filelist">
  172. <tr>
  173. <xsl:call-template name="alternated-row"/>
  174. <td nowrap="nowrap">
  175. <a>
  176. <xsl:attribute name="href">
  177. <xsl:text>files/</xsl:text><xsl:value-of select="substring-after(@name, $basedir)"/><xsl:text>.html</xsl:text>
  178. </xsl:attribute>
  179. <xsl:value-of select="substring-after(@name, $basedir)"/>
  180. </a>
  181. </td>
  182. <td><xsl:value-of select="count(error)"/></td>
  183. </tr>
  184. </xsl:template>
  185. <xsl:template match="file" mode="all.classes">
  186. <tr>
  187. <td nowrap="nowrap">
  188. <a target="fileFrame">
  189. <xsl:attribute name="href">
  190. <xsl:text>files/</xsl:text><xsl:value-of select="substring-after(@name, $basedir)"/><xsl:text>.html</xsl:text>
  191. </xsl:attribute>
  192. <xsl:value-of select="substring-after(@name, $basedir)"/>
  193. </a>
  194. </td>
  195. </tr>
  196. </xsl:template>
  197. <!--
  198. transform string like a/b/c to ../../../
  199. @param path the path to transform into a descending directory path
  200. -->
  201. <xsl:template name="path">
  202. <xsl:param name="path"/>
  203. <xsl:if test="contains($path,'/')">
  204. <xsl:text>../</xsl:text>
  205. <xsl:call-template name="path">
  206. <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'/')"/></xsl:with-param>
  207. </xsl:call-template>
  208. </xsl:if>
  209. <xsl:if test="not(contains($path,'/')) and not($path = '')">
  210. <xsl:text>../</xsl:text>
  211. </xsl:if>
  212. </xsl:template>
  213. <xsl:template match="file">
  214. <redirect:write file="{$output.dir}/files/{substring-after(@name, $basedir)}.html">
  215. <html>
  216. <head>
  217. <link rel="stylesheet" type="text/css">
  218. <xsl:attribute name="href"><xsl:call-template name="path"><xsl:with-param name="path" select="substring-after(@name, $basedir)"/></xsl:call-template><xsl:text>stylesheet.css</xsl:text></xsl:attribute>
  219. </link>
  220. </head>
  221. <body>
  222. <xsl:call-template name="pageHeader"/>
  223. <h3>File <xsl:value-of select="substring-after(@name, $basedir)"/></h3>
  224. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  225. <tr>
  226. <th>Error Description</th>
  227. <th>Line:Column</th>
  228. </tr>
  229. <xsl:for-each select="error">
  230. <tr>
  231. <xsl:call-template name="alternated-row"/>
  232. <td><a title="{@source}"><xsl:value-of select="@message"/></a></td>
  233. <td align="center"><xsl:value-of select="@line"/><xsl:if test="@column">:<xsl:value-of select="@column"/></xsl:if></td>
  234. </tr>
  235. </xsl:for-each>
  236. </table>
  237. </body>
  238. </html>
  239. </redirect:write>
  240. </xsl:template>
  241. <xsl:template match="checkstyle" mode="summary">
  242. <h3>Summary</h3>
  243. <xsl:variable name="fileCount" select="count(file)"/>
  244. <xsl:variable name="errorCount" select="count(file/error)"/>
  245. <xsl:variable name="fileErrorCount" select="count(file[count(error) != 0])"/>
  246. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  247. <tr>
  248. <th>Total Files</th>
  249. <th>Files With Errors</th>
  250. <th>Errors</th>
  251. </tr>
  252. <tr>
  253. <xsl:call-template name="alternated-row"/>
  254. <td><xsl:value-of select="$fileCount"/></td>
  255. <td><xsl:value-of select="$fileErrorCount"/></td>
  256. <td><xsl:value-of select="$errorCount"/></td>
  257. </tr>
  258. </table>
  259. </xsl:template>
  260. <xsl:template name="alternated-row">
  261. <xsl:attribute name="class">
  262. <xsl:if test="position() mod 2 = 1">oddrow</xsl:if>
  263. <xsl:if test="position() mod 2 = 0">evenrow</xsl:if>
  264. </xsl:attribute>
  265. </xsl:template>
  266. </xsl:stylesheet>