You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

coverage-frames.xsl 18 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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.xslt.extensions.Redirect"
  4. extension-element-prefixes="redirect">
  5. <xsl:output method="html" indent="yes"/>
  6. <xsl:decimal-format decimal-separator="." grouping-separator="," />
  7. <!--
  8. The Apache Software License, Version 1.1
  9. Copyright (c) 2001-2002 The Apache Software Foundation. All rights
  10. reserved.
  11. Redistribution and use in source and binary forms, with or without
  12. modification, are permitted provided that the following conditions
  13. are met:
  14. 1. Redistributions of source code must retain the above copyright
  15. notice, this list of conditions and the following disclaimer.
  16. 2. Redistributions in binary form must reproduce the above copyright
  17. notice, this list of conditions and the following disclaimer in
  18. the documentation and/or other materials provided with the
  19. distribution.
  20. 3. The end-user documentation included with the redistribution, if
  21. any, must include the following acknowlegement:
  22. "This product includes software developed by the
  23. Apache Software Foundation (http://www.apache.org/)."
  24. Alternately, this acknowlegement may appear in the software itself,
  25. if and wherever such third-party acknowlegements normally appear.
  26. 4. The names "The Jakarta Project", "Ant", and "Apache Software
  27. Foundation" must not be used to endorse or promote products derived
  28. from this software without prior written permission. For written
  29. permission, please contact apache@apache.org.
  30. 5. Products derived from this software may not be called "Apache"
  31. nor may "Apache" appear in their names without prior written
  32. permission of the Apache Group.
  33. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  34. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  35. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  36. DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  37. ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  38. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  39. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  40. USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  41. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  42. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  43. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  44. SUCH DAMAGE.
  45. ====================================================================
  46. This software consists of voluntary contributions made by many
  47. individuals on behalf of the Apache Software Foundation. For more
  48. information on the Apache Software Foundation, please see
  49. <http://www.apache.org/>.
  50. -->
  51. <!--
  52. Sample stylesheet to be used with JProbe 3.0 XML output.
  53. It creates a set of HTML files a la javadoc where you can browse easily
  54. through all packages and classes.
  55. It is best used with JProbe Coverage Ant task that gives you the benefit
  56. of a reference classpath so that you have the list of classes/methods
  57. that are not used at all in a given classpath.
  58. @author Stephane Bailliez <a href="mailto:sbailliez@apache.org"/>
  59. -->
  60. <!-- default output directory is current directory -->
  61. <xsl:param name="output.dir" select="'.'"/>
  62. <!-- ======================================================================
  63. Root element
  64. ======================================================================= -->
  65. <xsl:template match="/snapshot">
  66. <!-- create the index.html -->
  67. <redirect:write file="{$output.dir}/index.html">
  68. <xsl:call-template name="index.html"/>
  69. </redirect:write>
  70. <!-- create the stylesheet.css -->
  71. <redirect:write file="{$output.dir}/stylesheet.css">
  72. <xsl:call-template name="stylesheet.css"/>
  73. </redirect:write>
  74. <!-- create the overview-packages.html at the root -->
  75. <redirect:write file="{$output.dir}/overview-summary.html">
  76. <xsl:apply-templates select="." mode="overview.packages"/>
  77. </redirect:write>
  78. <!-- create the all-packages.html at the root -->
  79. <redirect:write file="{$output.dir}/overview-frame.html">
  80. <xsl:apply-templates select="." mode="all.packages"/>
  81. </redirect:write>
  82. <!-- create the all-classes.html at the root -->
  83. <redirect:write file="{$output.dir}/allclasses-frame.html">
  84. <xsl:apply-templates select="." mode="all.classes"/>
  85. </redirect:write>
  86. <!-- process all packages -->
  87. <xsl:apply-templates select="./package" mode="write"/>
  88. </xsl:template>
  89. <!-- =======================================================================
  90. Frameset definition. Entry point for the report.
  91. 3 frames: packageListFrame, classListFrame, classFrame
  92. ======================================================================= -->
  93. <xsl:template name="index.html">
  94. <html>
  95. <head><title>Coverage Results.</title></head>
  96. <frameset cols="20%,80%">
  97. <frameset rows="30%,70%">
  98. <frame src="overview-frame.html" name="packageListFrame"/>
  99. <frame src="allclasses-frame.html" name="classListFrame"/>
  100. </frameset>
  101. <frame src="overview-summary.html" name="classFrame"/>
  102. </frameset>
  103. <noframes>
  104. <h2>Frame Alert</h2>
  105. <p>
  106. 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.
  107. </p>
  108. </noframes>
  109. </html>
  110. </xsl:template>
  111. <!-- =======================================================================
  112. Stylesheet CSS used
  113. ======================================================================= -->
  114. <!-- this is the stylesheet css to use for nearly everything -->
  115. <xsl:template name="stylesheet.css">
  116. .bannercell {
  117. border: 0px;
  118. padding: 0px;
  119. }
  120. body {
  121. margin-left: 10;
  122. margin-right: 10;
  123. font:normal 80% arial,helvetica,sanserif;
  124. background-color:#FFFFFF;
  125. color:#000000;
  126. }
  127. .a td {
  128. background: #efefef;
  129. }
  130. .b td {
  131. background: #fff;
  132. }
  133. th, td {
  134. text-align: left;
  135. vertical-align: top;
  136. }
  137. th {
  138. font-weight:bold;
  139. background: #ccc;
  140. color: black;
  141. }
  142. table, th, td {
  143. font-size:100%;
  144. border: none
  145. }
  146. table.log tr td, tr th {
  147. }
  148. h2 {
  149. font-weight:bold;
  150. font-size:140%;
  151. margin-bottom: 5;
  152. }
  153. h3 {
  154. font-size:100%;
  155. font-weight:bold;
  156. background: #525D76;
  157. color: white;
  158. text-decoration: none;
  159. padding: 5px;
  160. margin-right: 2px;
  161. margin-left: 2px;
  162. margin-bottom: 0;
  163. }
  164. </xsl:template>
  165. <!-- =======================================================================
  166. List of all classes in all packages
  167. This will be the first page in the classListFrame
  168. ======================================================================= -->
  169. <xsl:template match="snapshot" mode="all.classes">
  170. <html>
  171. <head>
  172. <xsl:call-template name="create.stylesheet.link"/>
  173. </head>
  174. <body>
  175. <h2>Classes</h2>
  176. <table width="100%">
  177. <xsl:for-each select="package/class">
  178. <xsl:sort select="@name"/>
  179. <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/>
  180. <xsl:variable name="link">
  181. <xsl:if test="not($package.name='')">
  182. <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text>
  183. </xsl:if><xsl:value-of select="@name"/><xsl:text>.html</xsl:text>
  184. </xsl:variable>
  185. <tr>
  186. <td nowrap="nowrap">
  187. <a target="classFrame" href="{$link}"><xsl:value-of select="@name"/></a>
  188. </td>
  189. </tr>
  190. </xsl:for-each>
  191. </table>
  192. </body>
  193. </html>
  194. </xsl:template>
  195. <!-- list of all packages -->
  196. <xsl:template match="snapshot" mode="all.packages">
  197. <html>
  198. <head>
  199. <xsl:call-template name="create.stylesheet.link"/>
  200. </head>
  201. <body>
  202. <h2><a href="overview-summary.html" target="classFrame">Home</a></h2>
  203. <h2>Packages</h2>
  204. <table width="100%">
  205. <xsl:for-each select="package">
  206. <xsl:sort select="@name" order="ascending"/>
  207. <tr>
  208. <td nowrap="nowrap">
  209. <a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame">
  210. <xsl:value-of select="@name"/>
  211. </a>
  212. </td>
  213. </tr>
  214. </xsl:for-each>
  215. </table>
  216. </body>
  217. </html>
  218. </xsl:template>
  219. <!-- overview of statistics in packages -->
  220. <xsl:template match="snapshot" mode="overview.packages">
  221. <html>
  222. <head>
  223. <xsl:call-template name="create.stylesheet.link"/>
  224. </head>
  225. <body onload="open('allclasses-frame.html','classListFrame')">
  226. <xsl:call-template name="pageHeader"/>
  227. <h3>Summary</h3>
  228. <table class="log" cellpadding="5" cellspacing="2" width="100%">
  229. <tr>
  230. <!--th width="10%" nowrap="nowrap">Date</th>
  231. <th width="10%" nowrap="nowrap">Elapsed time</th-->
  232. <th width="10%" nowrap="nowrap">Reported Classes</th>
  233. <th width="10%" nowrap="nowrap">Methods Hit</th>
  234. <th width="10%" nowrap="nowrap">Lines Hit</th>
  235. </tr>
  236. <tr class="a">
  237. <!--td nowrap="nowrap"><xsl:value-of select="execution_log/@program_start"/></td>
  238. <td><xsl:value-of select="format-number(execution_log/@elapsed_time div 1000,'0.0')"/>secs</td-->
  239. <td><xsl:value-of select="count(package/class)"/></td>
  240. <td><xsl:value-of select="format-number(cov.data/@hit_methods div cov.data/@total_methods,'0.0%')"/></td>
  241. <td><xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/></td>
  242. </tr>
  243. </table>
  244. <table border="0" width="100%">
  245. <tr>
  246. <td style="text-align: justify;">
  247. To ensure accurate test runs on Java applications, developers need to know how much of
  248. the code has been tested, and where to find any untested code. Coverage helps you
  249. locate untested code, and measure precisely how much code has been exercised.
  250. The result is a higher quality application in a shorter period of time.
  251. <p/>
  252. </td>
  253. </tr>
  254. </table>
  255. <h3>Packages</h3>
  256. <table class="log" cellpadding="5" cellspacing="2" width="100%">
  257. <xsl:apply-templates select="package[1]" mode="stats.header"/>
  258. <!-- display packages and sort them via their coverage rate -->
  259. <xsl:for-each select="package">
  260. <xsl:sort data-type="number" select="cov.data/@hit_lines div cov.data/@total_lines"/>
  261. <tr>
  262. <xsl:call-template name="alternate-row"/>
  263. <td><a href="{translate(@name,'.','/')}/package-summary.html"><xsl:value-of select="@name"/></a></td>
  264. <td><xsl:value-of select="format-number(cov.data/@hit_methods div cov.data/@total_methods,'0.0%')"/></td>
  265. <td><xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/></td>
  266. </tr>
  267. </xsl:for-each>
  268. </table>
  269. <xsl:call-template name="pageFooter"/>
  270. </body>
  271. </html>
  272. </xsl:template>
  273. <!--
  274. detailed info for a package. It will output the list of classes
  275. , the summary page, and the info for each class
  276. -->
  277. <xsl:template match="package" mode="write">
  278. <xsl:variable name="package.dir">
  279. <xsl:if test="not(@name = '')"><xsl:value-of select="translate(@name,'.','/')"/></xsl:if>
  280. <xsl:if test="@name = ''">.</xsl:if>
  281. </xsl:variable>
  282. <!-- create a classes-list.html in the package directory -->
  283. <redirect:write file="{$output.dir}/{$package.dir}/package-frame.html">
  284. <xsl:apply-templates select="." mode="classes.list"/>
  285. </redirect:write>
  286. <!-- create a package-summary.html in the package directory -->
  287. <redirect:write file="{$output.dir}/{$package.dir}/package-summary.html">
  288. <xsl:apply-templates select="." mode="package.summary"/>
  289. </redirect:write>
  290. <!-- for each class, creates a @name.html -->
  291. <xsl:for-each select="class">
  292. <redirect:write file="{$output.dir}/{$package.dir}/{@name}.html">
  293. <xsl:apply-templates select="." mode="class.details"/>
  294. </redirect:write>
  295. </xsl:for-each>
  296. </xsl:template>
  297. <!-- list of classes in a package -->
  298. <xsl:template match="package" mode="classes.list">
  299. <html>
  300. <HEAD>
  301. <xsl:call-template name="create.stylesheet.link">
  302. <xsl:with-param name="package.name" select="@name"/>
  303. </xsl:call-template>
  304. </HEAD>
  305. <BODY>
  306. <table width="100%">
  307. <tr>
  308. <td nowrap="nowrap">
  309. <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="@name"/></a></H2>
  310. </td>
  311. </tr>
  312. </table>
  313. <H2>Classes</H2>
  314. <TABLE WIDTH="100%">
  315. <xsl:for-each select="class">
  316. <xsl:sort select="@name"/>
  317. <tr>
  318. <td nowrap="nowrap">
  319. <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a>
  320. </td>
  321. </tr>
  322. </xsl:for-each>
  323. </TABLE>
  324. </BODY>
  325. </html>
  326. </xsl:template>
  327. <!-- summary of a package -->
  328. <xsl:template match="package" mode="package.summary">
  329. <HTML>
  330. <HEAD>
  331. <xsl:call-template name="create.stylesheet.link">
  332. <xsl:with-param name="package.name" select="@name"/>
  333. </xsl:call-template>
  334. </HEAD>
  335. <!-- when loading this package, it will open the classes into the frame -->
  336. <BODY onload="open('package-frame.html','classListFrame')">
  337. <xsl:call-template name="pageHeader"/>
  338. <h3>Package <xsl:value-of select="@name"/></h3>
  339. <table class="log" cellpadding="5" cellspacing="2" width="100%">
  340. <xsl:apply-templates select="." mode="stats.header"/>
  341. <xsl:apply-templates select="." mode="stats"/>
  342. </table>
  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. <!-- details of a class -->
  357. <xsl:template match="class" mode="class.details">
  358. <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/>
  359. <HTML>
  360. <HEAD>
  361. <xsl:call-template name="create.stylesheet.link">
  362. <xsl:with-param name="package.name" select="$package.name"/>
  363. </xsl:call-template>
  364. </HEAD>
  365. <BODY>
  366. <xsl:call-template name="pageHeader"/>
  367. <H3>Class <xsl:if test="not($package.name = '')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></H3>
  368. <!-- class summary -->
  369. <table class="log" cellpadding="5" cellspacing="2" width="100%">
  370. <xsl:apply-templates select="." mode="stats.header"/>
  371. <xsl:apply-templates select="." mode="stats"/>
  372. </table>
  373. <!-- details of methods -->
  374. <H3>Methods</H3>
  375. <table class="log" cellpadding="5" cellspacing="2" width="100%">
  376. <xsl:apply-templates select="method[1]" mode="stats.header"/>
  377. <xsl:apply-templates select="method" mode="stats">
  378. <xsl:sort data-type="number" select="cov.data/@hit_lines div cov.data/@total_lines"/>
  379. </xsl:apply-templates>
  380. </table>
  381. <xsl:call-template name="pageFooter"/>
  382. </BODY>
  383. </HTML>
  384. </xsl:template>
  385. <!-- Page Header -->
  386. <xsl:template name="pageHeader">
  387. <!-- jakarta logo -->
  388. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  389. <tr>
  390. <td class="bannercell" rowspan="2">
  391. <a href="http://jakarta.apache.org/">
  392. <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
  393. </a>
  394. </td>
  395. <td style="text-align:right"><h2>Source Code Coverage</h2></td>
  396. </tr>
  397. <tr>
  398. <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>
  399. </tr>
  400. </table>
  401. <hr size="1"/>
  402. </xsl:template>
  403. <!-- Page Footer -->
  404. <xsl:template name="pageFooter">
  405. <table width="100%">
  406. <tr><td><hr noshade="yes" size="1"/></td></tr>
  407. <tr><td>
  408. <div align="center"><font color="#525D76" size="-1"><em>
  409. Copyright &#169; 1999-2001, Apache Software Foundation
  410. </em></font></div>
  411. </td></tr>
  412. </table>
  413. </xsl:template>
  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. <xsl:template match="method" mode="stats.header">
  422. <tr>
  423. <th width="90%">Name</th>
  424. <th width="10%" nowrap="nowrap">Lines Hit</th>
  425. </tr>
  426. </xsl:template>
  427. <xsl:template match="method" mode="stats">
  428. <tr>
  429. <xsl:call-template name="alternate-row"/>
  430. <td><xsl:value-of select="@name"/></td>
  431. <td>
  432. <xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/>
  433. </td>
  434. </tr>
  435. </xsl:template>
  436. <xsl:template match="package|class" mode="stats.header">
  437. <tr>
  438. <th width="80%">Name</th>
  439. <th width="10%" nowrap="nowrap">Methods Hit</th>
  440. <th width="10%" nowrap="nowrap">Lines Hit</th>
  441. </tr>
  442. </xsl:template>
  443. <xsl:template match="package|class" mode="stats">
  444. <tr>
  445. <xsl:call-template name="alternate-row"/>
  446. <td><xsl:value-of select="@name"/></td>
  447. <td><xsl:value-of select="format-number(cov.data/@hit_methods div cov.data/@total_methods,'0.0%')"/></td>
  448. <td><xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/></td>
  449. </tr>
  450. </xsl:template>
  451. <!--
  452. transform string like a.b.c to ../../../
  453. @param path the path to transform into a descending directory path
  454. -->
  455. <xsl:template name="path">
  456. <xsl:param name="path"/>
  457. <xsl:if test="contains($path,'.')">
  458. <xsl:text>../</xsl:text>
  459. <xsl:call-template name="path">
  460. <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param>
  461. </xsl:call-template>
  462. </xsl:if>
  463. <xsl:if test="not(contains($path,'.')) and not($path = '')">
  464. <xsl:text>../</xsl:text>
  465. </xsl:if>
  466. </xsl:template>
  467. <!-- create the link to the stylesheet based on the package name -->
  468. <xsl:template name="create.stylesheet.link">
  469. <xsl:param name="package.name"/>
  470. <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>
  471. </xsl:template>
  472. <!-- alternated row style -->
  473. <xsl:template name="alternate-row">
  474. <xsl:attribute name="class">
  475. <xsl:if test="position() mod 2 = 1">a</xsl:if>
  476. <xsl:if test="position() mod 2 = 0">b</xsl:if>
  477. </xsl:attribute>
  478. </xsl:template>
  479. </xsl:stylesheet>