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