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="http://xml.apache.org/xalan/redirect"
5
    xmlns:string="xalan://java.lang.String"
6
    extension-element-prefixes="redirect">
7
<xsl:output method="html" indent="yes" encoding="UTF-8"/>
8
<xsl:decimal-format decimal-separator="." grouping-separator=","/>
9
<!--
10
   Licensed to the Apache Software Foundation (ASF) under one or more
11
   contributor license agreements.  See the NOTICE file distributed with
12
   this work for additional information regarding copyright ownership.
13
   The ASF licenses this file to You under the Apache License, Version 2.0
14
   (the "License"); you may not use this file except in compliance with
15
   the License.  You may obtain a copy of the License at
16
 
17
       http://www.apache.org/licenses/LICENSE-2.0
18
 
19
   Unless required by applicable law or agreed to in writing, software
20
   distributed under the License is distributed on an "AS IS" BASIS,
21
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
   See the License for the specific language governing permissions and
23
   limitations under the License.
24
 -->
25
 
26
<!--
27
 
28
 Sample stylesheet to be used with Ant JUnitReport output.
29
 
30
 It creates a set of HTML files a la javadoc where you can browse easily
31
 through all packages and classes.
32
 
33
-->
34
<xsl:param name="output.dir" select="'.'"/>
35
<xsl:param name="TITLE">Unit Test Results.</xsl:param>
36
 
37
 
38
<xsl:template match="testsuites">
39
    <!-- create the index.html -->
40
    <redirect:write file="{$output.dir}/index.html">
41
        <xsl:call-template name="index.html"/>
42
    </redirect:write>
43
 
44
    <!-- create the stylesheet.css -->
45
    <redirect:write file="{$output.dir}/stylesheet.css">
46
        <xsl:call-template name="stylesheet.css"/>
47
    </redirect:write>
48
 
49
    <!-- create the overview-packages.html at the root -->
50
    <redirect:write file="{$output.dir}/overview-summary.html">
51
        <xsl:apply-templates select="." mode="overview.packages"/>
52
    </redirect:write>
53
 
54
    <!-- create the all-packages.html at the root -->
55
    <redirect:write file="{$output.dir}/overview-frame.html">
56
        <xsl:apply-templates select="." mode="all.packages"/>
57
    </redirect:write>
58
 
59
    <!-- create the all-classes.html at the root -->
60
    <redirect:write file="{$output.dir}/allclasses-frame.html">
61
        <xsl:apply-templates select="." mode="all.classes"/>
62
    </redirect:write>
63
 
64
    <!-- create the all-tests.html at the root -->
65
    <redirect:write file="{$output.dir}/all-tests.html">
66
        <xsl:apply-templates select="." mode="all.tests"/>
67
    </redirect:write>
68
 
69
    <!-- create the alltests-fails.html at the root -->
70
    <redirect:write file="{$output.dir}/alltests-fails.html">
71
      <xsl:apply-templates select="." mode="all.tests">
72
        <xsl:with-param name="type" select="'fails'"/>
73
      </xsl:apply-templates>
74
    </redirect:write>
75
 
76
  <!-- create the alltests-errors.html at the root -->
77
    <redirect:write file="{$output.dir}/alltests-errors.html">
78
      <xsl:apply-templates select="." mode="all.tests">
79
        <xsl:with-param name="type" select="'errors'"/>
80
      </xsl:apply-templates>
81
    </redirect:write>
82
 
83
    <!-- create the alltests-skipped.html at the root -->
84
    <redirect:write file="{$output.dir}/alltests-skipped.html">
85
      <xsl:apply-templates select="." mode="all.tests">
86
        <xsl:with-param name="type" select="'skipped'"/>
87
      </xsl:apply-templates>
88
    </redirect:write>
89
 
90
  <!-- process all packages -->
91
    <xsl:for-each select="./testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
92
        <xsl:call-template name="package">
93
            <xsl:with-param name="name" select="@package"/>
94
        </xsl:call-template>
95
    </xsl:for-each>
96
</xsl:template>
97
 
98
 
99
<xsl:template name="package">
100
    <xsl:param name="name"/>
101
    <xsl:variable name="package.dir">
102
        <xsl:if test="not($name = '')"><xsl:value-of select="translate($name,'.','/')"/></xsl:if>
103
        <xsl:if test="$name = ''">.</xsl:if>
104
    </xsl:variable>
105
    <!--Processing package <xsl:value-of select="@name"/> in <xsl:value-of select="$output.dir"/> -->
106
    <!-- create a classes-list.html in the package directory -->
107
    <redirect:write file="{$output.dir}/{$package.dir}/package-frame.html">
108
        <xsl:call-template name="classes.list">
109
            <xsl:with-param name="name" select="$name"/>
110
        </xsl:call-template>
111
    </redirect:write>
112
 
113
    <!-- create a package-summary.html in the package directory -->
114
    <redirect:write file="{$output.dir}/{$package.dir}/package-summary.html">
115
        <xsl:call-template name="package.summary">
116
            <xsl:with-param name="name" select="$name"/>
117
        </xsl:call-template>
118
    </redirect:write>
119
 
120
    <!-- for each class, creates a @name.html -->
121
    <!-- @bug there will be a problem with inner classes having the same name, it will be overwritten -->
