root/trunk/config/junit-frames.xsl

Revision 1011, 28.8 kB (checked in by amandel, 4 years ago)

Aligned svn keyword settings.

  • Property svn:mime-type set to text/xml
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
2    xmlns:lxslt="http://xml.apache.org/xslt"
3    xmlns:redirect="http://xml.apache.org/xalan/redirect"
4    extension-element-prefixes="redirect">
5<xsl:output method="html" indent="yes" encoding="US-ASCII"/>
6<xsl:decimal-format decimal-separator="." grouping-separator=","/>
7<!--
8 The Apache Software License, Version 1.1
9
10 Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
11 reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions
15 are met:
16
17 1. Redistributions of source code must retain the above copyright
18    notice, this list of conditions and the following disclaimer.
19
20 2. Redistributions in binary form must reproduce the above copyright
21    notice, this list of conditions and the following disclaimer in
22    the documentation and/or other materials provided with the
23    distribution.
24
25 3. The end-user documentation included with the redistribution, if
26    any, must include the following acknowlegement:
27       "This product includes software developed by the
28        Apache Software Foundation (http://www.apache.org/)."
29    Alternately, this acknowlegement may appear in the software itself,
30    if and wherever such third-party acknowlegements normally appear.
31
32 4. The names "The Jakarta Project", "Ant", and "Apache Software
33    Foundation" must not be used to endorse or promote products derived
34    from this software without prior written permission. For written
35    permission, please contact apache@apache.org.
36
37 5. Products derived from this software may not be called "Apache"
38    nor may "Apache" appear in their names without prior written
39    permission of the Apache Group.
40
41 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
42 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
43 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44 DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
45 ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
47 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
48 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
49 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
50 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
51 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52 SUCH DAMAGE.
53 ====================================================================
54
55 This software consists of voluntary contributions made by many
56 individuals on behalf of the Apache Software Foundation.  For more
57 information on the Apache Software Foundation, please see
58 <http://www.apache.org/>.
59 -->
60
61<!--
62 
63 Sample stylesheet to be used with An JUnitReport output.
64 
65 It creates a set of HTML files a la javadoc where you can browse easily
66 through all packages and classes.
67 
68 @author Stephane Bailliez <a href="mailto:sbailliez@apache.org"/>
69 @author Erik Hatcher <a href="mailto:ehatcher@apache.org"/>
70 
71-->
72<xsl:param name="output.dir" select="'.'"/>
73
74
75<xsl:template match="testsuites">
76    <!-- create the index.html -->
77    <redirect:write file="{$output.dir}/index.html">
78        <xsl:call-template name="index.html"/>
79    </redirect:write>
80
81    <!-- create the stylesheet.css -->
82    <redirect:write file="{$output.dir}/stylesheet.css">
83        <xsl:call-template name="stylesheet.css"/>
84    </redirect:write>
85
86    <!-- create the overview-packages.html at the root -->
87    <redirect:write file="{$output.dir}/overview-summary.html">
88        <xsl:apply-templates select="." mode="overview.packages"/>
89    </redirect:write>
90
91    <!-- create the all-packages.html at the root -->
92    <redirect:write file="{$output.dir}/overview-frame.html">
93        <xsl:apply-templates select="." mode="all.packages"/>
94    </redirect:write>
95   
96    <!-- create the all-classes.html at the root -->
97    <redirect:write file="{$output.dir}/allclasses-frame.html">
98        <xsl:apply-templates select="." mode="all.classes"/>
99    </redirect:write>
100   
101    <!-- process all packages -->
102    <xsl:for-each select="./testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
103        <xsl:call-template name="package">
104            <xsl:with-param name="name" select="@package"/>
105        </xsl:call-template>
106    </xsl:for-each>
107</xsl:template>
108
109
110<xsl:template name="package">
111    <xsl:param name="name"/>
112    <xsl:variable name="package.dir">
113        <xsl:if test="not($name = '')"><xsl:value-of select="translate($name,'.','/')"/></xsl:if>
114        <xsl:if test="$name = ''">.</xsl:if>
115    </xsl:variable> 
116    <!--Processing package <xsl:value-of select="@name"/> in <xsl:value-of select="$output.dir"/> -->
117    <!-- create a classes-list.html in the package directory -->
118    <redirect:write file="{$output.dir}/{$package.dir}/package-frame.html">
119        <xsl:call-template name="classes.list">
120            <xsl:with-param name="name" select="$name"/>
121        </xsl:call-template>
122    </redirect:write>
123   
124    <!-- create a package-summary.html in the package directory -->
125    <redirect:write file="{$output.dir}/{$package.dir}/package-summary.html">
126        <xsl:call-template name="package.summary">
127            <xsl:with-param name="name" select="$name"/>
128        </xsl:call-template>
129    </redirect:write>
130   
131    <!-- for each class, creates a @name.html -->
132    <!-- @bug there will be a problem with inner classes having the same name, it will be overwritten -->
133    <xsl:for-each select="/testsuites/testsuite[@package = $name]">
134        <redirect:write file="{$output.dir}/{$package.dir}/{@name}.html">
135            <xsl:apply-templates select="." mode="class.details"/>
136        </redirect:write>
137    </xsl:for-each>
138</xsl:template>
139
140<xsl:template name="index.html">
141<html>
142    <head>
143        <title>Unit Test Results.</title>
144    </head>
145    <frameset cols="20%,80%">
146        <frameset rows="30%,70%">
147            <frame src="overview-frame.html" name="packageListFrame"/>
148            <frame src="allclasses-frame.html" name="classListFrame"/>
149        </frameset>
150        <frame src="overview-summary.html" name="classFrame"/>
151        <noframes>
152            <h2>Frame Alert</h2>
153            <p>
154                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.
155            </p>
156        </noframes>
157    </frameset>
158</html>
159</xsl:template>
160
161<!-- this is the stylesheet css to use for nearly everything -->
162<xsl:template name="stylesheet.css">
163body {
164    font:normal 68% verdana,arial,helvetica;
165    color:#000000;
166}
167table tr td, table tr th {
168    font-size: 68%;
169}
170table.details tr th{
171    font-weight: bold;
172    text-align:left;
173    background:#a6caf0;
174}
175table.details tr td{
176    background:#eeeee0;
177}
178
179p {
180    line-height:1.5em;
181    margin-top:0.5em; margin-bottom:1.0em;
182}
183h1 {
184    margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
185}
186h2 {
187    margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
188}
189h3 {
190    margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
191}
192h4 {
193    margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
194}
195h5 {
196    margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
197}
198h6 {
199    margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
200}
201.Error {
202    font-weight:bold; color:red;
203}
204.Failure {
205    font-weight:bold; color:purple;
206}
207.Properties {
208  text-align:right;
209}
210</xsl:template>
211
212
213<!-- ======================================================================
214    This page is created for every testsuite class.
215    It prints a summary of the testsuite and detailed information about
216    testcase methods.
217     ====================================================================== -->
218<xsl:template match="testsuite" mode="class.details">
219    <xsl:variable name="package.name" select="@package"/>
220    <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>
221    <html>
222        <head>
223          <title>Unit Test Results: <xsl:value-of select="$class.name"/></title>
224            <xsl:call-template name="create.stylesheet.link">
225                <xsl:with-param name="package.name" select="$package.name"/>
226            </xsl:call-template>
227       <script type="text/javascript" language="JavaScript">
228        var TestCases = new Array();
229        var cur;
230        <xsl:apply-templates select="properties"/>
231       </script>
232       <script type="text/javascript" language="JavaScript"><![CDATA[
233        function displayProperties (name) {
234          var win = window.open('','JUnitSystemProperties','scrollbars=1,resizable=1');
235          var doc = win.document.open();
236          doc.write("<html><head><title>Properties of " + name + "</title>");
237          doc.write("<style type=\"text/css\">");
238          doc.write("body {font:normal 68% verdana,arial,helvetica; color:#000000; }");
239          doc.write("table tr td, table tr th { font-size: 68%; }");
240          doc.write("table.properties { border-collapse:collapse; border-left:solid 1 #cccccc; border-top:solid 1 #cccccc; padding:5px; }");
241          doc.write("table.properties th { text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#eeeeee; }");
242          doc.write("table.properties td { font:normal; text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#fffffff; }");
243          doc.write("h3 { margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica }");
244          doc.write("</style>");
245          doc.write("</head><body>");
246          doc.write("<h3>Properties of " + name + "</h3>");
247          doc.write("<div align=\"right\"><a href=\"javascript:window.close();\">Close</a></div>");
248          doc.write("<table class='properties'>");
249          doc.write("<tr><th>Name</th><th>Value</th></tr>");
250          for (prop in TestCases[name]) {
251            doc.write("<tr><th>" + prop + "</th><td>" + TestCases[name][prop] + "</td></tr>");
252          }
253          doc.write("</table>");
254          doc.write("</body></html>");
255          doc.close();
256          win.focus();
257        }
258      ]]> 
259      </script>
260        </head>
261        <body>
262            <xsl:call-template name="pageHeader"/> 
263            <h3>Class <xsl:value-of select="$class.name"/></h3>
264
265           
266            <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
267                <xsl:call-template name="testsuite.test.header"/>
268                <xsl:apply-templates select="." mode="print.test"/>
269            </table>
270   
271            <h2>Tests</h2>
272            <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
273        <xsl:call-template name="testcase.test.header"/>
274              <!--
275              test can even not be started at all (failure to load the class)
276              so report the error directly
277              -->
278                <xsl:if test="./error">
279                    <tr class="Error">
280                        <td colspan="4"><xsl:apply-templates select="./error"/></td>
281                    </tr>
282                </xsl:if>
283                <xsl:apply-templates select="./testcase" mode="print.test"/>
284            </table>
285           
286            <table width="95%" cellspacing="2" cellpadding="5" class="details">
287            <tr valign="top">
288            <th>Standard Output</th></tr>
289            <tr>
290            <td class="TableRowColor">
291            <pre>
292               <xsl:value-of select="./system-out"/>
293            </pre>
294            </td>
295            </tr>
296            </table>           
297
298            <table width="95%" cellspacing="2" cellpadding="5" class="details">
299            <tr valign="top">
300            <th>Standard Error</th></tr>
301            <tr>
302            <td class="TableRowColor">
303            <pre>
304               <xsl:value-of select="./system-err"/>
305            </pre>
306            </td>
307            </tr>
308            </table>           
309
310            <div class="Properties">
311                <a>
312                    <xsl:attribute name="href">javascript:displayProperties('<xsl:value-of select="@package"/>.<xsl:value-of select="@name"/>');</xsl:attribute>
313                    Properties &#187;
314                </a>
315            </div>
316        </body>
317    </html>
318</xsl:template>
319
320  <!--
321   Write properties into a JavaScript data structure.
322   This is based on the original idea by Erik Hatcher (ehatcher@apache.org)
323   -->
324  <xsl:template match="properties">
325    cur = TestCases['<xsl:value-of select="../@package"/>.<xsl:value-of select="../@name"/>'] = new Array();
326    <xsl:for-each select="property">
327    <xsl:sort select="@name"/>
328        cur['<xsl:value-of select="@name"/>'] = '<xsl:call-template name="JS-escape"><xsl:with-param name="string" select="@value"/></xsl:call-template>';
329    </xsl:for-each>
330  </xsl:template>
331
332
333<!-- ======================================================================
334    This page is created for every package.
335    It prints the name of all classes that belongs to this package.
336    @param name the package name to print classes.
337     ====================================================================== -->
338<!-- list of classes in a package -->
339<xsl:template name="classes.list">
340    <xsl:param name="name"/>
341    <html>
342        <head>
343            <title>Unit Test Classes: <xsl:value-of select="$name"/></title>
344            <xsl:call-template name="create.stylesheet.link">
345                <xsl:with-param name="package.name" select="$name"/>
346            </xsl:call-template>
347        </head>
348        <body>
349            <table width="100%">
350                <tr>
351                    <td nowrap="nowrap">
352                        <h2><a href="package-summary.html" target="classFrame"><xsl:value-of select="$name"/></a></h2>
353                    </td>
354                </tr>
355            </table>
356   
357            <h2>Classes</h2>
358            <table width="100%">
359                <xsl:for-each select="/testsuites/testsuite[./@package = $name]">
360                    <xsl:sort select="@name"/>
361                    <tr>
362                        <td nowrap="nowrap">
363                            <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a>
364                        </td>
365                    </tr>
366                </xsl:for-each>
367            </table>
368        </body>
369    </html>
370</xsl:template>
371
372
373<!--
374    Creates an all-classes.html file that contains a link to all package-summary.html
375    on each class.
376-->
377<xsl:template match="testsuites" mode="all.classes">
378    <html>
379        <head>
380            <title>All Unit Test Classes</title>
381            <xsl:call-template name="create.stylesheet.link">
382                <xsl:with-param name="package.name"/>
383            </xsl:call-template>
384        </head>
385        <body>
386            <h2>Classes</h2>
387            <table width="100%">
388                <xsl:apply-templates select="testsuite" mode="all.classes">
389                    <xsl:sort select="@name"/>
390                </xsl:apply-templates>
391            </table>
392        </body>
393    </html>
394</xsl:template>
395
396<xsl:template match="testsuite" mode="all.classes">
397    <xsl:variable name="package.name" select="@package"/>
398    <tr>
399        <td nowrap="nowrap">
400            <a target="classFrame">
401                <xsl:attribute name="href">
402                    <xsl:if test="not($package.name='')">
403                        <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text>
404                    </xsl:if><xsl:value-of select="@name"/><xsl:text>.html</xsl:text>
405                </xsl:attribute>
406                <xsl:value-of select="@name"/>
407            </a>
408        </td>
409    </tr>
410</xsl:template>
411
412
413<!--
414    Creates an html file that contains a link to all package-summary.html files on
415    each package existing on testsuites.
416    @bug there will be a problem here, I don't know yet how to handle unnamed package :(
417-->
418<xsl:template match="testsuites" mode="all.packages">
419    <html>
420        <head>
421            <title>All Unit Test Packages</title>
422            <xsl:call-template name="create.stylesheet.link">
423                <xsl:with-param name="package.name"/>
424            </xsl:call-template>
425        </head>
426        <body>
427            <h2><a href="overview-summary.html" target="classFrame">Home</a></h2>
428            <h2>Packages</h2>
429            <table width="100%">
430                <xsl:apply-templates select="testsuite[not(./@package = preceding-sibling::testsuite/@package)]" mode="all.packages">
431                    <xsl:sort select="@package"/>
432                </xsl:apply-templates>
433            </table>
434        </body>
435    </html>
436</xsl:template>
437
438<xsl:template match="testsuite" mode="all.packages">
439    <tr>
440        <td nowrap="nowrap">
441            <a href="{translate(@package,'.','/')}/package-summary.html" target="classFrame">
442                <xsl:value-of select="@package"/>
443            </a>
444        </td>
445    </tr>
446</xsl:template>
447
448
449<xsl:template match="testsuites" mode="overview.packages">
450    <html>
451        <head>
452            <title>Unit Test Results: Summary</title>
453            <xsl:call-template name="create.stylesheet.link">
454                <xsl:with-param name="package.name"/>
455            </xsl:call-template>
456        </head>
457        <body>
458        <xsl:attribute name="onload">open('allclasses-frame.html','classListFrame')</xsl:attribute>
459        <xsl:call-template name="pageHeader"/>
460        <h2>Summary</h2>
461        <xsl:variable name="testCount" select="sum(testsuite/@tests)"/>
462        <xsl:variable name="errorCount" select="sum(testsuite/@errors)"/>
463        <xsl:variable name="failureCount" select="sum(testsuite/@failures)"/>
464        <xsl:variable name="timeCount" select="sum(testsuite/@time)"/>
465        <xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/>
466        <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
467        <tr valign="top">
468            <th>Tests</th>
469            <th>Failures</th>
470            <th>Errors</th>
471            <th>Success rate</th>
472            <th>Time</th>
473        </tr>
474        <tr valign="top">
475            <xsl:attribute name="class">
476                <xsl:choose>
477                    <xsl:when test="$errorCount &gt; 0">Error</xsl:when>
478                    <xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
479                    <xsl:otherwise>Pass</xsl:otherwise>
480                </xsl:choose>
481            </xsl:attribute>
482            <td><xsl:value-of select="$testCount"/></td>
483            <td><xsl:value-of select="$failureCount"/></td>
484            <td><xsl:value-of select="$errorCount"/></td>
485            <td>
486                <xsl:call-template name="display-percent">
487                    <xsl:with-param name="value" select="$successRate"/>
488                </xsl:call-template>
489            </td>
490            <td>
491                <xsl:call-template name="display-time">
492                    <xsl:with-param name="value" select="$timeCount"/>
493                </xsl:call-template>
494            </td>
495
496        </tr>
497        </table>
498        <table border="0" width="95%">
499        <tr>
500        <td style="text-align: justify;">
501        Note: <em>failures</em> are anticipated and checked for with assertions while <em>errors</em> are unanticipated.
502        </td>
503        </tr>
504        </table>
505       
506        <h2>Packages</h2>
507        <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
508            <xsl:call-template name="testsuite.test.header"/>
509            <xsl:for-each select="testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
510                <xsl:sort select="@package" order="ascending"/>
511                <!-- get the node set containing all testsuites that have the same package -->
512                <xsl:variable name="insamepackage" select="/testsuites/testsuite[./@package = current()/@package]"/>
513                <tr valign="top">
514                    <!-- display a failure if there is any failure/error in the package -->
515                    <xsl:attribute name="class">
516                        <xsl:choose>
517                            <xsl:when test="sum($insamepackage/@errors) &gt; 0">Error</xsl:when>
518                            <xsl:when test="sum($insamepackage/@failures) &gt; 0">Failure</xsl:when>
519                            <xsl:otherwise>Pass</xsl:otherwise>
520                        </xsl:choose>
521                    </xsl:attribute>
522                    <td><a href="{translate(@package,'.','/')}/package-summary.html"><xsl:value-of select="@package"/></a></td>
523                    <td><xsl:value-of select="sum($insamepackage/@tests)"/></td>
524                    <td><xsl:value-of select="sum($insamepackage/@errors)"/></td>
525                    <td><xsl:value-of select="sum($insamepackage/@failures)"/></td>
526                    <td>
527                    <xsl:call-template name="display-time">
528                        <xsl:with-param name="value" select="sum($insamepackage/@time)"/>
529                    </xsl:call-template>
530                    </td>
531                </tr>
532            </xsl:for-each>
533        </table>
534        </body>
535        </html>
536</xsl:template>
537
538
539<xsl:template name="package.summary">
540    <xsl:param name="name"/>
541    <html>
542        <head>
543            <xsl:call-template name="create.stylesheet.link">
544                <xsl:with-param name="package.name" select="$name"/>
545            </xsl:call-template>
546        </head>
547        <body>
548            <xsl:attribute name="onload">open('package-frame.html','classListFrame')</xsl:attribute>
549            <xsl:call-template name="pageHeader"/>
550            <h3>Package <xsl:value-of select="$name"/></h3>
551           
552            <!--table border="0" cellpadding="5" cellspacing="2" width="95%">
553                <xsl:call-template name="class.metrics.header"/>
554                <xsl:apply-templates select="." mode="print.metrics"/>
555            </table-->
556           
557            <xsl:variable name="insamepackage" select="/testsuites/testsuite[./@package = $name]"/>
558            <xsl:if test="count($insamepackage) &gt; 0">
559                <h2>Classes</h2>
560                <p>
561                <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
562                    <xsl:call-template name="testsuite.test.header"/>
563                    <xsl:apply-templates select="$insamepackage" mode="print.test">
564                        <xsl:sort select="@name"/>
565                    </xsl:apply-templates>
566                </table>
567                </p>
568            </xsl:if>
569        </body>
570    </html>
571</xsl:template>
572
573
574<!--
575    transform string like a.b.c to ../../../
576    @param path the path to transform into a descending directory path
577-->
578<xsl:template name="path">
579    <xsl:param name="path"/>
580    <xsl:if test="contains($path,'.')">
581        <xsl:text>../</xsl:text>   
582        <xsl:call-template name="path">
583            <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param>
584        </xsl:call-template>   
585    </xsl:if>
586    <xsl:if test="not(contains($path,'.')) and not($path = '')">
587        <xsl:text>../</xsl:text>   
588    </xsl:if>
589</xsl:template>
590
591
592<!-- create the link to the stylesheet based on the package name -->
593<xsl:template name="create.stylesheet.link">
594    <xsl:param name="package.name"/>
595    <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>
596</xsl:template>
597
598
599<!-- Page HEADER -->
600<xsl:template name="pageHeader">
601    <h1>Unit Test Results</h1>
602    <table width="100%">
603    <tr>
604        <td align="left"></td>
605        <td align="right">Designed for use with <a href="http://www.junit.org/">JUnit</a> and <a href="http://jakarta.apache.org/">Ant</a>.</td>
606    </tr>
607    </table>
608    <hr size="1"/>
609</xsl:template>
610
611<!-- class header -->
612<xsl:template name="testsuite.test.header">
613    <tr valign="top">
614        <th width="80%">Name</th>
615        <th>Tests</th>
616        <th>Errors</th>
617        <th>Failures</th>
618        <th nowrap="nowrap">Time(s)</th>
619    </tr>
620</xsl:template>
621
622<!-- method header -->
623<xsl:template name="testcase.test.header">
624    <tr valign="top">
625        <th>Name</th>
626        <th>Status</th>
627        <th width="80%">Type</th>
628        <th nowrap="nowrap">Time(s)</th>
629    </tr>
630</xsl:template>
631
632
633<!-- class information -->
634<xsl:template match="testsuite" mode="print.test">
635    <tr valign="top">       
636        <xsl:attribute name="class">
637            <xsl:choose>
638                <xsl:when test="@errors[.&gt; 0]">Error</xsl:when>
639                <xsl:when test="@failures[.&gt; 0]">Failure</xsl:when>
640                <xsl:otherwise>Pass</xsl:otherwise>
641            </xsl:choose>
642        </xsl:attribute>
643        <td><a href="{@name}.html"><xsl:value-of select="@name"/></a></td>
644        <td><xsl:apply-templates select="@tests"/></td>
645        <td><xsl:apply-templates select="@errors"/></td>
646        <td><xsl:apply-templates select="@failures"/></td>
647        <td><xsl:call-template name="display-time">
648                <xsl:with-param name="value" select="@time"/>
649            </xsl:call-template>
650        </td>
651    </tr>
652</xsl:template>
653
654<xsl:template match="testcase" mode="print.test">
655    <tr valign="top">
656        <xsl:attribute name="class">
657            <xsl:choose>
658                <xsl:when test="error">Error</xsl:when>
659                <xsl:when test="failure">Failure</xsl:when>
660                <xsl:otherwise>TableRowColor</xsl:otherwise>
661            </xsl:choose>
662        </xsl:attribute>
663        <td><xsl:value-of select="@name"/></td>
664        <xsl:choose>
665            <xsl:when test="failure">
666                <td>Failure</td>
667                <td><xsl:apply-templates select="failure"/></td>
668            </xsl:when>
669            <xsl:when test="error">
670                <td>Error</td>
671                <td><xsl:apply-templates select="error"/></td>
672            </xsl:when>
673            <xsl:otherwise>
674                <td>Success</td>
675                <td></td>
676            </xsl:otherwise>
677        </xsl:choose>
678        <td>
679            <xsl:call-template name="display-time">
680                <xsl:with-param name="value" select="@time"/>
681            </xsl:call-template>
682        </td>
683    </tr>
684</xsl:template>
685
686
687<!-- Note : the below template error and failure are the same style
688            so just call the same style store in the toolkit template -->
689<xsl:template match="failure">
690    <xsl:call-template name="display-failures"/>
691</xsl:template>
692
693<xsl:template match="error">
694    <xsl:call-template name="display-failures"/>
695</xsl:template>
696
697<!-- Style for the error and failure in the testcase template -->
698<xsl:template name="display-failures">
699    <xsl:choose>
700        <xsl:when test="not(@message)">N/A</xsl:when>
701        <xsl:otherwise>
702            <xsl:value-of select="@message"/>
703        </xsl:otherwise>
704    </xsl:choose>
705    <!-- display the stacktrace -->
706    <br/><br/>
707    <code>
708        <xsl:call-template name="br-replace">
709            <xsl:with-param name="word" select="."/>
710        </xsl:call-template>
711    </code>
712    <!-- the latter is better but might be problematic for non-21" monitors... -->
713    <!--pre><xsl:value-of select="."/></pre-->
714</xsl:template>
715
716<xsl:template name="JS-escape">
717    <xsl:param name="string"/>
718    <xsl:choose>
719        <xsl:when test="contains($string,&quot;'&quot;)">
720            <xsl:value-of select="substring-before($string,&quot;'&quot;)"/>\&apos;<xsl:call-template name="JS-escape">
721                <xsl:with-param name="string" select="substring-after($string,&quot;'&quot;)"/>
722            </xsl:call-template>
723        </xsl:when> 
724        <xsl:when test="contains($string,'\')">
725            <xsl:value-of select="substring-before($string,'\')"/>\\<xsl:call-template name="JS-escape">
726                <xsl:with-param name="string" select="substring-after($string,'\')"/>
727            </xsl:call-template>
728        </xsl:when>
729        <xsl:otherwise>
730            <xsl:value-of select="$string"/>
731        </xsl:otherwise>
732    </xsl:choose>
733</xsl:template>
734
735
736<!--
737    template that will convert a carriage return into a br tag
738    @param word the text from which to convert CR to BR tag
739-->
740<xsl:template name="br-replace">
741    <xsl:param name="word"/>
742    <xsl:choose>
743        <xsl:when test="contains($word,'&#xA;')">
744            <xsl:value-of select="substring-before($word,'&#xA;')"/>
745            <br/>
746            <xsl:call-template name="br-replace">
747                <xsl:with-param name="word" select="substring-after($word,'&#xA;')"/>
748            </xsl:call-template>
749        </xsl:when>
750        <xsl:otherwise>
751            <xsl:value-of select="$word"/>
752        </xsl:otherwise>
753    </xsl:choose>
754</xsl:template>
755
756<xsl:template name="display-time">
757    <xsl:param name="value"/>
758    <xsl:value-of select="format-number($value,'0.000')"/>
759</xsl:template>
760
761<xsl:template name="display-percent">
762    <xsl:param name="value"/>
763    <xsl:value-of select="format-number($value,'0.00%')"/>
764</xsl:template>
765</xsl:stylesheet>
Note: See TracBrowser for help on using the browser.