Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6803 buildadm 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"/>
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
 
27
 Sample stylesheet to be used with JProbe 3.0 XML output.
28
 
29
 It creates a set of HTML files a la javadoc where you can browse easily
30
 through all packages and classes.
31
 
32
 It is best used with JProbe Coverage Ant task that gives you the benefit
33
 of a reference classpath so that you have the list of classes/methods
34
 that are not used at all in a given classpath.
35
 
36
-->
37
 
38
<!-- default output directory is current directory -->
39
<xsl:param name="output.dir" select="'.'"/>
40
 
41
<!-- ======================================================================
42
    Root element
43
    ======================================================================= -->
44
<xsl:template match="/snapshot">
45
    <!-- create the index.html -->
46
    <redirect:write file="{$output.dir}/index.html">
47
        <xsl:call-template name="index.html"/>
48
    </redirect:write>
49
 
50
    <!-- create the stylesheet.css -->
51
    <redirect:write file="{$output.dir}/stylesheet.css">
52
        <xsl:call-template name="stylesheet.css"/>
53
    </redirect:write>
54
 
55
    <!-- create the overview-packages.html at the root -->
56
    <redirect:write file="{$output.dir}/overview-summary.html">
57
        <xsl:apply-templates select="." mode="overview.packages"/>
58
    </redirect:write>
59
 
60
    <!-- create the all-packages.html at the root -->
61
    <redirect:write file="{$output.dir}/overview-frame.html">
62
        <xsl:apply-templates select="." mode="all.packages"/>
63
    </redirect:write>
64
 
65
    <!-- create the all-classes.html at the root -->
66
    <redirect:write file="{$output.dir}/allclasses-frame.html">
67
        <xsl:apply-templates select="." mode="all.classes"/>
68
    </redirect:write>
69
 
70
    <!-- process all packages -->
71
    <xsl:apply-templates select="./package" mode="write"/>
72
</xsl:template>
73
 
74
<!-- =======================================================================
75
    Frameset definition. Entry point for the report.
76
    3 frames: packageListFrame, classListFrame, classFrame
77
    ======================================================================= -->
78
<xsl:template name="index.html">
79
<html>
80
    <head><title>Coverage Results.</title></head>
81
    <frameset cols="20%,80%">
82
        <frameset rows="30%,70%">
83
            <frame src="overview-frame.html" name="packageListFrame"/>
84
            <frame src="allclasses-frame.html" name="classListFrame"/>
85
        </frameset>
86
        <frame src="overview-summary.html" name="classFrame"/>
87
    </frameset>
88
    <noframes>
89
        <h2>Frame Alert</h2>
90
        <p>
91
        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.
92
        </p>
93
    </noframes>
94
</html>
95
</xsl:template>
96
 
97
<!-- =======================================================================
98
    Stylesheet CSS used
99
    ======================================================================= -->
100
<!-- this is the stylesheet css to use for nearly everything -->
101
<xsl:template name="stylesheet.css">
102
    .bannercell {
103
      border: 0px;
104
      padding: 0px;
105
    }
106
    body {
107
      margin-left: 10;
108
      margin-right: 10;
109
      font:normal 80% arial,helvetica,sanserif;
110
      background-color:#FFFFFF;
111
      color:#000000;
112
    }
113
    .a td {
114
      background: #efefef;
115
    }
116
    .b td {
117
      background: #fff;
118
    }
119
    th, td {
120
      text-align: left;
121
      vertical-align: top;
122
    }
123
    th {
124
      font-weight:bold;
125
      background: #ccc;
126
      color: black;
127
    }
128
    table, th, td {
129
      font-size:100%;
130
      border: none
131
    }
132
    table.log tr td, tr th {
133
 
134
    }
135
    h2 {
136
      font-weight:bold;
137
      font-size:140%;
138
      margin-bottom: 5;
139
    }
140
    h3 {
141
      font-size:100%;
142
      font-weight:bold;
143
      background: #525D76;
144
      color: white;
145
      text-decoration: none;
146
      padding: 5px;
147
      margin-right: 2px;
148
      margin-left: 2px;
149
      margin-bottom: 0;
150
    }
151
</xsl:template>
152
 
153
<!-- =======================================================================
154
    List of all classes in all packages
155
    This will be the first page in the classListFrame
156
    ======================================================================= -->
157
<xsl:template match="snapshot" mode="all.classes">
158
    <html>