122
  <xsl:for-each select="/testsuites/testsuite[@package = $name]">
123
    <redirect:write file="{$output.dir}/{$package.dir}/{@id}_{@name}.html">
124
      <xsl:apply-templates select="." mode="class.details"/>
125
    </redirect:write>
126
    <xsl:if test="string-length(./system-out)!=0">
127
      <redirect:write file="{$output.dir}/{$package.dir}/{@id}_{@name}-out.html">
128
        <html>
129
          <head>
130
            <title>Standard Output from <xsl:value-of select="@name"/></title>
131
          </head>
132
          <body>
133
            <pre><xsl:value-of select="./system-out"/></pre>
134
          </body>
135
        </html>
136
      </redirect:write>
137
    </xsl:if>
138
    <xsl:if test="string-length(./system-err)!=0">
139
      <redirect:write file="{$output.dir}/{$package.dir}/{@id}_{@name}-err.html">
140
        <html>
141
          <head>
142
            <title>Standard Error from <xsl:value-of select="@name"/></title>
143
          </head>
144
          <body>
145
            <pre><xsl:value-of select="./system-err"/></pre>
146
          </body>
147
        </html>
148
      </redirect:write>
149
    </xsl:if>
150
    <xsl:if test="@failures != 0">
151
      <redirect:write file="{$output.dir}/{$package.dir}/{@id}_{@name}-fails.html">
152
        <xsl:apply-templates select="." mode="class.details">
153
          <xsl:with-param name="type" select="'fails'"/>
154
        </xsl:apply-templates>
155
      </redirect:write>
156
    </xsl:if>
157
    <xsl:if test="@errors != 0">
158
      <redirect:write file="{$output.dir}/{$package.dir}/{@id}_{@name}-errors.html">
159
        <xsl:apply-templates select="." mode="class.details">
160
          <xsl:with-param name="type" select="'errors'"/>
161
        </xsl:apply-templates>
162
      </redirect:write>
163
    </xsl:if>
164
    <xsl:if test="@skipped != 0">
165
      <redirect:write file="{$output.dir}/{$package.dir}/{@id}_{@name}-skipped.html">
166
        <xsl:apply-templates select="." mode="class.details">
167
          <xsl:with-param name="type" select="'skipped'"/>
168
        </xsl:apply-templates>
169
      </redirect:write>
170
    </xsl:if>
171
  </xsl:for-each>
172
</xsl:template>
173
 
174
<xsl:template name="index.html">
175
<html>
176
    <head>
177
        <title><xsl:value-of select="$TITLE"/></title>
178
    </head>
179
    <frameset cols="20%,80%">
180
        <frameset rows="30%,70%">
181
            <frame src="overview-frame.html" name="packageListFrame"/>
182
            <frame src="allclasses-frame.html" name="classListFrame"/>
183
        </frameset>
184
        <frame src="overview-summary.html" name="classFrame"/>
185
        <noframes>
186
            <h2>Frame Alert</h2>
187
            <p>
188
                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.
189
            </p>
190
        </noframes>
191
    </frameset>
192
</html>
193
</xsl:template>
194
 
195
<!-- this is the stylesheet css to use for nearly everything -->
196
<xsl:template name="stylesheet.css">
197
body {
198
    font:normal 68% verdana,arial,helvetica;
199
    color:#000000;
200
}
201
table tr td, table tr th {
202
    font-size: 68%;
203
}
204
table.details tr th{
205
    font-weight: bold;
206
    text-align:left;
207
    background:#a6caf0;
208
}
209
table.details tr td{
210
    background:#eeeee0;
211
}
212
 
213
p {
214
    line-height:1.5em;
215
    margin-top:0.5em; margin-bottom:1.0em;
216
}
217
h1 {
218
    margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
219
}
220
h2 {
221
    margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
222
}
223
h3 {
224
    margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
225
}
226
h4 {
227
    margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
228
}
229
h5 {
230
    margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
231
}
232
h6 {
233
    margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
234
}
235
.Error {
236
    font-weight:bold; color:red;
237
}
238
.Failure {
239
    font-weight:bold; color:purple;
240
}
241
.Properties {
242
  text-align:right;
243
}
244
</xsl:template>
245
 
246
<!-- Create list of all/failed/errored/skipped tests -->
247
<xsl:template match="testsuites" mode="all.tests">
248
    <xsl:param name="type" select="'all'"/>
249
    <html>
250
	<xsl:variable name="title">
251
	    <xsl:choose>
252
		<xsl:when test="$type = 'fails'">
253
		    <xsl:text>All Failures</xsl:text>
254
		</xsl:when>
255
		<xsl:when test="$type = 'errors'">
256
		    <xsl:text>All Errors</xsl:text>
257
		</xsl:when>
258
		<xsl:when test="$type = 'skipped'">
259
		    <xsl:text>All Skipped</xsl:text>
260
		</xsl:when>
261
		<xsl:otherwise>
262
		    <xsl:text>All Tests</xsl:text>
263
		</xsl:otherwise>
264
	    </xsl:choose>
265
	</xsl:variable>
266
	<head>
267
	    <title>Unit Test Results: <xsl:value-of select="$title"/></title>
