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

checkstyle-frames.xsl 11 kB

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