OSDN Git Service

DBFlute-0.9.3に更新
[ea2ddl/ea2ddl.git] / ea2ddl-gen / dbflute-0.9.3 / ant / etc / coverage-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="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="," />
7 <!--
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
14
15        http://www.apache.org/licenses/LICENSE-2.0
16
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.
22 -->
23
24 <!--
25
26  Sample stylesheet to be used with JProbe 3.0 XML output.
27
28  It creates a set of HTML files a la javadoc where you can browse easily
29  through all packages and classes.
30
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.
34
35  @author Stephane Bailliez <a href="mailto:sbailliez@apache.org"/>
36
37 -->
38
39 <!-- default output directory is current directory -->
40 <xsl:param name="output.dir" select="'.'"/>
41
42 <!-- ======================================================================
43     Root element
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"/>
49     </redirect:write>
50
51     <!-- create the stylesheet.css -->
52     <redirect:write file="{$output.dir}/stylesheet.css">
53         <xsl:call-template name="stylesheet.css"/>
54     </redirect:write>
55
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"/>
59     </redirect:write>
60
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"/>
64     </redirect:write>
65
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"/>
69     </redirect:write>
70
71     <!-- process all packages -->
72     <xsl:apply-templates select="./package" mode="write"/>
73 </xsl:template>
74
75 <!-- =======================================================================
76     Frameset definition. Entry point for the report.
77     3 frames: packageListFrame, classListFrame, classFrame
78     ======================================================================= -->
79 <xsl:template name="index.html">
80 <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"/>
86         </frameset>
87         <frame src="overview-summary.html" name="classFrame"/>
88     </frameset>
89     <noframes>
90         <h2>Frame Alert</h2>
91         <p>
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.
93         </p>
94     </noframes>
95 </html>
96 </xsl:template>
97
98 <!-- =======================================================================
99     Stylesheet CSS used
100     ======================================================================= -->
101 <!-- this is the stylesheet css to use for nearly everything -->
102 <xsl:template name="stylesheet.css">
103     .bannercell {
104       border: 0px;
105       padding: 0px;
106     }
107     body {
108       margin-left: 10;
109       margin-right: 10;
110       font:normal 80% arial,helvetica,sanserif;
111       background-color:#FFFFFF;
112       color:#000000;
113     }
114     .a td {
115       background: #efefef;
116     }
117     .b td {
118       background: #fff;
119     }
120     th, td {
121       text-align: left;
122       vertical-align: top;
123     }
124     th {
125       font-weight:bold;
126       background: #ccc;
127       color: black;
128     }
129     table, th, td {
130       font-size:100%;
131       border: none
132     }
133     table.log tr td, tr th {
134
135     }
136     h2 {
137       font-weight:bold;
138       font-size:140%;
139       margin-bottom: 5;
140     }
141     h3 {
142       font-size:100%;
143       font-weight:bold;
144       background: #525D76;
145       color: white;
146       text-decoration: none;
147       padding: 5px;
148       margin-right: 2px;
149       margin-left: 2px;
150       margin-bottom: 0;
151     }
152 </xsl:template>
153
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">
159     <html>
160         <head>
161             <xsl:call-template name="create.stylesheet.link"/>
162         </head>
163         <body>
164             <h2>Classes</h2>
165             <table width="100%">
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>
173                     </xsl:variable>
174                     <tr>
175                         <td nowrap="nowrap">
176                             <a target="classFrame" href="{$link}"><xsl:value-of select="@name"/></a>
177                         </td>
178                     </tr>
179                 </xsl:for-each>
180             </table>
181         </body>
182     </html>
183 </xsl:template>
184
185 <!-- list of all packages -->
186 <xsl:template match="snapshot" mode="all.packages">
187     <html>
188         <head>
189             <xsl:call-template name="create.stylesheet.link"/>
190         </head>
191         <body>
192             <h2><a href="overview-summary.html" target="classFrame">Home</a></h2>
193             <h2>Packages</h2>
194             <table width="100%">
195                 <xsl:for-each select="package">
196                     <xsl:sort select="@name" order="ascending"/>
197                     <tr>
198                         <td nowrap="nowrap">
199                             <a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame">
200                                 <xsl:value-of select="@name"/>
201                             </a>
202                         </td>
203                     </tr>
204                 </xsl:for-each>
205             </table>
206         </body>
207     </html>
208 </xsl:template>
209
210 <!-- overview of statistics in packages -->
211 <xsl:template match="snapshot" mode="overview.packages">
212     <html>
213         <head>
214             <xsl:call-template name="create.stylesheet.link"/>
215         </head>
216         <body onload="open('allclasses-frame.html','classListFrame')">
217         <xsl:call-template name="pageHeader"/>
218         <h3>Summary</h3>
219         <table class="log" cellpadding="5" cellspacing="2" width="100%">
220             <tr>
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>
226             </tr>
227             <tr class="a">
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>
233             </tr>
234         </table>
235         <table border="0" width="100%">
236         <tr>
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.
242         <p/>
243         </td>
244         </tr>
245         </table>
246
247         <h3>Packages</h3>
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"/>
253                 <tr>
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>
258                 </tr>
259             </xsl:for-each>
260         </table>
261         <xsl:call-template name="pageFooter"/>
262         </body>
263         </html>
264 </xsl:template>
265
266 <!--
267  detailed info for a package. It will output the list of classes
268 , the summary page, and the info for each class
269 -->
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>
274     </xsl:variable>
275
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"/>
279     </redirect:write>
280
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"/>
284     </redirect:write>
285
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"/>
290         </redirect:write>
291     </xsl:for-each>
292 </xsl:template>
293
294 <!-- list of classes in a package -->
295 <xsl:template match="package" mode="classes.list">
296     <html>
297         <HEAD>
298             <xsl:call-template name="create.stylesheet.link">
299                 <xsl:with-param name="package.name" select="@name"/>
300             </xsl:call-template>
301         </HEAD>
302         <BODY>
303             <table width="100%">
304                 <tr>
305                     <td nowrap="nowrap">
306                         <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="@name"/></a></H2>
307                     </td>
308                 </tr>
309             </table>
310
311             <H2>Classes</H2>
312             <TABLE WIDTH="100%">
313                 <xsl:for-each select="class">
314                     <xsl:sort select="@name"/>
315                     <tr>
316                         <td nowrap="nowrap">
317                             <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a>
318                         </td>
319                     </tr>
320                 </xsl:for-each>
321             </TABLE>
322         </BODY>
323     </html>
324 </xsl:template>
325
326 <!-- summary of a package -->
327 <xsl:template match="package" mode="package.summary">
328     <HTML>
329         <HEAD>
330             <xsl:call-template name="create.stylesheet.link">
331                 <xsl:with-param name="package.name" select="@name"/>
332             </xsl:call-template>
333         </HEAD>
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"/>
341             </table>
342
343             <xsl:if test="count(class) &gt; 0">
344                 <H3>Classes</H3>
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>
350                 </table>
351             </xsl:if>
352             <xsl:call-template name="pageFooter"/>
353         </BODY>
354     </HTML>
355 </xsl:template>
356
357 <!-- details of a class -->
358 <xsl:template match="class" mode="class.details">
359     <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/>
360     <HTML>
361         <HEAD>
362             <xsl:call-template name="create.stylesheet.link">
363                 <xsl:with-param name="package.name" select="$package.name"/>
364             </xsl:call-template>
365         </HEAD>
366         <BODY>
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>
369
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"/>
374             </table>
375
376             <!-- details of methods -->
377             <H3>Methods</H3>
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>
383             </table>
384             <xsl:call-template name="pageFooter"/>
385         </BODY>
386     </HTML>
387
388 </xsl:template>
389
390 <!-- Page Header -->
391 <xsl:template name="pageHeader">
392   <!-- jakarta logo -->
393   <table border="0" cellpadding="0" cellspacing="0" width="100%">
394   <tr>
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"/>
398       </a>
399     </td>
400         <td style="text-align:right"><h2>Source Code Coverage</h2></td>
401         </tr>
402         <tr>
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>
404         </tr>
405   </table>
406     <hr size="1"/>
407 </xsl:template>
408
409 <!-- Page Footer -->
410 <xsl:template name="pageFooter">
411 </xsl:template>
412
413
414 <xsl:template name="table.header">
415     <tr>
416         <th width="80%">Name</th>
417         <th width="10%" nowrap="nowrap">Methods Hit</th>
418         <th width="10%" nowrap="nowrap">Lines Hit</th>
419     </tr>
420 </xsl:template>
421
422 <xsl:template match="method" mode="stats.header">
423     <tr>
424         <th width="90%">Name</th>
425         <th width="10%" nowrap="nowrap">Lines Hit</th>
426     </tr>
427 </xsl:template>
428 <xsl:template match="method" mode="stats">
429     <tr>
430       <xsl:call-template name="alternate-row"/>
431         <td><xsl:value-of select="@name"/></td>
432         <td>
433         <xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/>
434         </td>
435     </tr>
436 </xsl:template>
437
438 <xsl:template match="package|class" mode="stats.header">
439     <tr>
440         <th width="80%">Name</th>
441         <th width="10%" nowrap="nowrap">Methods Hit</th>
442         <th width="10%" nowrap="nowrap">Lines Hit</th>
443     </tr>
444 </xsl:template>
445 <xsl:template match="package|class" mode="stats">
446     <tr>
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>
451     </tr>
452 </xsl:template>
453
454 <!--
455     transform string like a.b.c to ../../../
456     @param path the path to transform into a descending directory path
457 -->
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>
464         </xsl:call-template>
465     </xsl:if>
466     <xsl:if test="not(contains($path,'.')) and not($path = '')">
467         <xsl:text>../</xsl:text>
468     </xsl:if>
469 </xsl:template>
470
471
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>
476 </xsl:template>
477
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>
483 </xsl:attribute>
484 </xsl:template>
485
486 </xsl:stylesheet>
487
488