268
	    <xsl:call-template name="create.stylesheet.link">
269
                <xsl:with-param name="package.name"/>
270
            </xsl:call-template>
271
	</head>
272
	<body>
273
	    <xsl:attribute name="onload">open('allclasses-frame.html','classListFrame')</xsl:attribute>
274
            <xsl:call-template name="pageHeader"/>
275
            <h2><xsl:value-of select="$title"/></h2>
276
 
277
            <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
278
		<xsl:call-template name="testcase.test.header">
279
		    <xsl:with-param name="show.class" select="'yes'"/>
280
		</xsl:call-template>
281
		<!--
282
                test can even not be started at all (failure to load the class)
283
		so report the error directly
284
		-->
285
              <xsl:if test="./error">
286
                <tr class="Error">
287
                  <td colspan="4">
288
                    <xsl:apply-templates select="./error"/>
289
                  </td>
290
                </tr>
291
              </xsl:if>
292
              <xsl:choose>
293
                <xsl:when test="$type = 'fails'">
294
                  <xsl:apply-templates select=".//testcase[failure]" mode="print.test">
295
                    <xsl:with-param name="show.class" select="'yes'"/>
296
                  </xsl:apply-templates>
297
                </xsl:when>
298
                <xsl:when test="$type = 'errors'">
299
                  <xsl:apply-templates select=".//testsuite[error]" mode="alltests.error.row"/>
300
                  <xsl:apply-templates select=".//testcase[error]" mode="print.test">
301
                    <xsl:with-param name="show.class" select="'yes'"/>
302
                  </xsl:apply-templates>
303
                </xsl:when>
304
                <xsl:when test="$type = 'skipped'">
305
                  <xsl:apply-templates select=".//testcase[skipped]" mode="print.test">
306
                    <xsl:with-param name="show.class" select="'yes'"/>
307
                  </xsl:apply-templates>
308
                </xsl:when>
309
                <xsl:otherwise>
310
                  <xsl:apply-templates select=".//testsuite[error]" mode="alltests.error.row"/>
311
                  <xsl:apply-templates select=".//testcase" mode="print.test">
312
                    <xsl:with-param name="show.class" select="'yes'"/>
313
                  </xsl:apply-templates>
314
                </xsl:otherwise>
315
              </xsl:choose>
316
            </table>
317
        </body>
318
    </html>
319
</xsl:template>
320
 
321
 
322
<!-- ======================================================================
323
    This page is created for every testsuite class.
324
    It prints a summary of the testsuite and detailed information about
325
    testcase methods.
326
     ====================================================================== -->
327
<xsl:template match="testsuite" mode="class.details">
328
    <xsl:param name="type" select="'all'"/>
329
    <xsl:variable name="package.name" select="@package"/>
330
    <xsl:variable name="class.name"><xsl:if test="not($package.name = '')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></xsl:variable>
331
    <html>
332
        <head>
333
          <title>Unit Test Results: <xsl:value-of select="$class.name"/></title>
334
            <xsl:call-template name="create.stylesheet.link">
335
                <xsl:with-param name="package.name" select="$package.name"/>
336
            </xsl:call-template>
337
       <script type="text/javascript" language="JavaScript">
338
        var TestCases = new Array();
339
        var cur;
340
        <xsl:apply-templates select="properties"/>
341
       </script>
342
       <script type="text/javascript" language="JavaScript"><![CDATA[
343
        function displayProperties (name) {
344
          var win = window.open('','JUnitSystemProperties','scrollbars=1,resizable=1');
345
          var doc = win.document;
346
          doc.open();
347
          doc.write("<html><head><title>Properties of " + name + "</title>");
348
          doc.write("<style type=\"text/css\">");
349
          doc.write("body {font:normal 68% verdana,arial,helvetica; color:#000000; }");
350
          doc.write("table tr td, table tr th { font-size: 68%; }");
351
          doc.write("table.properties { border-collapse:collapse; border-left:solid 1 #cccccc; border-top:solid 1 #cccccc; padding:5px; }");
352
          doc.write("table.properties th { text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#eeeeee; }");
353
          doc.write("table.properties td { font:normal; text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#fffffff; }");
354
          doc.write("h3 { margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica }");
355
          doc.write("</style>");
356
          doc.write("</head><body>");
357
          doc.write("<h3>Properties of " + name + "</h3>");
358
          doc.write("<div align=\"right\"><a href=\"javascript:window.close();\">Close</a></div>");
359
          doc.write("<table class='properties'>");
360
          doc.write("<tr><th>Name</th><th>Value</th></tr>");
361
          for (prop in TestCases[name]) {
362
            doc.write("<tr><th>" + prop + "</th><td>" + TestCases[name][prop] + "</td></tr>");
363
          }
364
          doc.write("</table>");
365
          doc.write("</body></html>");
366
          doc.close();
367
          win.focus();
368
        }
369
      ]]>
370
      </script>
371
        </head>
372
        <body>
373
            <xsl:call-template name="pageHeader"/>
374
            <h3>Class <xsl:value-of select="$class.name"/></h3>
375
 
376
 
377
            <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
378
                <xsl:call-template name="testsuite.test.header"/>
379
                <xsl:apply-templates select="." mode="print.test"/>
380
            </table>
