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