159
        <head>
160
            <xsl:call-template name="create.stylesheet.link"/>
161
        </head>
162
        <body>
163
            <h2>Classes</h2>
164
            <table width="100%">
165
                <xsl:for-each select="package/class">
166
                    <xsl:sort select="@name"/>
167
                    <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/>
168
                    <xsl:variable name="link">
169
                        <xsl:if test="not($package.name='')">
170
                            <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text>
171
                        </xsl:if><xsl:value-of select="@name"/><xsl:text>.html</xsl:text>
172
                    </xsl:variable>
173
                    <tr>
174
                        <td nowrap="nowrap">
175
                            <a target="classFrame" href="{$link}"><xsl:value-of select="@name"/></a>
176
                        </td>
177
                    </tr>
178
                </xsl:for-each>
179
            </table>
180
        </body>
181
    </html>
182
</xsl:template>
183
 
184
<!-- list of all packages -->
185
<xsl:template match="snapshot" mode="all.packages">
186
    <html>
187
        <head>
188
            <xsl:call-template name="create.stylesheet.link"/>
189
        </head>
190
        <body>
191
            <h2><a href="overview-summary.html" target="classFrame">Home</a></h2>
192
            <h2>Packages</h2>
193
            <table width="100%">
194
                <xsl:for-each select="package">
195
                    <xsl:sort select="@name" order="ascending"/>
196
                    <tr>
197
                        <td nowrap="nowrap">
198
                            <a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame">
199
                                <xsl:value-of select="@name"/>
200
                            </a>
201
                        </td>
202
                    </tr>
203
                </xsl:for-each>
204
            </table>
205
        </body>
206
    </html>
207
</xsl:template>
208
 
209
<!-- overview of statistics in packages -->
210
<xsl:template match="snapshot" mode="overview.packages">
211
    <html>
212
        <head>
213
            <xsl:call-template name="create.stylesheet.link"/>
214
        </head>
215
        <body onload="open('allclasses-frame.html','classListFrame')">
216
        <xsl:call-template name="pageHeader"/>
217
        <h3>Summary</h3>
218
        <table class="log" cellpadding="5" cellspacing="2" width="100%">
219
            <tr>
220
                <!--th width="10%" nowrap="nowrap">Date</th>
221
                <th width="10%" nowrap="nowrap">Elapsed time</th-->
222
                <th width="10%" nowrap="nowrap">Reported Classes</th>
223
                <th width="10%" nowrap="nowrap">Methods Hit</th>
224
                <th width="10%" nowrap="nowrap">Lines Hit</th>
225
            </tr>
226
            <tr class="a">
227
                <!--td nowrap="nowrap"><xsl:value-of select="execution_log/@program_start"/></td>
228
                <td><xsl:value-of select="format-number(execution_log/@elapsed_time div 1000,'0.0')"/>secs</td-->
229
                <td><xsl:value-of select="count(package/class)"/></td>
230
                <td><xsl:value-of select="format-number(cov.data/@hit_methods div cov.data/@total_methods,'0.0%')"/></td>
231
                <td><xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/></td>
232
            </tr>
233
        </table>
234
        <table border="0" width="100%">
235
        <tr>
236
        <td style="text-align: justify;">
237
        To ensure accurate test runs on Java applications, developers need to know how much of
238
        the code has been tested, and where to find any untested code. Coverage helps you
239
        locate untested code, and measure precisely how much code has been exercised.
240
        The result is a higher quality application in a shorter period of time.
241
        <p/>
242
        </td>
243
        </tr>
244
        </table>
245
 
246
        <h3>Packages</h3>
247
        <table class="log" cellpadding="5" cellspacing="2" width="100%">
248
            <xsl:apply-templates select="package[1]" mode="stats.header"/>
249
            <!-- display packages and sort them via their coverage rate -->
250
            <xsl:for-each select="package">
251
                <xsl:sort data-type="number" select="cov.data/@hit_lines div cov.data/@total_lines"/>
252
                <tr>
253
                  <xsl:call-template name="alternate-row"/>
254
                    <td><a href="{translate(@name,'.','/')}/package-summary.html"><xsl:value-of select="@name"/></a></td>
255
                    <td><xsl:value-of select="format-number(cov.data/@hit_methods div cov.data/@total_methods,'0.0%')"/></td>
256
                    <td><xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/></td>
257
                </tr>
258
            </xsl:for-each>