381
 
382
	    <xsl:choose>
383
		<xsl:when test="$type = 'fails'">
384
		    <h2>Failures</h2>
385
		</xsl:when>
386
		<xsl:when test="$type = 'errors'">
387
		    <h2>Errors</h2>
388
		</xsl:when>
389
		<xsl:when test="$type = 'skipped'">
390
		    <h2>Skipped</h2>
391
		</xsl:when>
392
		<xsl:otherwise>
393
		    <h2>Tests</h2>
394
		</xsl:otherwise>
395
	    </xsl:choose>
396
            <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
397
		<xsl:call-template name="testcase.test.header"/>
398
		<!--
399
                test can even not be started at all (failure to load the class)
400
		so report the error directly
401
		-->
402
                <xsl:if test="./error">
403
                    <tr class="Error">
404
                        <td colspan="4"><xsl:apply-templates select="./error"/></td>
405
                    </tr>
406
                </xsl:if>
407
		<xsl:choose>
408
		    <xsl:when test="$type = 'fails'">
409
			<xsl:apply-templates select="./testcase[failure]" mode="print.test"/>
410
		    </xsl:when>
411
		    <xsl:when test="$type = 'errors'">
412
			<xsl:apply-templates select="./testcase[error]" mode="print.test"/>
413
		    </xsl:when>
414
		    <xsl:when test="$type = 'skipped'">
415
			<xsl:apply-templates select="./testcase[skipped]" mode="print.test"/>
416
		    </xsl:when>
417
		    <xsl:otherwise>
418
			<xsl:apply-templates select="./testcase" mode="print.test"/>
419
		    </xsl:otherwise>
420
		</xsl:choose>
421
            </table>
422
            <div class="Properties">
423
                <a>
424
                    <xsl:attribute name="href">javascript:displayProperties('<xsl:value-of select="@package"/>.<xsl:value-of select="@name"/>');</xsl:attribute>
425
                    Properties &#187;
426
                </a>
427
            </div>
428
            <xsl:if test="string-length(./system-out)!=0">
429
                <div class="Properties">
430
                    <a>
431
                        <xsl:attribute name="href">./<xsl:value-of select="@id"/>_<xsl:value-of select="@name"/>-out.html</xsl:attribute>
432
                        System.out &#187;
433
                    </a>
434
                </div>
435
            </xsl:if>
436
            <xsl:if test="string-length(./system-err)!=0">
437
                <div class="Properties">
438
                    <a>
439
                        <xsl:attribute name="href">./<xsl:value-of select="@id"/>_<xsl:value-of select="@name"/>-err.html</xsl:attribute>
440
                        System.err &#187;
441
                    </a>
442
                </div>
443
            </xsl:if>
444
        </body>
445
    </html>
446
</xsl:template>
447
 
448
  <!--
449
   Write properties into a JavaScript data structure.
450
   This is based on the original idea by Erik Hatcher (ehatcher@apache.org)
451
   -->
452
  <xsl:template match="properties">
453
    cur = TestCases['<xsl:value-of select="../@package"/>.<xsl:value-of select="../@name"/>'] = new Array();
454
    <xsl:for-each select="property">
455
    <xsl:sort select="@name"/>
456
        cur['<xsl:value-of select="@name"/>'] = '<xsl:call-template name="JS-escape"><xsl:with-param name="string" select="@value"/></xsl:call-template>';
457
    </xsl:for-each>
458
  </xsl:template>
459
 
460
 
461
<!-- ======================================================================
462
    This page is created for every package.
463
    It prints the name of all classes that belongs to this package.
464
    @param name the package name to print classes.
465
     ====================================================================== -->
466
<!-- list of classes in a package -->
467
<xsl:template name="classes.list">
468
    <xsl:param name="name"/>
469
    <html>
470
        <head>
471
            <title>Unit Test Classes: <xsl:value-of select="$name"/></title>
472
            <xsl:call-template name="create.stylesheet.link">
473
                <xsl:with-param name="package.name" select="$name"/>
474
            </xsl:call-template>
475
        </head>
476
        <body>
477
            <table width="100%">
478
                <tr>
479
                    <td nowrap="nowrap">
480
                        <h2><a href="package-summary.html" target="classFrame">
481
                            <xsl:value-of select="$name"/>
482
                            <xsl:if test="$name = ''">&lt;none&gt;</xsl:if>
483
                        </a></h2>
484
                    </td>
485
                </tr>
486
            </table>
487
 
488
            <h2>Classes</h2>
489
            <table width="100%">
490
                <xsl:for-each select="/testsuites/testsuite[./@package = $name]">
491
                    <xsl:sort select="@name"/>
492
                    <tr>
493
                        <td nowrap="nowrap">
494
                            <a href="{@id}_{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a>
495
                        </td>
496
                    </tr>
497
                </xsl:for-each>
498
            </table>
499
        </body>
500
    </html>
501
</xsl:template>
502
 
503
 
504
<!--
505
    Creates an all-classes.html file that contains a link to all package-summary.html
506
    on each class.
507
-->
508
<xsl:template match="testsuites" mode="all.classes">
509
    <html>
510
        <head>
511
            <title>All Unit Test Classes</title>
512
            <xsl:call-template name="create.stylesheet.link">
