OSDN Git Service

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