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="org.apache.xalan.lib.Redirect"
      5   extension-element-prefixes="redirect">
      6 <xsl:output method="html" indent="yes" encoding="US-ASCII"/>
      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 JDepend 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  @author <a href="mailto:jtulley (a] novell.com">Jeff Tulley</a>
     32 
     33   -->
     34 <xsl:param name="output.dir" select="'.'"/>
     35 
     36 <xsl:template match="JDepend">
     37    <!-- create the index.html -->
     38    <redirect:write file="{$output.dir}/index.html">
     39       <xsl:call-template name="index.html"/>
     40    </redirect:write>
     41 
     42   <!-- create the stylesheet.css -->
     43   <redirect:write file="{$output.dir}/stylesheet.css">
     44     <xsl:call-template name="stylesheet.css"/>
     45    </redirect:write>
     46 
     47    <!-- create the overview-packages.html at the root -->
     48   <redirect:write file="{$output.dir}/overview-summary.html">
     49     <xsl:apply-templates select="." mode="overview.packages"/>
     50   </redirect:write>
     51 
     52    <!-- create the overview-packages.html at the root -->
     53    <redirect:write file="{$output.dir}/overview-packages.html">
     54     <xsl:apply-templates select="." mode="packages.details"/>
     55   </redirect:write>
     56 
     57    <!-- create the overview-cycles.html at the root -->
     58    <redirect:write file="{$output.dir}/overview-cycles.html">
     59     <xsl:apply-templates select="." mode="cycles.details"/>
     60   </redirect:write>
     61 
     62    <!-- create the overview-cycles.html at the root -->
     63    <redirect:write file="{$output.dir}/overview-explanations.html">
     64     <xsl:apply-templates select="." mode="explanations"/>
     65   </redirect:write>
     66 
     67   <!-- create the all-packages.html at the root -->
     68    <redirect:write file="{$output.dir}/all-packages.html">
     69     <xsl:apply-templates select="Packages" mode="all.packages"/>
     70   </redirect:write>
     71 
     72   <!-- create the all-cycles.html at the root -->
     73   <redirect:write file="{$output.dir}/all-cycles.html">
     74     <xsl:apply-templates select="Cycles" mode="all.cycles"/>
     75   </redirect:write>
     76 </xsl:template>
     77 
     78 
     79 <xsl:template name="index.html">
     80 <html>
     81    <head>
     82       <title>JDepend Analysis</title>
     83    </head>
     84       <frameset cols="20%,80%">
     85          <frameset rows="30%,70%">
     86             <frame src="all-packages.html" name="packageListFrame"/>
     87             <frame src="all-cycles.html" name="classListFrame"/>
     88          </frameset>
     89          <frame src="overview-summary.html" name="classFrame"/>
     90       </frameset>
     91       <noframes>
     92          <h2>Frame Alert</h2>
     93          <p>
     94             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.
     95          </p>
     96       </noframes>
     97 </html>
     98 </xsl:template>
     99 
    100 <!-- this is the stylesheet css to use for nearly everything -->
    101 <xsl:template name="stylesheet.css">
    102    <style type="text/css">
    103     body {
    104     font:normal 68% verdana,arial,helvetica;
    105     color:#000000;
    106     }
    107     table tr td, tr th {
    108       font-size: 68%;
    109     }
    110     table.details tr th{
    111     font-weight: bold;
    112     text-align:left;
    113     background:#a6caf0;
    114     }
    115     table.details tr td{
    116     background:#eeeee0;
    117     }
    118 
    119     p {
    120     line-height:1.5em;
    121     margin-top:0.5em; margin-bottom:1.0em;
    122     margin-left:2em;
    123     margin-right:2em;
    124     }
    125     h1 {
    126     margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
    127     }
    128     h2 {
    129     margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
    130     }
    131     h3 {
    132     margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
    133     }
    134     h4 {
    135     margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
    136     }
    137     h5 {
    138     margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
    139     }
    140     h6 {
    141     margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
    142     }
    143     .Error {
    144     font-weight:bold; color:red;
    145     }
    146     .Failure {
    147     font-weight:bold; color:purple;
    148     }
    149     .Properties {
    150     text-align:right;
    151     }
    152   </style>
    153 </xsl:template>
    154 
    155 <xsl:template match="JDepend" mode="overview.packages">
    156    <html>
    157       <head>
    158          <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
    159       </head>
    160       <body>
    161          <xsl:call-template name="pageHeader"/>
    162   <table width="100%"><tr align="left"><h2>Summary</h2><td>
    163   </td><td align="right">
    164   [summary]
    165   [<a href="overview-packages.html">packages</a>]
    166   [<a href="overview-cycles.html">cycles</a>]
    167   [<a href="overview-explanations.html">explanations</a>]
    168    </td></tr></table>
    169          <table width="100%" class="details">
    170             <tr>
    171                <th>Package</th>
    172                <th>Total Classes</th>
    173                <th><a href="overview-explanations.html#EXnumber">Abstract Classes</a></th>
    174                <th><a href="overview-explanations.html#EXnumber">Concrete Classes</a></th>
    175                <th><a href="overview-explanations.html#EXafferent">Afferent Couplings</a></th>
    176                <th><a href="overview-explanations.html#EXefferent">Efferent Couplings</a></th>
    177                <th><a href="overview-explanations.html#EXabstractness">Abstractness</a></th>
    178                <th><a href="overview-explanations.html#EXinstability">Instability</a></th>
    179                <th><a href="overview-explanations.html#EXdistance">Distance</a></th>
    180 
    181             </tr>
    182             <xsl:for-each select="./Packages/Package">
    183                <xsl:if test="count(error) = 0">
    184                   <tr>
    185                      <td align="left">
    186                         <a>
    187                            <xsl:attribute name="href">overview-packages.html#PK<xsl:value-of select="@name"/>
    188                            </xsl:attribute>
    189                            <xsl:value-of select="@name"/>
    190                         </a>
    191                      </td>
    192                      <td align="right"><xsl:value-of select="Stats/TotalClasses"/></td>
    193                      <td align="right"><xsl:value-of select="Stats/AbstractClasses"/></td>
    194                      <td align="right"><xsl:value-of select="Stats/ConcreteClasses"/></td>
    195                      <td align="right"><xsl:value-of select="Stats/Ca"/></td>
    196                      <td align="right"><xsl:value-of select="Stats/Ce"/></td>
    197                      <td align="right"><xsl:value-of select="Stats/A"/></td>
    198                      <td align="right"><xsl:value-of select="Stats/I"/></td>
    199                      <td align="right"><xsl:value-of select="Stats/D"/></td>
    200                   </tr>
    201                </xsl:if>
    202             </xsl:for-each>
    203             <xsl:for-each select="./Packages/Package">
    204                <xsl:if test="count(error) &gt; 0">
    205                   <tr>
    206                      <td align="left">
    207                         <xsl:value-of select="@name"/>
    208                      </td>
    209                      <td align="left" colspan="8"><xsl:value-of select="error"/></td>
    210                   </tr>
    211                </xsl:if>
    212             </xsl:for-each>
    213          </table>
    214       </body>
    215    </html>
    216 </xsl:template>
    217 
    218 <xsl:template match="JDepend" mode="packages.details">
    219    <html>
    220       <head>
    221           <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
    222       </head>
    223       <body>
    224          <xsl:call-template name="pageHeader"/>
    225   <table width="100%"><tr align="left"><h2>Packages</h2><td>
    226   </td><td align="right">
    227   [<a href="overview-summary.html">summary</a>]
    228   [packages]
    229   [<a href="overview-cycles.html">cycles</a>]
    230   [<a href="overview-explanations.html">explanations</a>]
    231    </td></tr></table>
    232 
    233   <xsl:for-each select="./Packages/Package">
    234     <xsl:if test="count(error) = 0">
    235       <h3><a><xsl:attribute name="name">PK<xsl:value-of select="@name"/></xsl:attribute>
    236       <xsl:value-of select="@name"/></a></h3>
    237 
    238       <table width="100%"><tr>
    239         <td><a href="overview-explanations.html#EXafferent">Afferent Couplings</a>: <xsl:value-of select="Stats/Ca"/></td>
    240         <td><a href="overview-explanations.html#EXefferent">Efferent Couplings</a>: <xsl:value-of select="Stats/Ce"/></td>
    241         <td><a href="overview-explanations.html#EXabstractness">Abstractness</a>: <xsl:value-of select="Stats/A"/></td>
    242         <td><a href="overview-explanations.html#EXinstability">Instability</a>: <xsl:value-of select="Stats/I"/></td>
    243         <td><a href="overview-explanations.html#EXdistance">Distance</a>: <xsl:value-of select="Stats/D"/></td>
    244       </tr></table>
    245 
    246       <table width="100%" class="details">
    247         <tr>
    248           <th>Abstract Classes</th>
    249           <th>Concrete Classes</th>
    250           <th>Used by Packages</th>
    251           <th>Uses Packages</th>
    252         </tr>
    253         <tr>
    254           <td valign="top" width="25%">
    255           <xsl:if test="count(AbstractClasses/Class)=0">
    256               <i>None</i>
    257             </xsl:if>
    258             <xsl:for-each select="AbstractClasses/Class">
    259               <xsl:value-of select="node()"/><br/>
    260             </xsl:for-each>
    261           </td>
    262           <td valign="top" width="25%">
    263             <xsl:if test="count(ConcreteClasses/Class)=0">
    264               <i>None</i>
    265             </xsl:if>
    266             <xsl:for-each select="ConcreteClasses/Class">
    267               <xsl:value-of select="node()"/><br/>
    268             </xsl:for-each>
    269           </td>
    270           <td valign="top" width="25%">
    271             <xsl:if test="count(UsedBy/Package)=0">
    272               <i>None</i>
    273             </xsl:if>
    274             <xsl:for-each select="UsedBy/Package">
    275               <a>
    276                         <xsl:attribute name="href">overview-packages.html#PK<xsl:value-of select="node()"/></xsl:attribute>
    277                 <xsl:value-of select="node()"/>
    278               </a><br/>
    279             </xsl:for-each>
    280           </td>
    281           <td valign="top" width="25%">
    282             <xsl:if test="count(DependsUpon/Package)=0">
    283               <i>None</i>
    284             </xsl:if>
    285             <xsl:for-each select="DependsUpon/Package">
    286               <a>
    287                         <xsl:attribute name="href">overview-packages.html#PK<xsl:value-of select="node()"/></xsl:attribute>
    288                 <xsl:value-of select="node()"/>
    289               </a><br/>
    290             </xsl:for-each>
    291           </td>
    292         </tr>
    293       </table>
    294     </xsl:if>
    295   </xsl:for-each>
    296   <!-- this is often a long listing; provide a lower navigation table also -->
    297   <table width="100%"><tr align="left"><td></td><td align="right">
    298   [<a href="overview-summary.html">summary</a>]
    299   [packages]
    300   [<a href="overview-cycles.html">cycles</a>]
    301   [<a href="overview-explanations.html">explanations</a>]
    302    </td></tr></table>
    303       </body>
    304    </html>
    305 </xsl:template>
    306 
    307 <xsl:template match="JDepend" mode="cycles.details">
    308    <html>
    309       <head>
    310          <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
    311       </head>
    312       <body>
    313          <xsl:call-template name="pageHeader"/>
    314   <table width="100%"><tr align="left"><h2>Cycles</h2><td>
    315   </td><td align="right">
    316   [<a href="overview-summary.html">summary</a>]
    317   [<a href="overview-packages.html">packages</a>]
    318   [cycles]
    319   [<a href="overview-explanations.html">explanations</a>]
    320    </td></tr></table>
    321   <!--<table width="100%"><tr><td>
    322   </td><td align="right">
    323     [<a href="#NVsummary">summary</a>]
    324   [<a href="#NVpackages">packages</a>]
    325   [<a href="#NVcycles">cycles</a>]
    326    [<a href="#NVexplanations">explanations</a>]
    327   </td></tr></table> -->
    328 
    329   <xsl:if test="count(Cycles/Package) = 0">
    330     <p>There are no cyclic dependancies.</p>
    331   </xsl:if>
    332   <xsl:for-each select="Cycles/Package">
    333      <h3><a><xsl:attribute name="name">#CY<xsl:value-of select="@Name"/></xsl:attribute><xsl:value-of select="@Name"/></a></h3><p>
    334     <xsl:for-each select="Package">
    335       <xsl:value-of select="."/><br/>
    336     </xsl:for-each></p>
    337   </xsl:for-each>
    338   <!-- this is often a long listing; provide a lower navigation table also -->
    339   <table width="100%"><tr align="left"><td></td><td align="right">
    340   [<a href="overview-summary.html">summary</a>]
    341   [<a href="overview-packages.html">packages</a>]
    342   [cycles]
    343   [<a href="overview-explanations.html">explanations</a>]
    344    </td></tr></table>
    345   </body>
    346   </html>
    347 </xsl:template>
    348 
    349 <xsl:template match="JDepend" mode="explanations">
    350    <html>
    351       <head>
    352          <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
    353       </head>
    354       <body>
    355          <xsl:call-template name="pageHeader"/>
    356 
    357   <table width="100%"><tr align="left"><h2>Explanations</h2><td>
    358   </td><td align="right">
    359   [<a href="overview-summary.html">summary</a>]
    360   [<a href="overview-packages.html">packages</a>]
    361   [<a href="overview-cycles.html">cycles</a>]
    362   [explanations]
    363    </td></tr></table>
    364 
    365   <p>The following explanations are for quick reference and are lifted directly from the original <a href="http://www.clarkware.com/software/JDepend.html">JDepend documentation</a>.</p>
    366 
    367   <h3><a name="EXnumber">Number of Classes</a></h3>
    368     <p>The number of concrete and abstract classes (and interfaces) in the package is an indicator of the extensibility of the package.</p>
    369   <h3><a name="EXafferent">Afferent Couplings</a></h3>
    370     <p>The number of other packages that depend upon classes within the package is an indicator of the package's responsibility. </p>
    371   <h3><a name="EXefferent">Efferent Couplings</a></h3>
    372     <p>The number of other packages that the classes in the package depend upon is an indicator of the package's independence. </p>
    373   <h3><a name="EXabstractness">Abstractness</a></h3>
    374     <p>The ratio of the number of abstract classes (and interfaces) in the analyzed package to the total number of classes in the analyzed package. </p>
    375     <p>The range for this metric is 0 to 1, with A=0 indicating a completely concrete package and A=1 indicating a completely abstract package. </p>
    376   <h3><a name="EXinstability">Instability</a></h3>
    377     <p>The ratio of efferent coupling (Ce) to total coupling (Ce / (Ce + Ca)). This metric is an indicator of the package's resilience to change. </p>
    378     <p>The range for this metric is 0 to 1, with I=0 indicating a completely stable package and I=1 indicating a completely instable package. </p>
    379   <h3><a name="EXdistance">Distance</a></h3>
    380     <p>The perpendicular distance of a package from the idealized line A + I = 1. This metric is an indicator of the package's balance between abstractness and stability. </p>
    381     <p>A package squarely on the main sequence is optimally balanced with respect to its abstractness and stability. Ideal packages are either completely abstract and stable (x=0, y=1) or completely concrete and instable (x=1, y=0). </p>
    382     <p>The range for this metric is 0 to 1, with D=0 indicating a package that is coincident with the main sequence and D=1 indicating a package that is as far from the main sequence as possible. </p>
    383 
    384       </body>
    385    </html>
    386 </xsl:template>
    387 
    388 
    389 <!--
    390 Creates an html file that contains a link to all package links in overview-packages.html.
    391   @bug there will be a problem here, I don't know yet how to handle unnamed package :(
    392 -->
    393 <xsl:template match="JDepend/Packages" mode="all.packages">
    394   <html>
    395     <head>
    396       <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
    397     </head>
    398     <body>
    399   <table width="100%"><tr align="left"><td></td><td nowrap="nowrap" align="right">
    400   [<a href="overview-summary.html" target="classFrame">summary</a>]
    401   [<a href="overview-packages.html" target="classFrame">packages</a>]
    402   [<a href="overview-cycles.html" target="classFrame">cycles</a>]
    403   [<a href="overview-explanations.html" target="classFrame">explanations</a>]
    404    </td></tr></table>
    405       <h2>Packages</h2>
    406         <table width="100%">
    407           <xsl:apply-templates select="Package[count(error)=0]" mode="all.packages.link">
    408             <xsl:sort select="@name"/>
    409           </xsl:apply-templates>
    410           <xsl:apply-templates select="Package[count(error) &gt; 0]" mode="all.packages.nolink">
    411             <xsl:sort select="@name"/>
    412           </xsl:apply-templates>
    413         </table>
    414     </body>
    415   </html>
    416 </xsl:template>
    417 
    418 <xsl:template match="JDepend/Packages/Package" mode="all.packages.link">
    419   <tr>
    420     <td nowrap="nowrap">
    421          <a href="overview-packages.html#PK{@name}" target="classFrame">
    422         <xsl:value-of select="@name"/>
    423       </a>
    424     </td>
    425   </tr>
    426 </xsl:template>
    427 
    428 <!--
    429 I do not know JDepend enough to know if every error results in a non-analyzed package,
    430 but that is how I am presenting it to the viewer.  This may need to change.
    431   @bug there will be a problem here, I don't know yet how to handle unnamed package :(
    432 -->
    433 <xsl:template match="JDepend/Packages/Package" mode="all.packages.nolink">
    434   <tr>
    435     <td nowrap="nowrap">
    436        Not Analyzed: <xsl:value-of select="@name"/>
    437     </td>
    438   </tr>
    439 </xsl:template>
    440 
    441 <!--
    442 Creates an html file that contains a link to all package links in overview-cycles.html.
    443   @bug there will be a problem here, I don't know yet how to handle unnamed package :(
    444 -->
    445 <xsl:template match="JDepend/Cycles" mode="all.cycles">
    446   <html>
    447     <head>
    448       <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
    449     </head>
    450     <body>
    451   <table width="100%"><tr align="left"><td></td><td nowrap="nowrap" align="right">
    452   [<a href="overview-summary.html" target="classFrame">summary</a>]
    453   [<a href="overview-packages.html" target="classFrame">packages</a>]
    454   [<a href="overview-cycles.html" target="classFrame">cycles</a>]
    455   [<a href="overview-explanations.html" target="classFrame">explanations</a>]
    456    </td></tr></table>
    457       <h2>Cycles</h2>
    458         <table width="100%">
    459            <xsl:apply-templates select="Package" mode="all.cycles">
    460             <xsl:sort select="@Name"/>
    461           </xsl:apply-templates>
    462         </table>
    463     </body>
    464   </html>
    465 </xsl:template>
    466 
    467 <xsl:template match="JDepend/Cycles/Package" mode="all.cycles">
    468   <tr>
    469     <td nowrap="nowrap">
    470          <a href="overview-cycles.html#CY{@Name}" target="classFrame"><xsl:value-of select="@Name"/></a>
    471     </td>
    472   </tr>
    473 </xsl:template>
    474 
    475 <!-- Page HEADER -->
    476 <xsl:template name="pageHeader">
    477    <h1>JDepend Analysis</h1>
    478   <table width="100%">
    479   <tr>
    480     <td align="left"></td>
    481       <td align="right">Designed for use with <a href="http://www.clarkware.com/software/JDepend.html">JDepend</a> and <a href="http://jakarta.apache.org">Ant</a>.</td>
    482   </tr>
    483   </table>
    484   <hr size="1"/>
    485 </xsl:template>
    486 
    487 </xsl:stylesheet>
    488