513
                <xsl:with-param name="package.name"/>
514
            </xsl:call-template>
515
        </head>
516
        <body>
517
            <h2>Classes</h2>
518
            <table width="100%">
519
                <xsl:apply-templates select="testsuite" mode="all.classes">
520
                    <xsl:sort select="@name"/>
521
                </xsl:apply-templates>
522
            </table>
523
        </body>
524
    </html>
525
</xsl:template>
526
 
527
<xsl:template match="testsuite" mode="all.classes">
528
    <xsl:variable name="package.name" select="@package"/>
529
    <tr>
530
        <td nowrap="nowrap">
531
            <a target="classFrame">
532
                <xsl:attribute name="href">
533
                    <xsl:if test="not($package.name='')">
534
                        <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text>
535
                    </xsl:if><xsl:value-of select="@id"/>_<xsl:value-of select="@name"/><xsl:text>.html</xsl:text>
536
                </xsl:attribute>
537
                <xsl:value-of select="@name"/>
538
            </a>
539
        </td>
540
    </tr>
541
</xsl:template>
542
 
543
 
544
<!--
545
    Creates an html file that contains a link to all package-summary.html files on
546
    each package existing on testsuites.
547
    @bug there will be a problem here, I don't know yet how to handle unnamed package :(
548
-->
549
<xsl:template match="testsuites" mode="all.packages">
550
    <html>
551
        <head>
552
            <title>All Unit Test Packages</title>
553
            <xsl:call-template name="create.stylesheet.link">
554
                <xsl:with-param name="package.name"/>
555
            </xsl:call-template>
556
        </head>
557
        <body>
558
            <h2><a href="overview-summary.html" target="classFrame">Home</a></h2>
559
            <h2>Packages</h2>
560
            <table width="100%">
561
                <xsl:apply-templates select="testsuite[not(./@package = preceding-sibling::testsuite/@package)]" mode="all.packages">
562
                    <xsl:sort select="@package"/>
563
                </xsl:apply-templates>
564
            </table>
565
        </body>
566
    </html>
567
</xsl:template>
568
 
569
<xsl:template match="testsuite" mode="all.packages">
570
    <tr>
571
        <td nowrap="nowrap">
572
            <a href="./{translate(@package,'.','/')}/package-summary.html" target="classFrame">
573
                <xsl:value-of select="@package"/>
574
                <xsl:if test="@package = ''">&lt;none&gt;</xsl:if>
575
            </a>
576
        </td>
577
    </tr>
578
</xsl:template>
579
 
580
 
581
<xsl:template match="testsuites" mode="overview.packages">
582
    <html>
583
        <head>
584
            <title>Unit Test Results: Summary</title>
585
            <xsl:call-template name="create.stylesheet.link">
586
                <xsl:with-param name="package.name"/>
587
            </xsl:call-template>
588
        </head>
589
        <body>
590
        <xsl:attribute name="onload">open('allclasses-frame.html','classListFrame')</xsl:attribute>
591
        <xsl:call-template name="pageHeader"/>
592
        <h2>Summary</h2>
593
        <xsl:variable name="testCount" select="sum(testsuite/@tests)"/>
594
        <xsl:variable name="errorCount" select="sum(testsuite/@errors)"/>
595
        <xsl:variable name="failureCount" select="sum(testsuite/@failures)"/>
596
        <xsl:variable name="skippedCount" select="sum(testsuite/@skipped)" />
597
        <xsl:variable name="timeCount" select="sum(testsuite/@time)"/>
598
        <xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/>
599
        <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
600
        <tr valign="top">
601
            <th>Tests</th>
602
            <th>Failures</th>
603
            <th>Errors</th>
604
            <th>Skipped</th>
605
            <th>Success rate</th>
606
            <th>Time</th>
607
        </tr>
608
        <tr valign="top">
609
            <xsl:attribute name="class">
610
                <xsl:choose>
611
                    <xsl:when test="$errorCount &gt; 0">Error</xsl:when>
612
                    <xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
613
                    <xsl:otherwise>Pass</xsl:otherwise>
614
                </xsl:choose>
615
            </xsl:attribute>
616
            <td><a title="Display all tests" href="all-tests.html"><xsl:value-of select="$testCount"/></a></td>
617
            <td><a title="Display all failures" href="alltests-fails.html"><xsl:value-of select="$failureCount"/></a></td>
618
            <td><a title="Display all errors" href="alltests-errors.html"><xsl:value-of select="$errorCount"/></a></td>
619
            <td><a title="Display all skipped test" href="alltests-skipped.html"><xsl:value-of select="$skippedCount" /></a></td>
620
            <td>
621
                <xsl:call-template name="display-percent">
622
                    <xsl:with-param name="value" select="$successRate"/>
623
                </xsl:call-template>
624
            </td>
625
            <td>
626
                <xsl:call-template name="display-time">
627
                    <xsl:with-param name="value" select="$timeCount"/>
628
                </xsl:call-template>
629
            </td>
630
        </tr>
631
        </table>
632
        <table border="0" width="95%">
633
        <tr>
634
        <td style="text-align: justify;">
635
        Note: <em>failures</em> are anticipated and checked for with assertions while <em>errors</em> are unanticipated.
636
        </td>
