"Fossies" - the Fresh Open Source Software Archive

Member "UNICORE-Client-7.4.1/plugins/org.apache.ant_1.10.3.v20180417-1627/etc/mmetrics-frames.xsl" (4 May 2018, 37754 Bytes) of package /windows/misc/UNICORE_Client-7.4.1-win32.win32.x86.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) XML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    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:xalan="http://xml.apache.org/xalan"
    5   xmlns:redirect="org.apache.xalan.lib.Redirect"
    6   exclude-result-prefixes="xalan"
    7   extension-element-prefixes="redirect">
    8 <xsl:output method="html" indent="yes" encoding="US-ASCII"/>
    9 <xsl:decimal-format decimal-separator="." grouping-separator="," />
   10 <!--
   11    Licensed to the Apache Software Foundation (ASF) under one or more
   12    contributor license agreements.  See the NOTICE file distributed with
   13    this work for additional information regarding copyright ownership.
   14    The ASF licenses this file to You under the Apache License, Version 2.0
   15    (the "License"); you may not use this file except in compliance with
   16    the License.  You may obtain a copy of the License at
   17 
   18        http://www.apache.org/licenses/LICENSE-2.0
   19 
   20    Unless required by applicable law or agreed to in writing, software
   21    distributed under the License is distributed on an "AS IS" BASIS,
   22    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   23    See the License for the specific language governing permissions and
   24    limitations under the License.
   25 -->
   26 <xsl:param name="output.dir" select="'.'"/>
   27 
   28 <!-- default max value for the metrics -->
   29 <xsl:param name="vg.max" select="10"/>
   30 <xsl:param name="loc.max" select="1000"/>
   31 <xsl:param name="dit.max" select="10"/>
   32 <xsl:param name="noa.max" select="250"/>
   33 <xsl:param name="nrm.max" select="50"/>
   34 <xsl:param name="nlm.max" select="250"/>
   35 <xsl:param name="wmc.max" select="250"/>
   36 <xsl:param name="rfc.max" select="50"/>
   37 <xsl:param name="dac.max" select="10"/>
   38 <xsl:param name="fanout.max" select="10"/>
   39 <xsl:param name="cbo.max" select="15"/>
   40 <xsl:param name="lcom.max" select="10"/>
   41 <xsl:param name="nocl.max" select="10"/>
   42 
   43 
   44 <!-- create a tree fragment to speed up processing -->
   45 <xsl:variable name="doctree.var">
   46   <xsl:element name="classes">
   47     <xsl:for-each select=".//class">
   48       <xsl:element name="class">
   49         <xsl:attribute name="package">
   50           <xsl:value-of select="(ancestor::package)[last()]/@name"/>
   51         </xsl:attribute>
   52         <xsl:copy-of select="@*"/>
   53         <xsl:attribute name="name">
   54           <xsl:apply-templates select="." mode="class.name"/>
   55         </xsl:attribute>
   56         <xsl:copy-of select="method"/>
   57       </xsl:element>
   58     </xsl:for-each>
   59   </xsl:element>
   60 </xsl:variable>
   61 
   62 <xsl:variable name="doctree" select="xalan:nodeset($doctree.var)"/>
   63 
   64 <xsl:template match="metrics">
   65 
   66   <!-- create the index.html -->
   67   <redirect:write file="{$output.dir}/index.html">
   68     <xsl:call-template name="index.html"/>
   69   </redirect:write>
   70 
   71   <!-- create the stylesheet.css -->
   72   <redirect:write file="{$output.dir}/stylesheet.css">
   73     <xsl:call-template name="stylesheet.css"/>
   74   </redirect:write>
   75 
   76   <redirect:write file="{$output.dir}/metrics-reference.html">
   77     <xsl:call-template name="metrics-reference.html"/>
   78   </redirect:write>
   79 
   80   <!-- create the overview-packages.html at the root -->
   81   <redirect:write file="{$output.dir}/overview-summary.html">
   82     <xsl:apply-templates select="." mode="overview.packages"/>
   83   </redirect:write>
   84 
   85   <!-- create the all-packages.html at the root -->
   86   <redirect:write file="{$output.dir}/overview-frame.html">
   87     <xsl:apply-templates select="." mode="all.packages"/>
   88   </redirect:write>
   89 
   90   <!-- create the all-classes.html at the root -->
   91   <redirect:write file="{$output.dir}/allclasses-frame.html">
   92     <xsl:apply-templates select="." mode="all.classes"/>
   93   </redirect:write>
   94 
   95   <!-- process all packages -->
   96   <xsl:apply-templates select=".//package"/>
   97 </xsl:template>
   98 
   99 
  100 <xsl:template match="package">
  101   <xsl:variable name="package.name" select="@name"/>
  102   <xsl:variable name="package.dir">
  103     <xsl:if test="not($package.name = 'unnamed package')"><xsl:value-of select="translate($package.name,'.','/')"/></xsl:if>
  104     <xsl:if test="$package.name = 'unnamed package'">.</xsl:if>
  105   </xsl:variable>
  106   <!-- create a classes-list.html in the package directory -->
  107   <redirect:write file="{$output.dir}/{$package.dir}/package-frame.html">
  108     <xsl:apply-templates select="." mode="classes.list"/>
  109   </redirect:write>
  110 
  111   <!-- create a package-summary.html in the package directory -->
  112   <redirect:write file="{$output.dir}/{$package.dir}/package-summary.html">
  113     <xsl:apply-templates select="." mode="package.summary"/>
  114   </redirect:write>
  115 
  116   <!-- for each class, creates a @name.html -->
  117   <!-- @bug there will be a problem with inner classes having the same name, it will be overwritten -->
  118   <xsl:for-each select="$doctree/classes/class[@package = current()/@name]">
  119       <!--Processing <xsl:value-of select="$class.name"/><xsl:text>&#10;</xsl:text> -->
  120     <redirect:write file="{$output.dir}/{$package.dir}/{@name}.html">
  121       <xsl:apply-templates select="." mode="class.details"/>
  122     </redirect:write>
  123   </xsl:for-each>
  124 </xsl:template>
  125 
  126 <!-- little trick to compute the classname for inner and non inner classes -->
  127 <!-- this is all in one line to avoid CRLF in the name -->
  128 <xsl:template match="class" mode="class.name">
  129     <xsl:if test="parent::class"><xsl:apply-templates select="parent::class" mode="class.name"/>.<xsl:value-of select="@name"/></xsl:if><xsl:if test="not(parent::class)"><xsl:value-of select="@name"/></xsl:if>
  130 </xsl:template>
  131 
  132 
  133 <xsl:template name="index.html">
  134 <HTML>
  135   <HEAD><TITLE>Metrics Results.</TITLE></HEAD>
  136   <FRAMESET cols="20%,80%">
  137     <FRAMESET rows="30%,70%">
  138       <FRAME src="overview-frame.html" name="packageListFrame"/>
  139       <FRAME src="allclasses-frame.html" name="classListFrame"/>
  140     </FRAMESET>
  141     <FRAME src="overview-summary.html" name="classFrame"/>
  142   </FRAMESET>
  143   <noframes>
  144     <H2>Frame Alert</H2>
  145     <P>
  146     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.
  147     </P>
  148   </noframes>
  149 </HTML>
  150 </xsl:template>
  151 
  152 <!-- this is the stylesheet css to use for nearly everything -->
  153 <xsl:template name="metrics-reference.html">
  154 <html>
  155 <head>
  156 <link title="Style" type="text/css" rel="stylesheet" href="stylesheet.css"/>
  157 </head>
  158 <body style="text-align:justify;">
  159 <h2>Metrics Reference</h2>
  160 <a href="#V(G)">V(G)</a> |
  161 <a href="#LOC">LOC</a> |
  162 <a href="#DIT">DIT</a> |
  163 <a href="#NOA">NOA</a> |
  164 <a href="#NRM">NRM</a> |
  165 <a href="#NLM">NLM</a> |
  166 <a href="#WMC">WMC</a> |
  167 <a href="#RFC">RFC</a> |
  168 <a href="#DAC">DAC</a> |
  169 <a href="#FANOUT">FANOUT</a> |
  170 <a href="#CBO">CBO</a> |
  171 <a href="#LCOM">LCOM</a> |
  172 <a href="#NOC">NOC</a>
  173 
  174 <a name="V(G)"/>
  175 <h3>Cyclomatic Complexity - V(G)</h3>
  176 This metric was introduced in the 1970s to measure the amount of control
  177 flow complexity or branching complexity in a module such as a
  178 subroutine. It gives the number of paths that may be taken through the
  179 code, and was initially developed to give some measure of the cost of
  180 producing a test case for the module by executing each path.
  181 <p/>
  182 Methods with a high cyclomatic complexity tend to be more difficult to
  183 understand and maintain. In general the more complex the methods of an
  184 application, the more difficult it will be to test it, and this will adversely
  185 affect its reliability.
  186 <p/>
  187 V(G) is a measure of the control flow complexity of a method or
  188 constructor.  It counts the number of branches in the body of the method,
  189 defined as:
  190 <ul>
  191 <li>while statements;</li>
  192 <li>if statements;</li>
  193 <li>for statements.</li>
  194 </ul>
  195 
  196 The metric can also be configured to count each case of a switch
  197 statement as well.
  198 
  199 <a name="LOC"/>
  200 <h3>Lines of Code - LOC</h3>
  201 
  202 This is perhaps the simplest of all the metrics to define and compute.
  203 Counting lines has a long history as a software metric dating from before
  204 the rise of structured programming, and it is still in widespread use today.
  205 The size of a method affects the ease with which it can be understood, its
  206 reusability and its maintainability. There are a variety of ways that the size
  207 can be calculated. These include counting all the lines of code, the number
  208 of statements, the blank lines of code, the lines of commentary, and the
  209 lines consisting only of syntax such as block delimiters.
  210 <p/>
  211 This metric can also be used for sizing other constructs as well, for
  212 example, the overall size of a Java class or package can be measured by
  213 counting the number of source lines it consists of.
  214 <p/>
  215 LOC can be used to determine the size of a compilation unit (source file),
  216 class or interface, method, constructor, or field.  It can be configured to
  217 ignore:
  218 <ul>
  219 <li>blank lines;</li>
  220 <li>lines consisting only of comments;</li>
  221 <li>lines consisting only of opening and closing braces.</li>
  222 </ul>
  223 
  224 <a name="DIT"/>
  225 <h3>Depth of Inheritance Hierarchy - DIT</h3>
  226 
  227 This metric calculates how far down the inheritance hierarchy a class is
  228 declared. In Java all classes have java.lang.Object as their ultimate
  229 superclass, which is defined to have a depth of 1. So a class that
  230 immediately extends java.lang.Object has a metric value of 2; any of its
  231 subclasses will have a value of 3, and so on.
  232 <p/>
  233 A class that is deep within the tree inherits more methods and state
  234 variables, thereby increasing its complexity and making it difficult to
  235 predict its behavior. It can be harder to understand a system with many
  236 inheritance layers.
  237 <p/>
  238 DIT is defined for classes and interfaces:
  239 <ul>
  240 <li>all interface types have a depth of 1;</li>
  241 <li>the class java.lang.Object has a depth of 1;</li>
  242 <li>all other classes have a depth of 1 + the depth of their super class.</li>
  243 </ul>
  244 
  245 <a name="NOA"/>
  246 <h3>Number of Attributes - NOA</h3>
  247 
  248 The number of distinct state variables in a class serves as one measure of
  249 its complexity. The more state a class represents the more difficult it is to
  250 maintain invariants for it. It also hinders comprehensibility and reuse.
  251 <p/>
  252 In Java, state can be exposed to subclasses through protected fields, which
  253 entails that the subclass also be aware of and maintain any invariants. This
  254 interference with the class's data encapsulation can be a source of defects
  255 and hidden dependencies between the state variables.
  256 <p/>
  257 NOA is defined for classes and interfaces.  It counts the number of fields
  258 declared in the class or interface.
  259 
  260 <a name="NRM"/>
  261 <h3>Number of Remote Methods - NRM</h3>
  262 
  263 NRM is defined for classes.  A remote method call is defined as an
  264 invocation of a method that is not declared in any of:
  265 <ul>
  266 <li>the class itself;</li>
  267 <li>a class or interface that the class extends or implements;</li>
  268 <li>a class or method that extends the class.</li>
  269 </ul>
  270 
  271 The value is the count of all the remote method calls in all of the methods
  272 and constructors of the class.
  273 
  274 <a name="NLM"/>
  275 <h3>Number of Local Methods - NLM</h3>
  276 
  277 NLM is defined for classes and interfaces.  A local method is defined as a
  278 method that is declared in the class or interface. NLM can be configured to
  279 include the local methods of all of the class's superclasses.  Methods with
  280 public, protected, package and private visibility can be independently
  281 counted by setting configuration parameters.
  282 
  283 <a name="WMC"/>
  284 <h3>Weighted Methods per Class - WMC</h3>
  285 
  286 If the number of methods in a class can be determined during the design
  287 and modeling phase of a project, it can be used as a predictor of how
  288 much time and effort is needed to develop, debug and maintain it. This
  289 metric can be further refined by incorporating a weighting for the
  290 complexity of each method. The usual weighting is given by the cyclomatic
  291 complexity of the method.
  292 <p/>
  293 The subclasses of a class inherit all of its public and protected methods,
  294 and possibly its package methods as well, so the number of methods a
  295 class has directly impacts the complexity of its subclasses. Classes with
  296 large numbers of methods are often specific to a particular application,
  297 reducing the ability to reuse them.
  298 <p/>
  299 The definition of WMC is based upon NLM, and it provides the same
  300 configuration parameters for counting inherited methods and of varying
  301 visibility. The main difference is that NLM always counts each method as 1,
  302 whereas WMC will weight each method. There are two weighting schemes:
  303 <ul>
  304 <li>V(G) the cyclomatic complexity of the method is used as its weight.
  305    Methods from class files are given a V(G) of 1.</li>
  306 <li>the arity, or the number of parameters of the method are used to
  307    determine the weight.</li>
  308 </ul>
  309 
  310 <a name="RFC"/>
  311 <h3>Response For Class - RFC</h3>
  312 
  313 The response set of a class is the set of all methods that can be invoked as
  314 a result of a message sent to an object of the class. This includes methods
  315 in the class's inheritance hierarchy and methods that can be invoked on
  316 other objects. The Response For Class metric is defined to be size of the
  317 response set for the class. A class which provides a larger response set is
  318 considered to be more complex than one with a smaller response set.
  319 <p/>
  320 One reason for this is that if a method call on a class can result in a large
  321 number of different method calls on the target and other classes, then it
  322 can be harder to test the behavior of the class and debug problems. It will
  323 typically require a deeper understanding of the potential interactions that
  324 objects of the class can have with the rest of the system.
  325 <p/>
  326 RFC is defined as the sum of NLM and NRM for the class.  The local methods
  327 include all of the public, protected, package and private methods, but not
  328 methods declared only in a superclass.
  329 
  330 <a name="DAC"/>
  331 <h3>Data Abstraction Coupling - DAC</h3>
  332 
  333 DAC is defined for classes and interfaces.  It counts the number of reference
  334 types that are used in the field declarations of the class or interface.  The
  335 component types of arrays are also counted.  Any field with a type that is
  336 either a supertype or a subtype of the class is not counted.
  337 
  338 <a name="FANOUT"/>
  339 <h3>Fan Out - FANOUT</h3>
  340 
  341 FANOUT is defined for classes and interfaces, constructors and methods. It
  342 counts the number of reference types that are used in:
  343 <ul>
  344 <li>field declarations;</li>
  345 <li>formal parameters and return types;</li>
  346 <li>throws declarations;</li>
  347 <li>local variables.</li>
  348 </ul>
  349 
  350 The component types of arrays are also counted. Any type that is either a
  351 supertype or a subtype of the class is not counted.
  352 
  353 <a name="CBO"/>
  354 <h3>Coupling Between Objects - CBO</h3>
  355 
  356 When one object or class uses another object or class they are said to be
  357 coupled. One major source of coupling is that between a superclass and a
  358 subclass. A coupling is also introduced when a method or field in another
  359 class is accessed, or when an object of another class is passed into or out
  360 of a method invocation. Coupling Between Objects is a measure of the
  361 non-inheritance coupling between two objects.
  362 <p/>
  363 A high value of coupling reduces the modularity of the class and makes
  364 reuse more difficult. The more independent a class is the more likely it is
  365 that it will be possible to reuse it in another part of the system. When a
  366 class is coupled to another class it becomes sensitive to changes in that
  367 class, thereby making maintenance for difficult. In addition, a class that is
  368 overly dependent on other classes can be difficult to understand and test in
  369 isolation.
  370 <p/>
  371 CBO is defined for classes and interfaces, constructors and methods. It
  372 counts the number of reference types that are used in:
  373 <ul>
  374 <li>field declarations</li>
  375 <li>formal parameters and return types</li>
  376 <li>throws declarations</li>
  377 <li>local variables</li>
  378 </ul>
  379 
  380 It also counts:
  381 <ul>
  382 <li>types from which field and method selections are made</li>
  383 </ul>
  384 
  385 The component types of arrays are also counted. Any type that is either a
  386 supertype or a subtype of the class is not counted.
  387 
  388 <a name="LCOM"/>
  389 <h3>Lack of Cohesion Of Methods - LCOM</h3>
  390 
  391 The cohesion of a class is the degree to which its methods are related to
  392 each other. It is determined by examining the pattern of state variable
  393 accesses within the set of methods. If all the methods access the same state
  394 variables then they have high cohesion; if they access disjoint sets of
  395 variables then the cohesion is low. An extreme example of low cohesion
  396 would be if none of the methods accessed any of the state variables.
  397 
  398 If a class exhibits low method cohesion it indicates that the design of the
  399 class has probably been partitioned incorrectly, and could benefit by being
  400 split into more classes with individually higher cohesion. On the other
  401 hand, a high value of cohesion (a low lack of cohesion) implies that the
  402 class is well designed. A cohesive class will tend to provide a high degree
  403 of encapsulation, whereas a lack of cohesion decreases encapsulation and
  404 increases complexity.
  405 <p/>
  406 Another form of cohesion that is useful for Java programs is cohesion
  407 between nested and enclosing classes. A nested class that has very low
  408 cohesion with its enclosing class would probably better designed as a peer
  409 class rather than a nested class.
  410 <p/>
  411 LCOM is defined for classes. Operationally, LCOM takes each pair of
  412 methods in the class and determines the set of fields they each access. If
  413 they have disjoint sets of field accesses increase the count P by one. If they
  414 share at least one field access then increase Q by one. After considering
  415 each pair of methods,
  416 LCOM = (P > Q) ? (P - Q) : 0
  417 <p/>
  418 Indirect access to fields via local methods can be considered by setting a
  419 metric configuration parameter.
  420 
  421 <a name="NOC"/>
  422 <h3>Number Of Classes - NOC</h3>
  423 
  424 The overall size of the system can be estimated by calculating the number
  425 of classes it contains. A large system with more classes is more complex
  426 than a smaller one because the number of potential interactions between
  427 objects is higher. This reduces the comprehensibility of the system which
  428 in turn makes it harder to test, debug and maintain.
  429 <p/>
  430 If the number of classes in the system can be projected during the initial
  431 design phase of the project it can serve as a base for estimating the total
  432 effort and cost of developing, debugging and maintaining the system.
  433 <p/>
  434 The NOC metric can also usefully be applied at the package and class level
  435 as well as the total system.
  436 <p/>
  437 NOCL is defined for class and interfaces. It counts the number of classes or
  438 interfaces that are declared. This is usually 1, but nested class declarations
  439 will increase this number.
  440 </body>
  441 </html>
  442 </xsl:template>
  443 
  444 <!-- this is the stylesheet css to use for nearly everything -->
  445 <xsl:template name="stylesheet.css">
  446     .bannercell {
  447       border: 0px;
  448       padding: 0px;
  449     }
  450     body {
  451       margin-left: 10;
  452       margin-right: 10;
  453       font:normal 80% arial,helvetica,sanserif;
  454       background-color:#FFFFFF;
  455       color:#000000;
  456     }
  457     .a td {
  458       background: #efefef;
  459     }
  460     .b td {
  461       background: #fff;
  462     }
  463     th, td {
  464       text-align: left;
  465       vertical-align: top;
  466     }
  467     th {
  468       font-weight:bold;
  469       background: #ccc;
  470       color: black;
  471     }
  472     table, th, td {
  473       font-size:100%;
  474       border: none
  475     }
  476     table.log tr td, tr th {
  477 
  478     }
  479     h2 {
  480       font-weight:bold;
  481       font-size:140%;
  482       margin-bottom: 5;
  483     }
  484     h3 {
  485       font-size:100%;
  486       font-weight:bold;
  487       background: #525D76;
  488       color: white;
  489       text-decoration: none;
  490       padding: 5px;
  491       margin-right: 2px;
  492       margin-left: 2px;
  493       margin-bottom: 0;
  494     }
  495     .Error {
  496       font-weight:bold; color:red;
  497     }
  498 
  499 </xsl:template>
  500 
  501 <!-- print the metrics of the class -->
  502 <xsl:template match="class" mode="class.details">
  503   <!--xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/-->
  504   <xsl:variable name="package.name" select="@package"/>
  505   <HTML>
  506     <HEAD>
  507       <xsl:call-template name="create.stylesheet.link">
  508         <xsl:with-param name="package.name" select="$package.name"/>
  509       </xsl:call-template>
  510     </HEAD>
  511     <BODY>
  512       <xsl:call-template name="pageHeader"/>
  513 
  514       <H3>Class <xsl:if test="not($package.name = 'unnamed package')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></H3>
  515       <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  516         <xsl:call-template name="all.metrics.header"/>
  517         <xsl:apply-templates select="." mode="print.metrics"/>
  518       </table>
  519 
  520       <H3>Methods</H3>
  521       <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  522         <xsl:call-template name="method.metrics.header"/>
  523         <xsl:apply-templates select="method" mode="print.metrics"/>
  524       </table>
  525 
  526       <xsl:call-template name="pageFooter"/>
  527     </BODY>
  528   </HTML>
  529 </xsl:template>
  530 
  531 
  532 <!-- list of classes in a package -->
  533 <xsl:template match="package" mode="classes.list">
  534   <HTML>
  535     <HEAD>
  536       <xsl:call-template name="create.stylesheet.link">
  537         <xsl:with-param name="package.name" select="@name"/>
  538       </xsl:call-template>
  539     </HEAD>
  540     <BODY>
  541       <table width="100%">
  542         <tr>
  543           <td nowrap="nowrap">
  544             <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="@name"/></a></H2>
  545           </td>
  546         </tr>
  547       </table>
  548 
  549       <H2>Classes</H2>
  550       <TABLE WIDTH="100%">
  551         <!-- xalan-nodeset:nodeset for Xalan 1.2.2 -->
  552             <xsl:for-each select="$doctree/classes/class[@package = current()/@name]">
  553                 <xsl:sort select="@name"/>
  554           <tr>
  555             <td nowrap="nowrap">
  556               <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a>
  557             </td>
  558           </tr>
  559             </xsl:for-each>
  560       </TABLE>
  561     </BODY>
  562   </HTML>
  563 </xsl:template>
  564 
  565 
  566 <!--
  567   Creates an all-classes.html file that contains a link to all package-summary.html
  568   on each class.
  569 -->
  570 <xsl:template match="metrics" mode="all.classes">
  571   <html>
  572     <head>
  573       <xsl:call-template name="create.stylesheet.link">
  574         <xsl:with-param name="package.name" select="''"/>
  575       </xsl:call-template>
  576     </head>
  577     <body>
  578       <h2>Classes</h2>
  579       <table width="100%">
  580           <xsl:for-each select="$doctree/classes/class">
  581               <xsl:sort select="@name"/>
  582               <xsl:apply-templates select="." mode="all.classes"/>
  583           </xsl:for-each>
  584       </table>
  585     </body>
  586   </html>
  587 </xsl:template>
  588 
  589 <xsl:template match="class" mode="all.classes">
  590     <xsl:variable name="package.name" select="@package"/>
  591     <xsl:variable name="class.name" select="@name"/>
  592   <tr>
  593     <td nowrap="nowrap">
  594       <a target="classFrame">
  595         <xsl:attribute name="href">
  596           <xsl:if test="not($package.name='unnamed package')">
  597             <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text>
  598           </xsl:if>
  599           <xsl:value-of select="$class.name"/><xsl:text>.html</xsl:text>
  600         </xsl:attribute>
  601         <xsl:value-of select="$class.name"/>
  602       </a>
  603     </td>
  604   </tr>
  605 </xsl:template>
  606 
  607 <!--
  608   Creates an html file that contains a link to all package-summary.html files on
  609   each package existing on testsuites.
  610   @bug there will be a problem here, I don't know yet how to handle unnamed package :(
  611 -->
  612 <xsl:template match="metrics" mode="all.packages">
  613   <html>
  614     <head>
  615       <xsl:call-template name="create.stylesheet.link">
  616         <xsl:with-param name="package.name" select="./package/@name"/>
  617       </xsl:call-template>
  618     </head>
  619     <body>
  620       <h2><a href="overview-summary.html" target="classFrame">Home</a></h2>
  621       <h2>Packages</h2>
  622         <table width="100%">
  623           <xsl:apply-templates select=".//package[not(./@name = 'unnamed package')]" mode="all.packages">
  624             <xsl:sort select="@name"/>
  625           </xsl:apply-templates>
  626         </table>
  627     </body>
  628   </html>
  629 </xsl:template>
  630 
  631 <xsl:template match="package" mode="all.packages">
  632   <tr>
  633     <td nowrap="nowrap">
  634       <a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame">
  635         <xsl:value-of select="@name"/>
  636       </a>
  637     </td>
  638   </tr>
  639 </xsl:template>
  640 
  641 
  642 <xsl:template match="metrics" mode="overview.packages">
  643   <html>
  644     <head>
  645       <xsl:call-template name="create.stylesheet.link">
  646         <xsl:with-param name="package.name" select="''"/>
  647       </xsl:call-template>
  648     </head>
  649     <body onload="open('allclasses-frame.html','classListFrame')">
  650     <xsl:call-template name="pageHeader"/>
  651     <h3>Summary</h3>
  652     <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  653     <tr>
  654       <th><a href="metrics-reference.html#V(G)">V(G)</a></th>
  655       <th><a href="metrics-reference.html#LOC">LOC</a></th>
  656       <th><a href="metrics-reference.html#DIT">DIT</a></th>
  657       <th><a href="metrics-reference.html#NOA">NOA</a></th>
  658       <th><a href="metrics-reference.html#NRM">NRM</a></th>
  659       <th><a href="metrics-reference.html#NLM">NLM</a></th>
  660       <th><a href="metrics-reference.html#WMC">WMC</a></th>
  661       <th><a href="metrics-reference.html#RFC">RFC</a></th>
  662       <th><a href="metrics-reference.html#DAC">DAC</a></th>
  663       <th><a href="metrics-reference.html#FANOUT">FANOUT</a></th>
  664       <th><a href="metrics-reference.html#CBO">CBO</a></th>
  665       <th><a href="metrics-reference.html#LCOM">LCOM</a></th>
  666       <th><a href="metrics-reference.html#NOCL">NOCL</a></th>
  667     </tr>
  668     <xsl:apply-templates select="." mode="print.metrics"/>
  669     </table>
  670     <table border="0" width="100%">
  671     <tr>
  672     <td style="text-align: justify;">
  673     Note: Metrics evaluate the quality of software by analyzing the program source and quantifying
  674     various kind of complexity. Complexity is a common source of problems and defects in software.
  675     High complexity makes it more difficult to develop, understand, maintain, extend, test and debug
  676     a program.
  677     <p/>
  678     The primary use of metrics is to focus your attention on those parts of code that potentially are
  679     complexity hot spots. Once the complex areas your program have been uncovered, you can take remedial
  680     actions.
  681     For additional information about metrics and their meaning, please consult
  682     Metamata Metrics manual.
  683     </td>
  684     </tr>
  685     </table>
  686 
  687     <h3>Packages</h3>
  688     <table border="0" cellpadding="5" cellspacing="2" width="100%">
  689       <xsl:call-template name="all.metrics.header"/>
  690       <xsl:for-each select=".//package[not(@name = 'unnamed package')]">
  691         <xsl:sort select="@name" order="ascending"/>
  692         <xsl:apply-templates select="." mode="print.metrics"/>
  693       </xsl:for-each>
  694     </table>
  695     <!-- @bug there could some classes at this level (classes in unnamed package) -->
  696     <xsl:call-template name="pageFooter"/>
  697     </body>
  698     </html>
  699 </xsl:template>
  700 
  701 <xsl:template match="package" mode="package.summary">
  702   <HTML>
  703     <HEAD>
  704       <xsl:call-template name="create.stylesheet.link">
  705         <xsl:with-param name="package.name" select="@name"/>
  706       </xsl:call-template>
  707     </HEAD>
  708     <body onload="open('package-frame.html','classListFrame')">
  709       <xsl:call-template name="pageHeader"/>
  710       <!-- create an anchor to this package name -->
  711       <h3>Package <xsl:value-of select="@name"/></h3>
  712 
  713       <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  714         <xsl:call-template name="all.metrics.header"/>
  715         <xsl:apply-templates select="." mode="print.metrics"/>
  716       </table>
  717 
  718       <table border="0" width="100%">
  719       <tr>
  720       <td style="text-align: justify;">
  721       Note: Metrics evaluate the quality of software by analyzing the program source and quantifying
  722       various kind of complexity. Complexity is a common source of problems and defects in software.
  723       High complexity makes it more difficult to develop, understand, maintain, extend, test and debug
  724       a program.
  725       <p/>
  726       The primary use of metrics is to focus your attention on those parts of code that potentially are
  727       complexity hot spots. Once the complex areas your program have been uncovered, you can take remedial
  728       actions.
  729       For additional information about metrics and their meaning, please consult
  730       Metamata Metrics manual.
  731       </td>
  732       </tr>
  733       </table>
  734 
  735       <xsl:variable name="classes-in-package" select="$doctree/classes/class[@package = current()/@name]"/>
  736       <xsl:if test="count($classes-in-package) &gt; 0">
  737         <H3>Classes</H3>
  738         <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
  739           <xsl:call-template name="all.metrics.header"/>
  740           <xsl:for-each select="$classes-in-package">
  741                 <xsl:sort select="@name"/>
  742                 <xsl:apply-templates select="." mode="print.metrics"/>
  743           </xsl:for-each>
  744         </table>
  745       </xsl:if>
  746 
  747       <xsl:call-template name="pageFooter"/>
  748     </body>
  749   </HTML>
  750 </xsl:template>
  751 
  752 
  753 <!--
  754     transform string like a.b.c to ../../../
  755     @param path the path to transform into a descending directory path
  756 -->
  757 <xsl:template name="path">
  758   <xsl:param name="path"/>
  759   <xsl:if test="contains($path,'.')">
  760     <xsl:text>../</xsl:text>
  761     <xsl:call-template name="path">
  762       <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param>
  763     </xsl:call-template>
  764   </xsl:if>
  765   <xsl:if test="not(contains($path,'.')) and not($path = '')">
  766     <xsl:text>../</xsl:text>
  767   </xsl:if>
  768 </xsl:template>
  769 
  770 
  771 <!-- create the link to the stylesheet based on the package name -->
  772 <xsl:template name="create.stylesheet.link">
  773   <xsl:param name="package.name"/>
  774   <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>
  775 </xsl:template>
  776 
  777 
  778 <!-- Page Header -->
  779 <xsl:template name="pageHeader">
  780 
  781   <!-- jakarta logo -->
  782   <table border="0" cellpadding="0" cellspacing="0" width="100%">
  783   <tr>
  784     <td class="bannercell" rowspan="2">
  785       <a href="http://jakarta.apache.org/">
  786       <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
  787       </a>
  788     </td>
  789     <td style="text-align:right"><h2>Source Code Metrics</h2></td>
  790     </tr>
  791     <tr>
  792     <td style="text-align:right">Designed for use with <a href='http://www.webgain.com/products/quality_analyzer/'>Webgain QA/Metamata Metrics</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
  793     </tr>
  794   </table>
  795   <hr size="1"/>
  796 </xsl:template>
  797 
  798 <!-- Page Footer -->
  799 <xsl:template name="pageFooter">
  800 </xsl:template>
  801 
  802 <!-- class header -->
  803 <xsl:template name="all.metrics.header">
  804   <tr>
  805     <th width="80%">Name</th>
  806     <th nowrap="nowrap">V(G)</th>
  807     <th>LOC</th>
  808     <th>DIT</th>
  809     <th>NOA</th>
  810     <th>NRM</th>
  811     <th>NLM</th>
  812     <th>WMC</th>
  813     <th>RFC</th>
  814     <th>DAC</th>
  815     <th>FANOUT</th>
  816     <th>CBO</th>
  817     <th>LCOM</th>
  818     <th>NOCL</th>
  819   </tr>
  820 </xsl:template>
  821 
  822 <!-- method header -->
  823 <xsl:template name="method.metrics.header">
  824   <tr>
  825     <th width="80%">Name</th>
  826     <th nowrap="nowrap">V(G)</th>
  827     <th>LOC</th>
  828     <th>FANOUT</th>
  829     <th>CBO</th>
  830   </tr>
  831 </xsl:template>
  832 
  833 <!-- method information -->
  834 <xsl:template match="method" mode="print.metrics">
  835   <tr>
  836     <xsl:call-template name="alternate-row"/>
  837     <td><xsl:apply-templates select="@name"/></td>
  838     <td><xsl:apply-templates select="@vg"/></td>
  839     <td><xsl:apply-templates select="@loc"/></td>
  840     <td><xsl:apply-templates select="@fanout"/></td>
  841     <td><xsl:apply-templates select="@cbo"/></td>
  842   </tr>
  843 </xsl:template>
  844 
  845 <!-- class information -->
  846 <xsl:template match="class" mode="print.metrics">
  847   <tr>
  848     <xsl:call-template name="alternate-row"/>
  849     <td><a href="{@name}.html"><xsl:value-of select="@name"/></a></td>
  850     <td><xsl:apply-templates select="@vg"/></td>
  851     <td><xsl:apply-templates select="@loc"/></td>
  852     <td><xsl:apply-templates select="@dit"/></td>
  853     <td><xsl:apply-templates select="@noa"/></td>
  854     <td><xsl:apply-templates select="@nrm"/></td>
  855     <td><xsl:apply-templates select="@nlm"/></td>
  856     <td><xsl:apply-templates select="@wmc"/></td>
  857     <td><xsl:apply-templates select="@rfc"/></td>
  858     <td><xsl:apply-templates select="@dac"/></td>
  859     <td><xsl:apply-templates select="@fanout"/></td>
  860     <td><xsl:apply-templates select="@cbo"/></td>
  861     <td><xsl:apply-templates select="@lcom"/></td>
  862     <td><xsl:apply-templates select="@nocl"/></td>
  863   </tr>
  864 </xsl:template>
  865 
  866 <xsl:template match="file|package" mode="print.metrics">
  867   <tr>
  868     <xsl:call-template name="alternate-row"/>
  869     <td>
  870     <a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame">
  871     <xsl:value-of select="@name"/>
  872     </a>
  873     </td>
  874     <td><xsl:apply-templates select="@vg"/></td>
  875     <td><xsl:apply-templates select="@loc"/></td>
  876     <td><xsl:apply-templates select="@dit"/></td>
  877     <td><xsl:apply-templates select="@noa"/></td>
  878     <td><xsl:apply-templates select="@nrm"/></td>
  879     <td><xsl:apply-templates select="@nlm"/></td>
  880     <td><xsl:apply-templates select="@wmc"/></td>
  881     <td><xsl:apply-templates select="@rfc"/></td>
  882     <td><xsl:apply-templates select="@dac"/></td>
  883     <td><xsl:apply-templates select="@fanout"/></td>
  884     <td><xsl:apply-templates select="@cbo"/></td>
  885     <td><xsl:apply-templates select="@lcom"/></td>
  886     <td><xsl:apply-templates select="@nocl"/></td>
  887   </tr>
  888 </xsl:template>
  889 
  890 <xsl:template match="metrics" mode="print.metrics">
  891   <tr>
  892     <xsl:call-template name="alternate-row"/>
  893       <!-- the global metrics is the top package metrics -->
  894     <td><xsl:apply-templates select="./package/@vg"/></td>
  895     <td><xsl:apply-templates select="./package/@loc"/></td>
  896     <td><xsl:apply-templates select="./package/@dit"/></td>
  897     <td><xsl:apply-templates select="./package/@noa"/></td>
  898     <td><xsl:apply-templates select="./package/@nrm"/></td>
  899     <td><xsl:apply-templates select="./package/@nlm"/></td>
  900     <td><xsl:apply-templates select="./package/@wmc"/></td>
  901     <td><xsl:apply-templates select="./package/@rfc"/></td>
  902     <td><xsl:apply-templates select="./package/@dac"/></td>
  903     <td><xsl:apply-templates select="./package/@fanout"/></td>
  904     <td><xsl:apply-templates select="./package/@cbo"/></td>
  905     <td><xsl:apply-templates select="./package/@lcom"/></td>
  906     <td><xsl:apply-templates select="./package/@nocl"/></td>
  907   </tr>
  908 </xsl:template>
  909 
  910 <!-- alternated row style -->
  911 <xsl:template name="alternate-row">
  912 <xsl:attribute name="class">
  913   <xsl:if test="position() mod 2 = 1">a</xsl:if>
  914   <xsl:if test="position() mod 2 = 0">b</xsl:if>
  915 </xsl:attribute>
  916 </xsl:template>
  917 
  918 
  919 <!-- how to display the metrics with their max value -->
  920 <!-- @todo the max values must be external to the xsl -->
  921 
  922   <xsl:template match="@vg">
  923     <xsl:call-template name="display-value">
  924       <xsl:with-param name="value" select="current()"/>
  925       <xsl:with-param name="max" select="$vg.max"/>
  926     </xsl:call-template>
  927   </xsl:template>
  928 
  929   <xsl:template match="@loc">
  930     <xsl:call-template name="display-value">
  931       <xsl:with-param name="value" select="current()"/>
  932       <xsl:with-param name="max" select="$loc.max"/>
  933     </xsl:call-template>
  934   </xsl:template>
  935 
  936   <xsl:template match="@dit">
  937     <xsl:call-template name="display-value">
  938       <xsl:with-param name="value" select="current()"/>
  939       <xsl:with-param name="max" select="$dit.max"/>
  940     </xsl:call-template>
  941   </xsl:template>
  942 
  943   <xsl:template match="@noa">
  944     <xsl:call-template name="display-value">
  945       <xsl:with-param name="value" select="current()"/>
  946       <xsl:with-param name="max" select="$noa.max"/>
  947     </xsl:call-template>
  948   </xsl:template>
  949 
  950   <xsl:template match="@nrm">
  951     <xsl:call-template name="display-value">
  952       <xsl:with-param name="value" select="current()"/>
  953       <xsl:with-param name="max" select="$nrm.max"/>
  954     </xsl:call-template>
  955   </xsl:template>
  956 
  957   <xsl:template match="@nlm">
  958     <xsl:call-template name="display-value">
  959       <xsl:with-param name="value" select="current()"/>
  960       <xsl:with-param name="max" select="$nlm.max"/>
  961     </xsl:call-template>
  962   </xsl:template>
  963 
  964   <xsl:template match="@wmc">
  965     <xsl:call-template name="display-value">
  966       <xsl:with-param name="value" select="current()"/>
  967       <xsl:with-param name="max" select="$wmc.max"/>
  968     </xsl:call-template>
  969   </xsl:template>
  970 
  971   <xsl:template match="@rfc">
  972     <xsl:call-template name="display-value">
  973       <xsl:with-param name="value" select="current()"/>
  974       <xsl:with-param name="max" select="$rfc.max"/>
  975     </xsl:call-template>
  976   </xsl:template>
  977 
  978   <xsl:template match="@dac">
  979     <xsl:call-template name="display-value">
  980       <xsl:with-param name="value" select="current()"/>
  981       <xsl:with-param name="max" select="$dac.max"/>
  982     </xsl:call-template>
  983   </xsl:template>
  984 
  985   <xsl:template match="@fanout">
  986     <xsl:call-template name="display-value">
  987       <xsl:with-param name="value" select="current()"/>
  988       <xsl:with-param name="max" select="$fanout.max"/>
  989     </xsl:call-template>
  990   </xsl:template>
  991 
  992   <xsl:template match="@cbo">
  993     <xsl:call-template name="display-value">
  994       <xsl:with-param name="value" select="current()"/>
  995       <xsl:with-param name="max" select="$cbo.max"/>
  996     </xsl:call-template>
  997   </xsl:template>
  998 
  999   <xsl:template match="@lcom">
 1000     <xsl:call-template name="display-value">
 1001       <xsl:with-param name="value" select="current()"/>
 1002       <xsl:with-param name="max" select="$lcom.max"/>
 1003     </xsl:call-template>
 1004   </xsl:template>
 1005 
 1006   <xsl:template match="@nocl">
 1007     <xsl:call-template name="display-value">
 1008       <xsl:with-param name="value" select="current()"/>
 1009       <xsl:with-param name="max" select="$nocl.max"/>
 1010     </xsl:call-template>
 1011   </xsl:template>
 1012 
 1013   <xsl:template name="display-value">
 1014     <xsl:param name="value"/>
 1015     <xsl:param name="max"/>
 1016     <xsl:if test="$value > $max">
 1017       <xsl:attribute name="class">Error</xsl:attribute>
 1018     </xsl:if>
 1019     <xsl:value-of select="$value"/>
 1020   </xsl:template>
 1021 
 1022 </xsl:stylesheet>
 1023