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="org.apache.xalan.lib.Redirect"
4 extension-element-prefixes="redirect">
5 <xsl:output method="html" indent="yes"/>
6 <xsl:decimal-format decimal-separator="." grouping-separator="," />
8 Licensed to the Apache Software Foundation (ASF) under one or more
9 contributor license agreements. See the NOTICE file distributed with
10 this work for additional information regarding copyright ownership.
11 The ASF licenses this file to You under the Apache License, Version 2.0
12 (the "License"); you may not use this file except in compliance with
13 the License. You may obtain a copy of the License at
15 http://www.apache.org/licenses/LICENSE-2.0
17 Unless required by applicable law or agreed to in writing, software
18 distributed under the License is distributed on an "AS IS" BASIS,
19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 See the License for the specific language governing permissions and
21 limitations under the License.
26 Sample stylesheet to be used with JProbe 3.0 XML output.
28 It creates a set of HTML files a la javadoc where you can browse easily
29 through all packages and classes.
31 It is best used with JProbe Coverage Ant task that gives you the benefit
32 of a reference classpath so that you have the list of classes/methods
33 that are not used at all in a given classpath.
35 @author Stephane Bailliez <a href="mailto:sbailliez@apache.org"/>
39 <!-- default output directory is current directory -->
40 <xsl:param name="output.dir" select="'.'"/>
42 <!-- ======================================================================
44 ======================================================================= -->
45 <xsl:template match="/snapshot">
46 <!-- create the index.html -->
47 <redirect:write file="{$output.dir}/index.html">
48 <xsl:call-template name="index.html"/>
51 <!-- create the stylesheet.css -->
52 <redirect:write file="{$output.dir}/stylesheet.css">
53 <xsl:call-template name="stylesheet.css"/>
56 <!-- create the overview-packages.html at the root -->
57 <redirect:write file="{$output.dir}/overview-summary.html">
58 <xsl:apply-templates select="." mode="overview.packages"/>
61 <!-- create the all-packages.html at the root -->
62 <redirect:write file="{$output.dir}/overview-frame.html">
63 <xsl:apply-templates select="." mode="all.packages"/>
66 <!-- create the all-classes.html at the root -->
67 <redirect:write file="{$output.dir}/allclasses-frame.html">
68 <xsl:apply-templates select="." mode="all.classes"/>
71 <!-- process all packages -->
72 <xsl:apply-templates select="./package" mode="write"/>
75 <!-- =======================================================================
76 Frameset definition. Entry point for the report.
77 3 frames: packageListFrame, classListFrame, classFrame
78 ======================================================================= -->
79 <xsl:template name="index.html">
81 <head><title>Coverage Results.</title></head>
82 <frameset cols="20%,80%">
83 <frameset rows="30%,70%">
84 <frame src="overview-frame.html" name="packageListFrame"/>
85 <frame src="allclasses-frame.html" name="classListFrame"/>
87 <frame src="overview-summary.html" name="classFrame"/>
92 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.
98 <!-- =======================================================================
100 ======================================================================= -->
101 <!-- this is the stylesheet css to use for nearly everything -->
102 <xsl:template name="stylesheet.css">
110 font:normal 80% arial,helvetica,sanserif;
111 background-color:#FFFFFF;
133 table.log tr td, tr th {
146 text-decoration: none;
154 <!-- =======================================================================
155 List of all classes in all packages
156 This will be the first page in the classListFrame
157 ======================================================================= -->
158 <xsl:template match="snapshot" mode="all.classes">
161 <xsl:call-template name="create.stylesheet.link"/>
166 <xsl:for-each select="package/class">
167 <xsl:sort select="@name"/>
168 <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/>
169 <xsl:variable name="link">
170 <xsl:if test="not($package.name='')">
171 <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text>
172 </xsl:if><xsl:value-of select="@name"/><xsl:text>.html</xsl:text>
176 <a target="classFrame" href="{$link}"><xsl:value-of select="@name"/></a>
185 <!-- list of all packages -->
186 <xsl:template match="snapshot" mode="all.packages">
189 <xsl:call-template name="create.stylesheet.link"/>
192 <h2><a href="overview-summary.html" target="classFrame">Home</a></h2>
195 <xsl:for-each select="package">
196 <xsl:sort select="@name" order="ascending"/>
199 <a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame">
200 <xsl:value-of select="@name"/>
210 <!-- overview of statistics in packages -->
211 <xsl:template match="snapshot" mode="overview.packages">
214 <xsl:call-template name="create.stylesheet.link"/>
216 <body onload="open('allclasses-frame.html','classListFrame')">
217 <xsl:call-template name="pageHeader"/>
219 <table class="log" cellpadding="5" cellspacing="2" width="100%">
221 <!--th width="10%" nowrap="nowrap">Date</th>
222 <th width="10%" nowrap="nowrap">Elapsed time</th-->
223 <th width="10%" nowrap="nowrap">Reported Classes</th>
224 <th width="10%" nowrap="nowrap">Methods Hit</th>
225 <th width="10%" nowrap="nowrap">Lines Hit</th>
228 <!--td nowrap="nowrap"><xsl:value-of select="execution_log/@program_start"/></td>
229 <td><xsl:value-of select="format-number(execution_log/@elapsed_time div 1000,'0.0')"/>secs</td-->
230 <td><xsl:value-of select="count(package/class)"/></td>
231 <td><xsl:value-of select="format-number(cov.data/@hit_methods div cov.data/@total_methods,'0.0%')"/></td>
232 <td><xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/></td>
235 <table border="0" width="100%">
237 <td style="text-align: justify;">
238 To ensure accurate test runs on Java applications, developers need to know how much of
239 the code has been tested, and where to find any untested code. Coverage helps you
240 locate untested code, and measure precisely how much code has been exercised.
241 The result is a higher quality application in a shorter period of time.
248 <table class="log" cellpadding="5" cellspacing="2" width="100%">
249 <xsl:apply-templates select="package[1]" mode="stats.header"/>
250 <!-- display packages and sort them via their coverage rate -->
251 <xsl:for-each select="package">
252 <xsl:sort data-type="number" select="cov.data/@hit_lines div cov.data/@total_lines"/>
254 <xsl:call-template name="alternate-row"/>
255 <td><a href="{translate(@name,'.','/')}/package-summary.html"><xsl:value-of select="@name"/></a></td>
256 <td><xsl:value-of select="format-number(cov.data/@hit_methods div cov.data/@total_methods,'0.0%')"/></td>
257 <td><xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/></td>
261 <xsl:call-template name="pageFooter"/>
267 detailed info for a package. It will output the list of classes
268 , the summary page, and the info for each class
270 <xsl:template match="package" mode="write">
271 <xsl:variable name="package.dir">
272 <xsl:if test="not(@name = '')"><xsl:value-of select="translate(@name,'.','/')"/></xsl:if>
273 <xsl:if test="@name = ''">.</xsl:if>
276 <!-- create a classes-list.html in the package directory -->
277 <redirect:write file="{$output.dir}/{$package.dir}/package-frame.html">
278 <xsl:apply-templates select="." mode="classes.list"/>
281 <!-- create a package-summary.html in the package directory -->
282 <redirect:write file="{$output.dir}/{$package.dir}/package-summary.html">
283 <xsl:apply-templates select="." mode="package.summary"/>
286 <!-- for each class, creates a @name.html -->
287 <xsl:for-each select="class">
288 <redirect:write file="{$output.dir}/{$package.dir}/{@name}.html">
289 <xsl:apply-templates select="." mode="class.details"/>
294 <!-- list of classes in a package -->
295 <xsl:template match="package" mode="classes.list">
298 <xsl:call-template name="create.stylesheet.link">
299 <xsl:with-param name="package.name" select="@name"/>
306 <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="@name"/></a></H2>
313 <xsl:for-each select="class">
314 <xsl:sort select="@name"/>
317 <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a>
326 <!-- summary of a package -->
327 <xsl:template match="package" mode="package.summary">
330 <xsl:call-template name="create.stylesheet.link">
331 <xsl:with-param name="package.name" select="@name"/>
334 <!-- when loading this package, it will open the classes into the frame -->
335 <BODY onload="open('package-frame.html','classListFrame')">
336 <xsl:call-template name="pageHeader"/>
337 <h3>Package <xsl:value-of select="@name"/></h3>
338 <table class="log" cellpadding="5" cellspacing="2" width="100%">
339 <xsl:apply-templates select="." mode="stats.header"/>
340 <xsl:apply-templates select="." mode="stats"/>
343 <xsl:if test="count(class) > 0">
345 <table class="log" cellpadding="5" cellspacing="2" width="100%">
346 <xsl:apply-templates select="." mode="stats.header"/>
347 <xsl:apply-templates select="class" mode="stats">
348 <xsl:sort data-type="number" select="cov.data/@hit_lines div cov.data/@total_lines"/>
349 </xsl:apply-templates>
352 <xsl:call-template name="pageFooter"/>
357 <!-- details of a class -->
358 <xsl:template match="class" mode="class.details">
359 <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/>
362 <xsl:call-template name="create.stylesheet.link">
363 <xsl:with-param name="package.name" select="$package.name"/>
367 <xsl:call-template name="pageHeader"/>
368 <H3>Class <xsl:if test="not($package.name = '')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></H3>
370 <!-- class summary -->
371 <table class="log" cellpadding="5" cellspacing="2" width="100%">
372 <xsl:apply-templates select="." mode="stats.header"/>
373 <xsl:apply-templates select="." mode="stats"/>
376 <!-- details of methods -->
378 <table class="log" cellpadding="5" cellspacing="2" width="100%">
379 <xsl:apply-templates select="method[1]" mode="stats.header"/>
380 <xsl:apply-templates select="method" mode="stats">
381 <xsl:sort data-type="number" select="cov.data/@hit_lines div cov.data/@total_lines"/>
382 </xsl:apply-templates>
384 <xsl:call-template name="pageFooter"/>
391 <xsl:template name="pageHeader">
392 <!-- jakarta logo -->
393 <table border="0" cellpadding="0" cellspacing="0" width="100%">
395 <td class="bannercell" rowspan="2">
396 <a href="http://jakarta.apache.org/">
397 <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
400 <td style="text-align:right"><h2>Source Code Coverage</h2></td>
403 <td style="text-align:right">Designed for use with <a href='http://www.sitraka.com/jprobe'>Sitraka JProbe</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
410 <xsl:template name="pageFooter">
414 <xsl:template name="table.header">
416 <th width="80%">Name</th>
417 <th width="10%" nowrap="nowrap">Methods Hit</th>
418 <th width="10%" nowrap="nowrap">Lines Hit</th>
422 <xsl:template match="method" mode="stats.header">
424 <th width="90%">Name</th>
425 <th width="10%" nowrap="nowrap">Lines Hit</th>
428 <xsl:template match="method" mode="stats">
430 <xsl:call-template name="alternate-row"/>
431 <td><xsl:value-of select="@name"/></td>
433 <xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/>
438 <xsl:template match="package|class" mode="stats.header">
440 <th width="80%">Name</th>
441 <th width="10%" nowrap="nowrap">Methods Hit</th>
442 <th width="10%" nowrap="nowrap">Lines Hit</th>
445 <xsl:template match="package|class" mode="stats">
447 <xsl:call-template name="alternate-row"/>
448 <td><xsl:value-of select="@name"/></td>
449 <td><xsl:value-of select="format-number(cov.data/@hit_methods div cov.data/@total_methods,'0.0%')"/></td>
450 <td><xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/></td>
455 transform string like a.b.c to ../../../
456 @param path the path to transform into a descending directory path
458 <xsl:template name="path">
459 <xsl:param name="path"/>
460 <xsl:if test="contains($path,'.')">
461 <xsl:text>../</xsl:text>
462 <xsl:call-template name="path">
463 <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param>
466 <xsl:if test="not(contains($path,'.')) and not($path = '')">
467 <xsl:text>../</xsl:text>
472 <!-- create the link to the stylesheet based on the package name -->
473 <xsl:template name="create.stylesheet.link">
474 <xsl:param name="package.name"/>
475 <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>
478 <!-- alternated row style -->
479 <xsl:template name="alternate-row">
480 <xsl:attribute name="class">
481 <xsl:if test="position() mod 2 = 1">a</xsl:if>
482 <xsl:if test="position() mod 2 = 0">b</xsl:if>