637
        </tr>
638
        </table>
639
 
640
        <h2>Packages</h2>
641
        <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
642
            <xsl:call-template name="testsuite.test.header"/>
643
            <xsl:for-each select="testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
644
                <xsl:sort select="@package" order="ascending"/>
645
                <!-- get the node set containing all testsuites that have the same package -->
646
                <xsl:variable name="insamepackage" select="/testsuites/testsuite[./@package = current()/@package]"/>
647
                <tr valign="top">
648
                    <!-- display a failure if there is any failure/error in the package -->
649
                    <xsl:attribute name="class">
650
                        <xsl:choose>
651
                            <xsl:when test="sum($insamepackage/@errors) &gt; 0">Error</xsl:when>
652
                            <xsl:when test="sum($insamepackage/@failures) &gt; 0">Failure</xsl:when>
653
                            <xsl:otherwise>Pass</xsl:otherwise>
654
                        </xsl:choose>
655
                    </xsl:attribute>
656
                    <td><a href="./{translate(@package,'.','/')}/package-summary.html">
657
                        <xsl:value-of select="@package"/>
658
                        <xsl:if test="@package = ''">&lt;none&gt;</xsl:if>
659
                    </a></td>
660
                    <td><xsl:value-of select="sum($insamepackage/@tests)"/></td>
661
                    <td><xsl:value-of select="sum($insamepackage/@errors)"/></td>
662
                    <td><xsl:value-of select="sum($insamepackage/@failures)"/></td>
663
                    <td><xsl:value-of select="sum($insamepackage/@skipped)" /></td>
664
                    <td>
665
                    <xsl:call-template name="display-time">
666
                        <xsl:with-param name="value" select="sum($insamepackage/@time)"/>
667
                    </xsl:call-template>
668
                    </td>
669
                    <td><xsl:value-of select="$insamepackage/@timestamp"/></td>
670
                    <td><xsl:value-of select="$insamepackage/@hostname"/></td>
671
                </tr>
672
            </xsl:for-each>
673
        </table>
674
        </body>
675
        </html>
676
</xsl:template>
677
 
678
 
679
<xsl:template name="package.summary">
680
    <xsl:param name="name"/>
681
    <html>
682
        <head>
683
            <xsl:call-template name="create.stylesheet.link">
684
                <xsl:with-param name="package.name" select="$name"/>
685
            </xsl:call-template>
686
        </head>
687
        <body>
688
            <xsl:attribute name="onload">open('package-frame.html','classListFrame')</xsl:attribute>
689
            <xsl:call-template name="pageHeader"/>
690
            <h3>Package <xsl:value-of select="$name"/></h3>
691
 
692
            <!--table border="0" cellpadding="5" cellspacing="2" width="95%">
693
                <xsl:call-template name="class.metrics.header"/>
694
                <xsl:apply-templates select="." mode="print.metrics"/>
695
            </table-->
696
 
697
            <xsl:variable name="insamepackage" select="/testsuites/testsuite[./@package = $name]"/>
698
            <xsl:if test="count($insamepackage) &gt; 0">
699
                <h2>Classes</h2>
700
                <p>
701
                <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
702
                    <xsl:call-template name="testsuite.test.header"/>
703
                    <xsl:apply-templates select="$insamepackage" mode="print.test">
704
                        <xsl:sort select="@name"/>
705
                    </xsl:apply-templates>
706
                </table>
707
                </p>
708
            </xsl:if>
709
        </body>
710
    </html>
711
</xsl:template>
712
 
713
 
714
<!--
715
    transform string like a.b.c to ../../../
716
    @param path the path to transform into a descending directory path
717
-->
718
<xsl:template name="path">
719
    <xsl:param name="path"/>
720
    <xsl:if test="contains($path,'.')">
721
        <xsl:text>../</xsl:text>
722
        <xsl:call-template name="path">
723
            <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param>
724
        </xsl:call-template>
725
    </xsl:if>
726
    <xsl:if test="not(contains($path,'.')) and not($path = '')">
727
        <xsl:text>../</xsl:text>
728
    </xsl:if>
729
</xsl:template>
730
 
731
 
732
<!-- create the link to the stylesheet based on the package name -->
733
<xsl:template name="create.stylesheet.link">
734
    <xsl:param name="package.name"/>
735
    <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>
736
</xsl:template>
737
 
738
 
739
<!-- Page HEADER -->
740
<xsl:template name="pageHeader">
741
    <h1><xsl:value-of select="$TITLE"/></h1>
742
    <table width="100%">
743
    <tr>
744
        <td align="left"></td>
745
        <td align="right">Designed for use with <a href="http://www.junit.org/">JUnit</a> and <a href="http://ant.apache.org/">Ant</a>.</td>
746
    </tr>
747
    </table>
748
    <hr size="1"/>
749
</xsl:template>
750
 
751
<!-- class header -->
752
<xsl:template name="testsuite.test.header">
753
    <tr valign="top">
754
        <th width="80%">Name</th>
755
        <th>Tests</th>
756
        <th>Errors</th>
757
        <th>Failures</th>
758
        <th>Skipped</th>
759
        <th nowrap="nowrap">Time(s)</th>
760
        <th nowrap="nowrap">Time Stamp</th>