259
        </table>
260
        <xsl:call-template name="pageFooter"/>
261
        </body>
262
        </html>
263
</xsl:template>
264
 
265
<!--
266
 detailed info for a package. It will output the list of classes
267
, the summary page, and the info for each class
268
-->
269
<xsl:template match="package" mode="write">
270
    <xsl:variable name="package.dir">
271
        <xsl:if test="not(@name = '')"><xsl:value-of select="translate(@name,'.','/')"/></xsl:if>
272
        <xsl:if test="@name = ''">.</xsl:if>
273
    </xsl:variable>
274
 
275
    <!-- create a classes-list.html in the package directory -->
276
    <redirect:write file="{$output.dir}/{$package.dir}/package-frame.html">
277
        <xsl:apply-templates select="." mode="classes.list"/>
278
    </redirect:write>
279
 
280
    <!-- create a package-summary.html in the package directory -->
281
    <redirect:write file="{$output.dir}/{$package.dir}/package-summary.html">
282
        <xsl:apply-templates select="." mode="package.summary"/>
283
    </redirect:write>
284
 
285
    <!-- for each class, creates a @name.html -->
286
    <xsl:for-each select="class">
287
        <redirect:write file="{$output.dir}/{$package.dir}/{@name}.html">
288
            <xsl:apply-templates select="." mode="class.details"/>
289
        </redirect:write>
290
    </xsl:for-each>
291
</xsl:template>
292
 
293
<!-- list of classes in a package -->
294
<xsl:template match="package" mode="classes.list">
295
    <html>
296
        <HEAD>
297
            <xsl:call-template name="create.stylesheet.link">
298
                <xsl:with-param name="package.name" select="@name"/>
299
            </xsl:call-template>
300
        </HEAD>
301
        <BODY>
302
            <table width="100%">
303
                <tr>
304
                    <td nowrap="nowrap">
305
                        <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="@name"/></a></H2>
306
                    </td>
307
                </tr>
308
            </table>
309
 
310
            <H2>Classes</H2>
311
            <TABLE WIDTH="100%">
312
                <xsl:for-each select="class">
313
                    <xsl:sort select="@name"/>
314
                    <tr>
315
                        <td nowrap="nowrap">
316
                            <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a>
317
                        </td>
318
                    </tr>
319
                </xsl:for-each>
320
            </TABLE>
321
        </BODY>
322
    </html>
323
</xsl:template>
324
 
325
<!-- summary of a package -->
326
<xsl:template match="package" mode="package.summary">
327
    <HTML>
328
        <HEAD>
329
            <xsl:call-template name="create.stylesheet.link">
330
                <xsl:with-param name="package.name" select="@name"/>
331
            </xsl:call-template>
332
        </HEAD>
333
        <!-- when loading this package, it will open the classes into the frame -->
334
        <BODY onload="open('package-frame.html','classListFrame')">
335
            <xsl:call-template name="pageHeader"/>
336
            <h3>Package <xsl:value-of select="@name"/></h3>
337
            <table class="log" cellpadding="5" cellspacing="2" width="100%">
338
                <xsl:apply-templates select="." mode="stats.header"/>
339
                <xsl:apply-templates select="." mode="stats"/>
340
            </table>
341
 
342
            <xsl:if test="count(class) &gt; 0">
343
                <H3>Classes</H3>
344
                <table class="log" cellpadding="5" cellspacing="2" width="100%">
345
                    <xsl:apply-templates select="." mode="stats.header"/>
346
                    <xsl:apply-templates select="class" mode="stats">
347
                        <xsl:sort data-type="number" select="cov.data/@hit_lines div cov.data/@total_lines"/>
348
                    </xsl:apply-templates>
349
                </table>
350
            </xsl:if>
351
            <xsl:call-template name="pageFooter"/>
352
        </BODY>
353
    </HTML>
354
</xsl:template>
355
 
356
<!-- details of a class -->
357
<xsl:template match="class" mode="class.details">
358
    <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/>
359
    <HTML>
360
        <HEAD>
361
            <xsl:call-template name="create.stylesheet.link">
362
                <xsl:with-param name="package.name" select="$package.name"/>
363
            </xsl:call-template>
364
        </HEAD>
365
        <BODY>
366
            <xsl:call-template name="pageHeader"/>
367
            <H3>Class <xsl:if test="not($package.name = '')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></H3>
368
 
369
            <!-- class summary -->
