Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

maudit-frames.xsl 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  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. <xsl:output method="html" indent="yes" encoding="US-ASCII"/>
  6. <xsl:decimal-format decimal-separator="." grouping-separator="," />
  7. <!--
  8. Copyright 2001-2004 The Apache Software Foundation
  9. Licensed under the Apache License, Version 2.0 (the "License");
  10. you may not use this file except in compliance with the License.
  11. You may obtain a copy of the License at
  12. http://www.apache.org/licenses/LICENSE-2.0
  13. Unless required by applicable law or agreed to in writing, software
  14. distributed under the License is distributed on an "AS IS" BASIS,
  15. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. See the License for the specific language governing permissions and
  17. limitations under the License.
  18. -->
  19. <!--
  20. Stylesheet to transform an XML file generated by the Ant MAudit task into
  21. a set of JavaDoc-like HTML page to make pages more convenient to be browsed.
  22. It use the Xalan redirect extension to write to multiple output files.
  23. @author Stephane Bailliez <a href="mailto:sbailliez@apache.org"/>
  24. -->
  25. <xsl:param name="output.dir" select="'.'"/>
  26. <xsl:template match="classes">
  27. <!-- create the index.html -->
  28. <redirect:write file="{$output.dir}/index.html">
  29. <xsl:call-template name="index.html"/>
  30. </redirect:write>
  31. <!-- create the stylesheet.css -->
  32. <redirect:write file="{$output.dir}/stylesheet.css">
  33. <xsl:call-template name="stylesheet.css"/>
  34. </redirect:write>
  35. <!-- create the overview-packages.html at the root -->
  36. <redirect:write file="{$output.dir}/overview-summary.html">
  37. <xsl:apply-templates select="." mode="overview.packages"/>
  38. </redirect:write>
  39. <!-- create the all-packages.html at the root -->
  40. <redirect:write file="{$output.dir}/overview-frame.html">
  41. <xsl:apply-templates select="." mode="all.packages"/>
  42. </redirect:write>
  43. <!-- create the all-classes.html at the root -->
  44. <redirect:write file="{$output.dir}/allclasses-frame.html">
  45. <xsl:apply-templates select="." mode="all.classes"/>
  46. </redirect:write>
  47. <!-- process all packages -->
  48. <xsl:for-each select="./class[not(./@package = preceding-sibling::class/@package)]">
  49. <xsl:call-template name="package">
  50. <xsl:with-param name="name" select="@package"/>
  51. </xsl:call-template>
  52. </xsl:for-each>
  53. </xsl:template>
  54. <xsl:template name="package">
  55. <xsl:param name="name"/>
  56. <xsl:variable name="package.dir">
  57. <xsl:if test="not($name = '')"><xsl:value-of select="translate($name,'.','/')"/></xsl:if>
  58. <xsl:if test="$name = ''">.</xsl:if>
  59. </xsl:variable>
  60. <!--Processing package <xsl:value-of select="@name"/> in <xsl:value-of select="$output.dir"/> -->
  61. <!-- create a classes-list.html in the package directory -->
  62. <redirect:write file="{$output.dir}/{$package.dir}/package-frame.html">
  63. <xsl:call-template name="classes.list">
  64. <xsl:with-param name="name" select="$name"/>
  65. </xsl:call-template>
  66. </redirect:write>
  67. <!-- create a package-summary.html in the package directory -->
  68. <redirect:write file="{$output.dir}/{$package.dir}/package-summary.html">
  69. <xsl:call-template name="package.summary">
  70. <xsl:with-param name="name" select="$name"/>
  71. </xsl:call-template>
  72. </redirect:write>
  73. <!-- for each class, creates a @name.html -->
  74. <!-- @bug there will be a problem with inner classes having the same name, it will be overwritten -->
  75. <xsl:for-each select="/classes/class[@package = $name]">
  76. <redirect:write file="{$output.dir}/{$package.dir}/{@name}.html">
  77. <xsl:apply-templates select="." mode="class.details"/>
  78. </redirect:write>
  79. </xsl:for-each>
  80. </xsl:template>
  81. <xsl:template name="index.html">
  82. <HTML>
  83. <HEAD><TITLE>Audit Results.</TITLE></HEAD>
  84. <FRAMESET cols="20%,80%">
  85. <FRAMESET rows="30%,70%">
  86. <FRAME src="overview-frame.html" name="packageListFrame"/>
  87. <FRAME src="allclasses-frame.html" name="classListFrame"/>
  88. </FRAMESET>
  89. <FRAME src="overview-summary.html" name="classFrame"/>
  90. </FRAMESET>
  91. <noframes>
  92. <H2>Frame Alert</H2>
  93. <P>
  94. This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
  95. </P>
  96. </noframes>
  97. </HTML>
  98. </xsl:template>
  99. <!-- this is the stylesheet css to use for nearly everything -->
  100. <xsl:template name="stylesheet.css">
  101. .bannercell {
  102. border: 0px;
  103. padding: 0px;
  104. }
  105. body {
  106. margin-left: 10;
  107. margin-right: 10;
  108. font:normal 80% arial,helvetica,sanserif;
  109. background-color:#FFFFFF;
  110. color:#000000;
  111. }
  112. .a td {
  113. background: #efefef;
  114. }
  115. .b td {
  116. background: #fff;
  117. }
  118. th, td {
  119. text-align: left;
  120. vertical-align: top;
  121. }
  122. th {
  123. font-weight:bold;
  124. background: #ccc;
  125. color: black;
  126. }
  127. table, th, td {
  128. font-size:100%;
  129. border: none
  130. }
  131. table.log tr td, tr th {
  132. }
  133. h2 {
  134. font-weight:bold;
  135. font-size:140%;
  136. margin-bottom: 5;
  137. }
  138. h3 {
  139. font-size:100%;
  140. font-weight:bold;
  141. background: #525D76;
  142. color: white;
  143. text-decoration: none;
  144. padding: 5px;
  145. margin-right: 2px;
  146. margin-left: 2px;
  147. margin-bottom: 0;
  148. }
  149. </xsl:template>
  150. <!-- print the violations of the class -->
  151. <xsl:template match="class" mode="class.details">
  152. <xsl:variable name="package.name" select="@package"/>
  153. <HTML>
  154. <HEAD>
  155. <xsl:call-template name="create.stylesheet.link">
  156. <xsl:with-param name="package.name" select="$package.name"/>
  157. </xsl:call-template>
  158. </HEAD>
  159. <BODY>
  160. <xsl:call-template name="pageHeader"/>
  161. <H3>Class <xsl:if test="not($package.name = '')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></H3>
  162. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  163. <xsl:call-template name="class.audit.header"/>
  164. <xsl:apply-templates select="." mode="print.audit"/>
  165. </table>
  166. <H3>Violations</H3>
  167. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  168. <xsl:call-template name="violation.audit.header"/>
  169. <xsl:apply-templates select="./violation" mode="print.audit">
  170. <xsl:sort data-type="number" select="@line"/>
  171. </xsl:apply-templates>
  172. </table>
  173. <xsl:call-template name="pageFooter"/>
  174. </BODY>
  175. </HTML>
  176. </xsl:template>
  177. <!-- list of classes in a package -->
  178. <xsl:template name="classes.list">
  179. <xsl:param name="name"/>
  180. <HTML>
  181. <HEAD>
  182. <xsl:call-template name="create.stylesheet.link">
  183. <xsl:with-param name="package.name" select="$name"/>
  184. </xsl:call-template>
  185. </HEAD>
  186. <BODY>
  187. <table width="100%">
  188. <tr>
  189. <td nowrap="nowrap">
  190. <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="$name"/></a></H2>
  191. </td>
  192. </tr>
  193. </table>
  194. <h2>Classes</h2>
  195. <TABLE WIDTH="100%">
  196. <xsl:apply-templates select="/classes/class[./@package = $name]" mode="classes.list">
  197. <xsl:sort select="@name"/>
  198. </xsl:apply-templates>
  199. </TABLE>
  200. </BODY>
  201. </HTML>
  202. </xsl:template>
  203. <!-- the class to list -->
  204. <xsl:template match="class" mode="classes.list">
  205. <tr>
  206. <td nowrap="nowrap">
  207. <!-- @bug naming to fix for inner classes -->
  208. <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a>
  209. </td>
  210. </tr>
  211. </xsl:template>
  212. <!--
  213. Creates an all-classes.html file that contains a link to all package-summary.html
  214. on each class.
  215. -->
  216. <xsl:template match="classes" mode="all.classes">
  217. <html>
  218. <head>
  219. <xsl:call-template name="create.stylesheet.link">
  220. <xsl:with-param name="package.name"/>
  221. </xsl:call-template>
  222. </head>
  223. <body>
  224. <h2>Classes</h2>
  225. <table width="100%">
  226. <xsl:apply-templates select=".//class" mode="all.classes">
  227. <xsl:sort select="@name"/>
  228. </xsl:apply-templates>
  229. </table>
  230. </body>
  231. </html>
  232. </xsl:template>
  233. <xsl:template match="class" mode="all.classes">
  234. <!-- (ancestor::package)[last()] is buggy in MSXML3 ? -->
  235. <xsl:variable name="package.name" select="@package"/>
  236. <tr>
  237. <td nowrap="nowrap">
  238. <a target="classFrame">
  239. <xsl:attribute name="href">
  240. <xsl:if test="not($package.name='')">
  241. <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text>
  242. </xsl:if><xsl:value-of select="@name"/><xsl:text>.html</xsl:text>
  243. </xsl:attribute>
  244. <xsl:value-of select="@name"/>
  245. </a>
  246. </td>
  247. </tr>
  248. </xsl:template>
  249. <!--
  250. Creates an html file that contains a link to all package-summary.html files on
  251. each package existing on testsuites.
  252. @bug there will be a problem here, I don't know yet how to handle unnamed package :(
  253. -->
  254. <xsl:template match="classes" mode="all.packages">
  255. <html>
  256. <head>
  257. <xsl:call-template name="create.stylesheet.link">
  258. <xsl:with-param name="package.name"/>
  259. </xsl:call-template>
  260. </head>
  261. <body>
  262. <h2><a href="overview-summary.html" target="classFrame">Home</a></h2>
  263. <h2>Packages</h2>
  264. <table width="100%">
  265. <xsl:apply-templates select="class[not(./@package = preceding-sibling::class/@package)]" mode="all.packages">
  266. <xsl:sort select="@package" order="ascending"/>
  267. </xsl:apply-templates>
  268. </table>
  269. </body>
  270. </html>
  271. </xsl:template>
  272. <xsl:template match="class" mode="all.packages">
  273. <tr>
  274. <td nowrap="nowrap">
  275. <a href="{translate(@package,'.','/')}/package-summary.html" target="classFrame">
  276. <xsl:value-of select="@package"/>
  277. </a>
  278. </td>
  279. </tr>
  280. </xsl:template>
  281. <xsl:template match="classes" mode="overview.packages">
  282. <html>
  283. <head>
  284. <xsl:call-template name="create.stylesheet.link">
  285. <xsl:with-param name="package.name"/>
  286. </xsl:call-template>
  287. </head>
  288. <body onload="open('allclasses-frame.html','classListFrame')">
  289. <xsl:call-template name="pageHeader"/>
  290. <h3>Summary</h3>
  291. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  292. <tr>
  293. <th>Audited classes</th>
  294. <th>Reported classes</th>
  295. <th>Violations</th>
  296. </tr>
  297. <tr class="a">
  298. <td><xsl:value-of select="@audited"/></td>
  299. <td><xsl:value-of select="@reported"/></td>
  300. <td><xsl:value-of select="@violations"/></td>
  301. </tr>
  302. </table>
  303. <table border="0" width="100%">
  304. <tr>
  305. <td style="text-align: justify;">
  306. Note: Rules checked have originated from style guidelines suggested by the language designers,
  307. experience from the Java development community and insite experience. Violations are generally
  308. reported with a reference to the <a href="http://java.sun.com/docs/books/jls/second_edition/html/jTOC.doc.html">Java Language Specifications</a> (JLS x.x.x)
  309. and Metamata Audit rules (x.x).
  310. Please consult these documents for additional information about violations.
  311. <p/>
  312. Rules checked also enforce adherence to <a href="http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html">Sun Java coding guidelines</a> in use at Jakarta.
  313. <p/>
  314. One should note that these violations do not necessary underline errors but should be used
  315. as an indication for <i>possible</i> errors. As always, use your best judgment and review
  316. them carefully, it might save you hours of debugging.
  317. </td>
  318. </tr>
  319. </table>
  320. <h3>Packages</h3>
  321. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  322. <xsl:call-template name="class.audit.header"/>
  323. <xsl:for-each select="class[not(./@package = preceding-sibling::class/@package)]">
  324. <xsl:sort select="@package" order="ascending"/>
  325. <tr>
  326. <xsl:call-template name="alternate-row"/>
  327. <td><a href="{translate(@package,'.','/')}/package-summary.html"><xsl:value-of select="@package"/></a></td>
  328. <td><xsl:value-of select="sum(/classes/class[./@package = current()/@package]/@violations)"/></td>
  329. </tr>
  330. </xsl:for-each>
  331. </table>
  332. <xsl:call-template name="pageFooter"/>
  333. </body>
  334. </html>
  335. </xsl:template>
  336. <xsl:template name="package.summary">
  337. <xsl:param name="name"/>
  338. <HTML>
  339. <HEAD>
  340. <xsl:call-template name="create.stylesheet.link">
  341. <xsl:with-param name="package.name" select="$name"/>
  342. </xsl:call-template>
  343. </HEAD>
  344. <BODY>
  345. <xsl:attribute name="onload">open('package-frame.html','classListFrame')</xsl:attribute>
  346. <xsl:call-template name="pageHeader"/>
  347. <h3>Package <xsl:value-of select="$name"/></h3>
  348. <!--table border="0" cellpadding="5" cellspacing="2" width="100%">
  349. <xsl:call-template name="class.metrics.header"/>
  350. <xsl:apply-templates select="." mode="print.metrics"/>
  351. </table-->
  352. <xsl:if test="count(/classes/class[./@package = $name]) &gt; 0">
  353. <H3>Classes</H3>
  354. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  355. <xsl:call-template name="class.audit.header"/>
  356. <xsl:apply-templates select="/classes/class[./@package = $name]" mode="print.audit">
  357. <xsl:sort select="@name"/>
  358. </xsl:apply-templates>
  359. </table>
  360. </xsl:if>
  361. <xsl:call-template name="pageFooter"/>
  362. </BODY>
  363. </HTML>
  364. </xsl:template>
  365. <!--
  366. transform string like a.b.c to ../../../
  367. @param path the path to transform into a descending directory path
  368. -->
  369. <xsl:template name="path">
  370. <xsl:param name="path"/>
  371. <xsl:if test="contains($path,'.')">
  372. <xsl:text>../</xsl:text>
  373. <xsl:call-template name="path">
  374. <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param>
  375. </xsl:call-template>
  376. </xsl:if>
  377. <xsl:if test="not(contains($path,'.')) and not($path = '')">
  378. <xsl:text>../</xsl:text>
  379. </xsl:if>
  380. </xsl:template>
  381. <!-- create the link to the stylesheet based on the package name -->
  382. <xsl:template name="create.stylesheet.link">
  383. <xsl:param name="package.name"/>
  384. <LINK REL ="stylesheet" TYPE="text/css" TITLE="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></LINK>
  385. </xsl:template>
  386. <!-- Page HEADER -->
  387. <xsl:template name="pageHeader">
  388. <!-- jakarta logo -->
  389. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  390. <tr>
  391. <td class="bannercell" rowspan="2">
  392. <a href="http://jakarta.apache.org/">
  393. <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
  394. </a>
  395. </td>
  396. <td style="text-align:right"><h2>Source Code Audit</h2></td>
  397. </tr>
  398. <tr>
  399. <td style="text-align:right">Designed for use with <a href='http://www.webgain.com/products/quality_analyzer/'>Webgain QA/Metamata Audit</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
  400. </tr>
  401. </table>
  402. <hr size="1"/>
  403. </xsl:template>
  404. <!-- Page HEADER -->
  405. <xsl:template name="pageFooter">
  406. <table width="100%">
  407. <tr><td><hr noshade="yes" size="1"/></td></tr>
  408. <tr><td>
  409. <div align="center"><font color="#525D76" size="-1"><em>
  410. Copyright &#169; 1999-2001, Apache Software Foundation
  411. </em></font></div>
  412. </td></tr>
  413. </table>
  414. </xsl:template>
  415. <!-- class header -->
  416. <xsl:template name="class.audit.header">
  417. <tr>
  418. <th width="80%">Name</th>
  419. <th>Violations</th>
  420. </tr>
  421. </xsl:template>
  422. <!-- method header -->
  423. <xsl:template name="violation.audit.header">
  424. <tr>
  425. <th>Line</th>
  426. <th>Message</th>
  427. </tr>
  428. </xsl:template>
  429. <!-- class information -->
  430. <xsl:template match="class" mode="print.audit">
  431. <tr>
  432. <xsl:call-template name="alternate-row"/>
  433. <td><a href="{@name}.html"><xsl:value-of select="@name"/></a></td>
  434. <td><xsl:apply-templates select="@violations"/></td>
  435. </tr>
  436. </xsl:template>
  437. <xsl:template match="violation" mode="print.audit">
  438. <tr>
  439. <xsl:call-template name="alternate-row"/>
  440. <td><xsl:value-of select="@line"/></td>
  441. <td><xsl:apply-templates select="@message"/></td>
  442. </tr>
  443. </xsl:template>
  444. <!-- alternated row style -->
  445. <xsl:template name="alternate-row">
  446. <xsl:attribute name="class">
  447. <xsl:if test="position() mod 2 = 1">a</xsl:if>
  448. <xsl:if test="position() mod 2 = 0">b</xsl:if>
  449. </xsl:attribute>
  450. </xsl:template>
  451. </xsl:stylesheet>