761
        <th>Host</th>
762
    </tr>
763
</xsl:template>
764
 
765
<!-- method header -->
766
<xsl:template name="testcase.test.header">
767
    <xsl:param name="show.class" select="''"/>
768
    <tr valign="top">
769
	<xsl:if test="boolean($show.class)">
770
	    <th>Class</th>
771
	</xsl:if>
772
        <th>Name</th>
773
        <th>Status</th>
774
        <th width="80%">Type</th>
775
        <th nowrap="nowrap">Time(s)</th>
776
    </tr>
777
</xsl:template>
778
 
779
 
780
<!-- class information -->
781
<xsl:template match="testsuite" mode="print.test">
782
    <tr valign="top">
783
        <xsl:attribute name="class">
784
            <xsl:choose>
785
                <xsl:when test="@errors[.&gt; 0]">Error</xsl:when>
786
                <xsl:when test="@failures[.&gt; 0]">Failure</xsl:when>
787
                <xsl:otherwise>Pass</xsl:otherwise>
788
            </xsl:choose>
789
        </xsl:attribute>
790
        <td><a title="Display all tests" href="{@id}_{@name}.html"><xsl:value-of select="@name"/></a></td>
791
        <td><a title="Display all tests" href="{@id}_{@name}.html"><xsl:apply-templates select="@tests"/></a></td>
792
        <td>
793
	    <xsl:choose>
794
		<xsl:when test="@errors != 0">
795
		    <a title="Display only errors" href="{@id}_{@name}-errors.html"><xsl:apply-templates select="@errors"/></a>
796
		</xsl:when>
797
		<xsl:otherwise>
798
		    <xsl:apply-templates select="@errors"/>
799
		</xsl:otherwise>
800
	    </xsl:choose>
801
		</td>
802
	    <td>
803
	    <xsl:choose>
804
		<xsl:when test="@failures != 0">
805
		    <a title="Display only failures" href="{@id}_{@name}-fails.html"><xsl:apply-templates select="@failures"/></a>
806
		</xsl:when>
807
		<xsl:otherwise>
808
		    <xsl:apply-templates select="@failures"/>
809
		</xsl:otherwise>
810
	    </xsl:choose>
811
		</td>
812
	    <td>
813
	    <xsl:choose>
814
		<xsl:when test="@skipped != 0">
815
		    <a title="Display only skipped tests" href="{@id}_{@name}-skipped.html"><xsl:apply-templates select="@skipped"/></a>
816
		</xsl:when>
817
		<xsl:otherwise>
818
		    <xsl:apply-templates select="@skipped"/>
819
		</xsl:otherwise>
820
	    </xsl:choose>
821
		</td>
822
        <td><xsl:call-template name="display-time">
823
                <xsl:with-param name="value" select="@time"/>
824
            </xsl:call-template>
825
        </td>
826
        <td><xsl:apply-templates select="@timestamp"/></td>
827
        <td><xsl:apply-templates select="@hostname"/></td>
828
    </tr>
829
</xsl:template>
830
 
831
<xsl:template match="testcase" mode="print.test">
832
    <xsl:param name="show.class" select="''"/>
833
    <tr valign="top">
834
        <xsl:attribute name="class">
835
            <xsl:choose>
836
                <xsl:when test="error">Error</xsl:when>
837
                <xsl:when test="failure">Failure</xsl:when>
838
                <xsl:otherwise>TableRowColor</xsl:otherwise>
839
            </xsl:choose>
840
        </xsl:attribute>
841
	<xsl:variable name="class.href">
842
	    <xsl:value-of select="concat(translate(../@package,'.','/'), '/', ../@id, '_', ../@name, '.html')"/>
843
	</xsl:variable>
844
	<xsl:if test="boolean($show.class)">
845
	    <td><a href="{$class.href}"><xsl:value-of select="../@name"/></a></td>
846
	</xsl:if>
847
        <td>
848
	    <a name="{@name}"/>
849
	    <xsl:choose>
850
		<xsl:when test="boolean($show.class)">
851
		    <a href="{concat($class.href, '#', @name)}"><xsl:value-of select="@name"/></a>
852
		</xsl:when>
853
		<xsl:otherwise>
854
		    <xsl:value-of select="@name"/>
855
		</xsl:otherwise>
856
	    </xsl:choose>
857
	</td>
858
        <xsl:choose>
859
            <xsl:when test="failure">
860
                <td>Failure</td>
861
                <td><xsl:apply-templates select="failure"/></td>
862
            </xsl:when>
863
            <xsl:when test="error">
864
                <td>Error</td>
865
                <td><xsl:apply-templates select="error"/></td>
866
            </xsl:when>
867
            <xsl:when test="skipped">
868
                <td>Skipped</td>
869
                <td><xsl:apply-templates select="skipped"/></td>
870
            </xsl:when>
871
            <xsl:otherwise>
872
                <td>Success</td>
873
                <td></td>
874
            </xsl:otherwise>
875
        </xsl:choose>
876
        <td>
877
            <xsl:call-template name="display-time">
878
                <xsl:with-param name="value" select="@time"/>
879
            </xsl:call-template>
880
        </td>
881
    </tr>
882
</xsl:template>
883
 
884
 
