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.

maudit-frames.xsl 20 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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.xslt.extensions.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. The Apache Software License, Version 1.1
  9. Copyright (c) 2001-2002 The Apache Software Foundation. All rights
  10. reserved.
  11. Redistribution and use in source and binary forms, with or without
  12. modification, are permitted provided that the following conditions
  13. are met:
  14. 1. Redistributions of source code must retain the above copyright
  15. notice, this list of conditions and the following disclaimer.
  16. 2. Redistributions in binary form must reproduce the above copyright
  17. notice, this list of conditions and the following disclaimer in
  18. the documentation and/or other materials provided with the
  19. distribution.
  20. 3. The end-user documentation included with the redistribution, if
  21. any, must include the following acknowlegement:
  22. "This product includes software developed by the
  23. Apache Software Foundation (http://www.apache.org/)."
  24. Alternately, this acknowlegement may appear in the software itself,
  25. if and wherever such third-party acknowlegements normally appear.
  26. 4. The names "The Jakarta Project", "Ant", and "Apache Software
  27. Foundation" must not be used to endorse or promote products derived
  28. from this software without prior written permission. For written
  29. permission, please contact apache@apache.org.
  30. 5. Products derived from this software may not be called "Apache"
  31. nor may "Apache" appear in their names without prior written
  32. permission of the Apache Group.
  33. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  34. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  35. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  36. DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  37. ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  38. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  39. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  40. USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  41. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  42. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  43. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  44. SUCH DAMAGE.
  45. ====================================================================
  46. This software consists of voluntary contributions made by many
  47. individuals on behalf of the Apache Software Foundation. For more
  48. information on the Apache Software Foundation, please see
  49. <http://www.apache.org/>.
  50. -->
  51. <!--
  52. Stylesheet to transform an XML file generated by the Ant MAudit task into
  53. a set of JavaDoc-like HTML page to make pages more convenient to be browsed.
  54. It use the Xalan redirect extension to write to multiple output files.
  55. @author Stephane Bailliez <a href="mailto:sbailliez@apache.org"/>
  56. -->
  57. <xsl:param name="output.dir" select="'.'"/>
  58. <xsl:template match="classes">
  59. <!-- create the index.html -->
  60. <redirect:write file="{$output.dir}/index.html">
  61. <xsl:call-template name="index.html"/>
  62. </redirect:write>
  63. <!-- create the stylesheet.css -->
  64. <redirect:write file="{$output.dir}/stylesheet.css">
  65. <xsl:call-template name="stylesheet.css"/>
  66. </redirect:write>
  67. <!-- create the overview-packages.html at the root -->
  68. <redirect:write file="{$output.dir}/overview-summary.html">
  69. <xsl:apply-templates select="." mode="overview.packages"/>
  70. </redirect:write>
  71. <!-- create the all-packages.html at the root -->
  72. <redirect:write file="{$output.dir}/overview-frame.html">
  73. <xsl:apply-templates select="." mode="all.packages"/>
  74. </redirect:write>
  75. <!-- create the all-classes.html at the root -->
  76. <redirect:write file="{$output.dir}/allclasses-frame.html">
  77. <xsl:apply-templates select="." mode="all.classes"/>
  78. </redirect:write>
  79. <!-- process all packages -->
  80. <xsl:for-each select="./class[not(./@package = preceding-sibling::class/@package)]">
  81. <xsl:call-template name="package">
  82. <xsl:with-param name="name" select="@package"/>
  83. </xsl:call-template>
  84. </xsl:for-each>
  85. </xsl:template>
  86. <xsl:template name="package">
  87. <xsl:param name="name"/>
  88. <xsl:variable name="package.dir">
  89. <xsl:if test="not($name = '')"><xsl:value-of select="translate($name,'.','/')"/></xsl:if>
  90. <xsl:if test="$name = ''">.</xsl:if>
  91. </xsl:variable>
  92. <!--Processing package <xsl:value-of select="@name"/> in <xsl:value-of select="$output.dir"/> -->
  93. <!-- create a classes-list.html in the package directory -->
  94. <redirect:write file="{$output.dir}/{$package.dir}/package-frame.html">
  95. <xsl:call-template name="classes.list">
  96. <xsl:with-param name="name" select="$name"/>
  97. </xsl:call-template>
  98. </redirect:write>
  99. <!-- create a package-summary.html in the package directory -->
  100. <redirect:write file="{$output.dir}/{$package.dir}/package-summary.html">
  101. <xsl:call-template name="package.summary">
  102. <xsl:with-param name="name" select="$name"/>
  103. </xsl:call-template>
  104. </redirect:write>
  105. <!-- for each class, creates a @name.html -->
  106. <!-- @bug there will be a problem with inner classes having the same name, it will be overwritten -->
  107. <xsl:for-each select="/classes/class[@package = $name]">
  108. <redirect:write file="{$output.dir}/{$package.dir}/{@name}.html">
  109. <xsl:apply-templates select="." mode="class.details"/>
  110. </redirect:write>
  111. </xsl:for-each>
  112. </xsl:template>
  113. <xsl:template name="index.html">
  114. <HTML>
  115. <HEAD><TITLE>Audit Results.</TITLE></HEAD>
  116. <FRAMESET cols="20%,80%">
  117. <FRAMESET rows="30%,70%">
  118. <FRAME src="overview-frame.html" name="packageListFrame"/>
  119. <FRAME src="allclasses-frame.html" name="classListFrame"/>
  120. </FRAMESET>
  121. <FRAME src="overview-summary.html" name="classFrame"/>
  122. </FRAMESET>
  123. <noframes>
  124. <H2>Frame Alert</H2>
  125. <P>
  126. 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.
  127. </P>
  128. </noframes>
  129. </HTML>
  130. </xsl:template>
  131. <!-- this is the stylesheet css to use for nearly everything -->
  132. <xsl:template name="stylesheet.css">
  133. .bannercell {
  134. border: 0px;
  135. padding: 0px;
  136. }
  137. body {
  138. margin-left: 10;
  139. margin-right: 10;
  140. font:normal 80% arial,helvetica,sanserif;
  141. background-color:#FFFFFF;
  142. color:#000000;
  143. }
  144. .a td {
  145. background: #efefef;
  146. }
  147. .b td {
  148. background: #fff;
  149. }
  150. th, td {
  151. text-align: left;
  152. vertical-align: top;
  153. }
  154. th {
  155. font-weight:bold;
  156. background: #ccc;
  157. color: black;
  158. }
  159. table, th, td {
  160. font-size:100%;
  161. border: none
  162. }
  163. table.log tr td, tr th {
  164. }
  165. h2 {
  166. font-weight:bold;
  167. font-size:140%;
  168. margin-bottom: 5;
  169. }
  170. h3 {
  171. font-size:100%;
  172. font-weight:bold;
  173. background: #525D76;
  174. color: white;
  175. text-decoration: none;
  176. padding: 5px;
  177. margin-right: 2px;
  178. margin-left: 2px;
  179. margin-bottom: 0;
  180. }
  181. </xsl:template>
  182. <!-- print the violations of the class -->
  183. <xsl:template match="class" mode="class.details">
  184. <xsl:variable name="package.name" select="@package"/>
  185. <HTML>
  186. <HEAD>
  187. <xsl:call-template name="create.stylesheet.link">
  188. <xsl:with-param name="package.name" select="$package.name"/>
  189. </xsl:call-template>
  190. </HEAD>
  191. <BODY>
  192. <xsl:call-template name="pageHeader"/>
  193. <H3>Class <xsl:if test="not($package.name = '')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></H3>
  194. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  195. <xsl:call-template name="class.audit.header"/>
  196. <xsl:apply-templates select="." mode="print.audit"/>
  197. </table>
  198. <H3>Violations</H3>
  199. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  200. <xsl:call-template name="violation.audit.header"/>
  201. <xsl:apply-templates select="./violation" mode="print.audit">
  202. <xsl:sort data-type="number" select="@line"/>
  203. </xsl:apply-templates>
  204. </table>
  205. <xsl:call-template name="pageFooter"/>
  206. </BODY>
  207. </HTML>
  208. </xsl:template>
  209. <!-- list of classes in a package -->
  210. <xsl:template name="classes.list">
  211. <xsl:param name="name"/>
  212. <HTML>
  213. <HEAD>
  214. <xsl:call-template name="create.stylesheet.link">
  215. <xsl:with-param name="package.name" select="$name"/>
  216. </xsl:call-template>
  217. </HEAD>
  218. <BODY>
  219. <table width="100%">
  220. <tr>
  221. <td nowrap="nowrap">
  222. <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="$name"/></a></H2>
  223. </td>
  224. </tr>
  225. </table>
  226. <h2>Classes</h2>
  227. <TABLE WIDTH="100%">
  228. <xsl:apply-templates select="/classes/class[./@package = $name]" mode="classes.list">
  229. <xsl:sort select="@name"/>
  230. </xsl:apply-templates>
  231. </TABLE>
  232. </BODY>
  233. </HTML>
  234. </xsl:template>
  235. <!-- the class to list -->
  236. <xsl:template match="class" mode="classes.list">
  237. <tr>
  238. <td nowrap="nowrap">
  239. <!-- @bug naming to fix for inner classes -->
  240. <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a>
  241. </td>
  242. </tr>
  243. </xsl:template>
  244. <!--
  245. Creates an all-classes.html file that contains a link to all package-summary.html
  246. on each class.
  247. -->
  248. <xsl:template match="classes" mode="all.classes">
  249. <html>
  250. <head>
  251. <xsl:call-template name="create.stylesheet.link">
  252. <xsl:with-param name="package.name"/>
  253. </xsl:call-template>
  254. </head>
  255. <body>
  256. <h2>Classes</h2>
  257. <table width="100%">
  258. <xsl:apply-templates select=".//class" mode="all.classes">
  259. <xsl:sort select="@name"/>
  260. </xsl:apply-templates>
  261. </table>
  262. </body>
  263. </html>
  264. </xsl:template>
  265. <xsl:template match="class" mode="all.classes">
  266. <!-- (ancestor::package)[last()] is buggy in MSXML3 ? -->
  267. <xsl:variable name="package.name" select="@package"/>
  268. <tr>
  269. <td nowrap="nowrap">
  270. <a target="classFrame">
  271. <xsl:attribute name="href">
  272. <xsl:if test="not($package.name='')">
  273. <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text>
  274. </xsl:if><xsl:value-of select="@name"/><xsl:text>.html</xsl:text>
  275. </xsl:attribute>
  276. <xsl:value-of select="@name"/>
  277. </a>
  278. </td>
  279. </tr>
  280. </xsl:template>
  281. <!--
  282. Creates an html file that contains a link to all package-summary.html files on
  283. each package existing on testsuites.
  284. @bug there will be a problem here, I don't know yet how to handle unnamed package :(
  285. -->
  286. <xsl:template match="classes" mode="all.packages">
  287. <html>
  288. <head>
  289. <xsl:call-template name="create.stylesheet.link">
  290. <xsl:with-param name="package.name"/>
  291. </xsl:call-template>
  292. </head>
  293. <body>
  294. <h2><a href="overview-summary.html" target="classFrame">Home</a></h2>
  295. <h2>Packages</h2>
  296. <table width="100%">
  297. <xsl:apply-templates select="class[not(./@package = preceding-sibling::class/@package)]" mode="all.packages">
  298. <xsl:sort select="@package" order="ascending"/>
  299. </xsl:apply-templates>
  300. </table>
  301. </body>
  302. </html>
  303. </xsl:template>
  304. <xsl:template match="class" mode="all.packages">
  305. <tr>
  306. <td nowrap="nowrap">
  307. <a href="{translate(@package,'.','/')}/package-summary.html" target="classFrame">
  308. <xsl:value-of select="@package"/>
  309. </a>
  310. </td>
  311. </tr>
  312. </xsl:template>
  313. <xsl:template match="classes" mode="overview.packages">
  314. <html>
  315. <head>
  316. <xsl:call-template name="create.stylesheet.link">
  317. <xsl:with-param name="package.name"/>
  318. </xsl:call-template>
  319. </head>
  320. <body onload="open('allclasses-frame.html','classListFrame')">
  321. <xsl:call-template name="pageHeader"/>
  322. <h3>Summary</h3>
  323. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  324. <tr>
  325. <th>Audited classes</th>
  326. <th>Reported classes</th>
  327. <th>Violations</th>
  328. </tr>
  329. <tr class="a">
  330. <td><xsl:value-of select="@audited"/></td>
  331. <td><xsl:value-of select="@reported"/></td>
  332. <td><xsl:value-of select="@violations"/></td>
  333. </tr>
  334. </table>
  335. <table border="0" width="100%">
  336. <tr>
  337. <td style="text-align: justify;">
  338. Note: Rules checked have originated from style guidelines suggested by the language designers,
  339. experience from the Java development community and insite experience. Violations are generally
  340. 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)
  341. and Metamata Audit rules (x.x).
  342. Please consult these documents for additional information about violations.
  343. <p/>
  344. 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.
  345. <p/>
  346. One should note that these violations do not necessary underline errors but should be used
  347. as an indication for <i>possible</i> errors. As always, use your best judgment and review
  348. them carefully, it might save you hours of debugging.
  349. </td>
  350. </tr>
  351. </table>
  352. <h3>Packages</h3>
  353. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  354. <xsl:call-template name="class.audit.header"/>
  355. <xsl:for-each select="class[not(./@package = preceding-sibling::class/@package)]">
  356. <xsl:sort select="@package" order="ascending"/>
  357. <tr>
  358. <xsl:call-template name="alternate-row"/>
  359. <td><a href="{translate(@package,'.','/')}/package-summary.html"><xsl:value-of select="@package"/></a></td>
  360. <td><xsl:value-of select="sum(/classes/class[./@package = current()/@package]/@violations)"/></td>
  361. </tr>
  362. </xsl:for-each>
  363. </table>
  364. <xsl:call-template name="pageFooter"/>
  365. </body>
  366. </html>
  367. </xsl:template>
  368. <xsl:template name="package.summary">
  369. <xsl:param name="name"/>
  370. <HTML>
  371. <HEAD>
  372. <xsl:call-template name="create.stylesheet.link">
  373. <xsl:with-param name="package.name" select="$name"/>
  374. </xsl:call-template>
  375. </HEAD>
  376. <BODY>
  377. <xsl:attribute name="onload">open('package-frame.html','classListFrame')</xsl:attribute>
  378. <xsl:call-template name="pageHeader"/>
  379. <h3>Package <xsl:value-of select="$name"/></h3>
  380. <!--table border="0" cellpadding="5" cellspacing="2" width="100%">
  381. <xsl:call-template name="class.metrics.header"/>
  382. <xsl:apply-templates select="." mode="print.metrics"/>
  383. </table-->
  384. <xsl:if test="count(/classes/class[./@package = $name]) &gt; 0">
  385. <H3>Classes</H3>
  386. <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  387. <xsl:call-template name="class.audit.header"/>
  388. <xsl:apply-templates select="/classes/class[./@package = $name]" mode="print.audit">
  389. <xsl:sort select="@name"/>
  390. </xsl:apply-templates>
  391. </table>
  392. </xsl:if>
  393. <xsl:call-template name="pageFooter"/>
  394. </BODY>
  395. </HTML>
  396. </xsl:template>
  397. <!--
  398. transform string like a.b.c to ../../../
  399. @param path the path to transform into a descending directory path
  400. -->
  401. <xsl:template name="path">
  402. <xsl:param name="path"/>
  403. <xsl:if test="contains($path,'.')">
  404. <xsl:text>../</xsl:text>
  405. <xsl:call-template name="path">
  406. <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param>
  407. </xsl:call-template>
  408. </xsl:if>
  409. <xsl:if test="not(contains($path,'.')) and not($path = '')">
  410. <xsl:text>../</xsl:text>
  411. </xsl:if>
  412. </xsl:template>
  413. <!-- create the link to the stylesheet based on the package name -->
  414. <xsl:template name="create.stylesheet.link">
  415. <xsl:param name="package.name"/>
  416. <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>
  417. </xsl:template>
  418. <!-- Page HEADER -->
  419. <xsl:template name="pageHeader">
  420. <!-- jakarta logo -->
  421. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  422. <tr>
  423. <td class="bannercell" rowspan="2">
  424. <a href="http://jakarta.apache.org/">
  425. <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
  426. </a>
  427. </td>
  428. <td style="text-align:right"><h2>Source Code Audit</h2></td>
  429. </tr>
  430. <tr>
  431. <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>
  432. </tr>
  433. </table>
  434. <hr size="1"/>
  435. </xsl:template>
  436. <!-- Page HEADER -->
  437. <xsl:template name="pageFooter">
  438. <table width="100%">
  439. <tr><td><hr noshade="yes" size="1"/></td></tr>
  440. <tr><td>
  441. <div align="center"><font color="#525D76" size="-1"><em>
  442. Copyright &#169; 1999-2001, Apache Software Foundation
  443. </em></font></div>
  444. </td></tr>
  445. </table>
  446. </xsl:template>
  447. <!-- class header -->
  448. <xsl:template name="class.audit.header">
  449. <tr>
  450. <th width="80%">Name</th>
  451. <th>Violations</th>
  452. </tr>
  453. </xsl:template>
  454. <!-- method header -->
  455. <xsl:template name="violation.audit.header">
  456. <tr>
  457. <th>Line</th>
  458. <th>Message</th>
  459. </tr>
  460. </xsl:template>
  461. <!-- class information -->
  462. <xsl:template match="class" mode="print.audit">
  463. <tr>
  464. <xsl:call-template name="alternate-row"/>
  465. <td><a href="{@name}.html"><xsl:value-of select="@name"/></a></td>
  466. <td><xsl:apply-templates select="@violations"/></td>
  467. </tr>
  468. </xsl:template>
  469. <xsl:template match="violation" mode="print.audit">
  470. <tr>
  471. <xsl:call-template name="alternate-row"/>
  472. <td><xsl:value-of select="@line"/></td>
  473. <td><xsl:apply-templates select="@message"/></td>
  474. </tr>
  475. </xsl:template>
  476. <!-- alternated row style -->
  477. <xsl:template name="alternate-row">
  478. <xsl:attribute name="class">
  479. <xsl:if test="position() mod 2 = 1">a</xsl:if>
  480. <xsl:if test="position() mod 2 = 0">b</xsl:if>
  481. </xsl:attribute>
  482. </xsl:template>
  483. </xsl:stylesheet>