source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/etc/maudit-frames.xsl@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

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