885
<!-- Note : the below template skipped, error and failure are the same style
886
            so just call the same style store in the toolkit template -->
887
<xsl:template match="failure">
888
    <xsl:call-template name="display-failures"/>
889
</xsl:template>
890
 
891
<xsl:template match="error">
892
    <xsl:call-template name="display-failures"/>
893
</xsl:template>
894
 
895
<xsl:template match="skipped">
896
    <xsl:call-template name="display-failures"/>
897
</xsl:template>
898
 
899
<!-- Style for the error and failure in the testcase template -->
900
<xsl:template name="display-failures">
901
    <xsl:choose>
902
        <xsl:when test="not(@message)">N/A</xsl:when>
903
        <xsl:otherwise>
904
            <xsl:value-of select="@message"/>
905
        </xsl:otherwise>
906
    </xsl:choose>
907
    <!-- display the stacktrace -->
908
    <br/><br/>
909
    <code>
910
        <xsl:call-template name="br-replace">
911
            <xsl:with-param name="word" select="."/>
912
        </xsl:call-template>
913
    </code>
914
    <!-- the latter is better but might be problematic for non-21" monitors... -->
915
    <!--pre><xsl:value-of select="."/></pre-->
916
</xsl:template>
917
 
918
<xsl:template name="JS-escape">
919
    <xsl:param name="string"/>
920
    <xsl:param name="tmp1" select="string:replaceAll(string:new(string($string)),'\\','\\\\')"/>
921
    <xsl:param name="tmp2" select="string:replaceAll(string:new(string($tmp1)),&quot;'&quot;,&quot;\\&apos;&quot;)"/>
922
    <xsl:param name="tmp3" select="string:replaceAll(string:new(string($tmp2)),&quot;&#10;&quot;,'\\n')"/>
923
    <xsl:param name="tmp4" select="string:replaceAll(string:new(string($tmp3)),&quot;&#13;&quot;,'\\r')"/>
924
    <xsl:value-of select="$tmp4"/>
925
</xsl:template>
926
 
927
 
928
<!--
929
    template that will convert a carriage return into a br tag
930
    @param word the text from which to convert CR to BR tag
931
-->
932
<xsl:template name="br-replace">
933
    <xsl:param name="word"/>
934
    <xsl:param name="splitlimit">32</xsl:param>
935
    <xsl:variable name="secondhalfstartindex" select="(string-length($word)+(string-length($word) mod 2)) div 2"/>
936
    <xsl:variable name="secondhalfword" select="substring($word, $secondhalfstartindex)"/>
937
    <!-- When word is very big, a recursive replace is very heap/stack expensive, so subdivide on line break after middle of string -->
938
    <xsl:choose>
939
      <xsl:when test="(string-length($word) > $splitlimit) and (contains($secondhalfword, '&#xa;'))">
940
        <xsl:variable name="secondhalfend" select="substring-after($secondhalfword, '&#xa;')"/>
941
        <xsl:variable name="firsthalflen" select="string-length($word) - string-length($secondhalfword)"/>
942
        <xsl:variable name="firsthalfword" select="substring($word, 1, $firsthalflen)"/>
943
        <xsl:variable name="firsthalfend" select="substring-before($secondhalfword, '&#xa;')"/>
944
        <xsl:call-template name="br-replace">
945
            <xsl:with-param name="word" select="concat($firsthalfword,$firsthalfend)"/>
946
        </xsl:call-template>
947
        <br/>
948
        <xsl:call-template name="br-replace">
949
            <xsl:with-param name="word" select="$secondhalfend"/>
950
        </xsl:call-template>
951
      </xsl:when>
952
      <xsl:when test="contains($word, '&#xa;')">
953
        <xsl:value-of select="substring-before($word, '&#xa;')"/>
954
        <br/>
955
        <xsl:call-template name="br-replace">
956
          <xsl:with-param name="word" select="substring-after($word, '&#xa;')"/>
957
        </xsl:call-template>
958
      </xsl:when>
959
      <xsl:otherwise>
960
        <xsl:value-of select="$word"/>
961
      </xsl:otherwise>
962
    </xsl:choose>
963
</xsl:template>
964
 
965
<xsl:template name="display-time">
966
    <xsl:param name="value"/>
967
    <xsl:value-of select="format-number($value,'0.000')"/>
968
</xsl:template>
969
 
970
<xsl:template name="display-percent">
971
    <xsl:param name="value"/>
972
    <xsl:value-of select="format-number($value,'0.00%')"/>
973
</xsl:template>
974
 
975
<xsl:template match="testsuite" mode="alltests.error.row">
976
  <xsl:variable name="package.dir">
977
    <xsl:if test="not(@package = '')"><xsl:value-of select="translate(@package,'.','/')"/><xsl:text>/</xsl:text></xsl:if>
978
  </xsl:variable>
979
  <xsl:variable name="class.href">
980
    <xsl:value-of select="concat($package.dir, @id, '_', @name, '.html')"/>
981
  </xsl:variable>
982
  <tr class="Error">
983
    <td><a href="{$class.href}"><xsl:value-of select="@name"/></a></td>
984
    <td colspan="3"><xsl:apply-templates select="./error"/></td>
985
  </tr>
986
</xsl:template>
987
 
988
</xsl:stylesheet>