370
            <table class="log" cellpadding="5" cellspacing="2" width="100%">
371
                <xsl:apply-templates select="." mode="stats.header"/>
372
                <xsl:apply-templates select="." mode="stats"/>
373
            </table>
374
 
375
            <!-- details of methods -->
376
            <H3>Methods</H3>
377
            <table class="log" cellpadding="5" cellspacing="2" width="100%">
378
                <xsl:apply-templates select="method[1]" mode="stats.header"/>
379
                <xsl:apply-templates select="method" mode="stats">
380
                    <xsl:sort data-type="number" select="cov.data/@hit_lines div cov.data/@total_lines"/>
381
                </xsl:apply-templates>
382
            </table>
383
            <xsl:call-template name="pageFooter"/>
384
        </BODY>
385
    </HTML>
386
 
387
</xsl:template>
388
 
389
<!-- Page Header -->
390
<xsl:template name="pageHeader">
391
  <!-- jakarta logo -->
392
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
393
  <tr>
394
    <td class="bannercell" rowspan="2">
395
      <a href="http://jakarta.apache.org/">
396
      <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
397
      </a>
398
    </td>
399
        <td style="text-align:right"><h2>Source Code Coverage</h2></td>
400
        </tr>
401
        <tr>
402
        <td style="text-align:right">Designed for use with <a href='http://www.sitraka.com/jprobe'>Sitraka JProbe</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
403
        </tr>
404
  </table>
405
    <hr size="1"/>
406
</xsl:template>
407
 
408
<!-- Page Footer -->
409
<xsl:template name="pageFooter">
410
</xsl:template>
411
 
412
 
413
<xsl:template name="table.header">
414
    <tr>
415
        <th width="80%">Name</th>
416
        <th width="10%" nowrap="nowrap">Methods Hit</th>
417
        <th width="10%" nowrap="nowrap">Lines Hit</th>
418
    </tr>
419
</xsl:template>
420
 
421
<xsl:template match="method" mode="stats.header">
422
    <tr>
423
        <th width="90%">Name</th>
424
        <th width="10%" nowrap="nowrap">Lines Hit</th>
425
    </tr>
426
</xsl:template>
427
<xsl:template match="method" mode="stats">
428
    <tr>
429
      <xsl:call-template name="alternate-row"/>
430
        <td><xsl:value-of select="@name"/></td>
431
        <td>
432
        <xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/>
433
        </td>
434
    </tr>
435
</xsl:template>
436
 
437
<xsl:template match="package|class" mode="stats.header">
438
    <tr>
439
        <th width="80%">Name</th>
440
        <th width="10%" nowrap="nowrap">Methods Hit</th>
441
        <th width="10%" nowrap="nowrap">Lines Hit</th>
442
    </tr>
443
</xsl:template>
444
<xsl:template match="package|class" mode="stats">
445
    <tr>
446
      <xsl:call-template name="alternate-row"/>
447
        <td><xsl:value-of select="@name"/></td>
448
        <td><xsl:value-of select="format-number(cov.data/@hit_methods div cov.data/@total_methods,'0.0%')"/></td>
449
        <td><xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/></td>
450
    </tr>
451
</xsl:template>
452
 
453
<!--
454
    transform string like a.b.c to ../../../
455
    @param path the path to transform into a descending directory path
456
-->
457
<xsl:template name="path">
458
    <xsl:param name="path"/>
459
    <xsl:if test="contains($path,'.')">
460
        <xsl:text>../</xsl:text>
461
        <xsl:call-template name="path">
462
            <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param>
463
        </xsl:call-template>
464
    </xsl:if>
465
    <xsl:if test="not(contains($path,'.')) and not($path = '')">
466
        <xsl:text>../</xsl:text>
467
    </xsl:if>
468
</xsl:template>
469
 
470
 
471
<!-- create the link to the stylesheet based on the package name -->
472
<xsl:template name="create.stylesheet.link">
473
    <xsl:param name="package.name"/>
474
    <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>
475
</xsl:template>
476
 
477
<!-- alternated row style -->
478
<xsl:template name="alternate-row">
479
<xsl:attribute name="class">
480
  <xsl:if test="position() mod 2 = 1">a</xsl:if>
481
  <xsl:if test="position() mod 2 = 0">b</xsl:if>
482
</xsl:attribute>
483
</xsl:template>
484
 
485
</xsl:stylesheet>
486
 
487