Sunday, July 01, 2007

metrics.xsl for http://metrics.sourceforge.net

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:m="http://metrics.sourceforge.net/2003/Metrics-First-Flat">
<xsl:output method="html"/>
<!--
metrics.xsl
01-JUL-07
metrics XML Style Sheet by Atsushi Sano
<as AT cyberoz DOT NET>
-->
<xsl:template match="/">
<xsl:apply-templates select="m:Metrics" />
</xsl:template>

<xsl:template match="m:Metrics">
<html lang="en">
<head>
<meta http-equiv="Content-Style-Type" content="text/css"></meta>
<title>Metrics Report for <xsl:value-of select="@scope"/> as of <xsl:value-of select="@date"/></title>
<style type="text/css"><![CDATA[
<!--
.bannercell {
border: 0px;
padding: 0px;
}
body {
margin-left: 10;
margin-right: 10;
font:normal 68% verdana,arial,helvetica;
background-color:#FFFFFF;
color:#000000;
}
.a td {
background: #efefef;
}
.b td {
background: #fff;
}
.a_ng td {
background: #efefef;
color:red;
}
.b_ng td {
background: #fff;
color:red;
}
th, td {
text-align: left;
vertical-align: top;
}
th {
font-weight:bold;
background: #ccc;
color: black;
}
table, th, td {
font-size:100%;
border: none
}
table.log tr td, tr th {

}
h2 {
font-weight:bold;
font-size:140%;
margin-bottom: 5;
}
h3 {
font-size:100%;
font-weight:bold;
background: #525D76;
color: white;
text-decoration: none;
padding: 5px;
margin-right: 2px;
margin-left: 2px;
margin-bottom: 0;
}
-->]]></style>
</head>
<body>
<h1><a><xsl:attribute name="name">top</xsl:attribute>Metrics Report for <xsl:value-of select="@scope"/> as of <xsl:value-of select="@date"/></a></h1>
<hr/>
<xsl:apply-templates select="m:Cycle" />
<hr/>
<h1>Metric</h1>
<table>
<thead><tr><th>id</th><th>description</th><th>limit</th><th>Total</th><th>Mean</th><th>Std. Dev.</th><th>Value Max</th><th>count</th><th>count(limit over)</th><th>Source causing Maximum</th><th>method</th></tr></thead>
<tbody>
<xsl:for-each select="m:Metric">
<tr>
<xsl:call-template name="alternated-row"/>
<td><a><xsl:attribute name="href">#<xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="@id" /></a></td>
<td><xsl:value-of select="@description" /></td>
<td><xsl:value-of select="@max" /></td>
<td>
<xsl:choose>
<xsl:when test="@id='TLOC'">
<xsl:value-of select="m:Value/@value" />
</xsl:when>
<xsl:when test="@id='NOP'">
<xsl:value-of select="m:Value/@value" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="m:Values/@total" />
</xsl:otherwise>
</xsl:choose>
</td>
<td><xsl:value-of select="m:Values/@avg" /></td>
<td><xsl:value-of select="m:Values/@stddev" /></td>
<td><xsl:value-of select="m:Values/@max" /></td>
<td><xsl:value-of select="count(m:Values/m:Value)" /></td>
<td><xsl:if test="boolean(@max)"><xsl:call-template name="alternate-count"><xsl:with-param name="max" select="@max" /></xsl:call-template></xsl:if></td>
<td><xsl:value-of select="m:Values/m:Value[1]/@package" /></td>
<td><xsl:if test="m:Values/m:Value[1]/@package!=m:Values/m:Value[1]/@name"><xsl:value-of select="m:Values/m:Value[1]/@name" /></xsl:if></td>
</tr>
</xsl:for-each>
</tbody>
</table>
<xsl:apply-templates select="m:Metric" />
<hr/>
<div style="font-size:large;font-weight:bold;">Powered by <span style="font-style:italic;">metrics.xsl</span>.</div>
</body></html>
</xsl:template>

<xsl:template match="m:Cycle">
<h1>Cycle</h1>
<table>
<thead><tr><th>name</th><th>nodes</th><th>diameter</th></tr></thead>
<tbody><tr><td><xsl:value-of select="@name"/></td><td><xsl:value-of select="@nodes"/></td><td><xsl:value-of select="@diameter"/></td></tr></tbody></table>
<table><thead><tr><th>Packages</th></tr></thead>
<tbody>
<xsl:for-each select="m:Package">
<tr><td><xsl:value-of select="." /></td></tr>
</xsl:for-each>
</tbody></table>
</xsl:template>

<xsl:template match="m:Metric">
<h1><a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="@id"/></a></h1>
<div><xsl:value-of select="@description"/></div>
<xsl:choose>
<xsl:when test="@id='TLOC'">
<xsl:apply-templates select="m:Value" />
</xsl:when>
<xsl:when test="@id='NOP'">
<xsl:apply-templates select="m:Value" />
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="m:Values" />
</xsl:otherwise>
</xsl:choose>
<a><xsl:attribute name="href">#top</xsl:attribute>back to top</a>
</xsl:template>

<xsl:template match="m:Values">
<h2>Values</h2>
<table>
<xsl:attribute name="summary">values-<xsl:value-of select="../@id"/></xsl:attribute>
<thead><tr><th>per</th><th>total</th><th>avg</th><th>stddev</th><th>max</th></tr></thead>
<tbody><tr>
<td><xsl:value-of select="@per"/></td>
<td><xsl:value-of select="@total"/></td>
<td><xsl:value-of select="@avg"/></td>
<td><xsl:value-of select="@stddev"/></td>
<td><xsl:value-of select="@max"/></td>
</tr></tbody>
</table>
<h2>Value</h2>
<table>
<xsl:attribute name="summary"><xsl:value-of select="../@id"/></xsl:attribute>
<tr><th>name</th><th>source</th><th>package</th><th>value</th></tr>
<xsl:for-each select="m:Value">
<tr>
<xsl:call-template name="alternated-row"/>
<td><xsl:value-of select="@name" /></td><td><xsl:value-of select="@source" /></td><td><xsl:value-of select="@package" /></td><td><xsl:value-of select="@value" /></td></tr>
</xsl:for-each>
</table>
</xsl:template>

<xsl:template match="m:Value">
<h2>Value</h2>
<table>
<tr><th>value</th></tr>
<tr><td><xsl:value-of select="@value" /></td></tr>
</table>
</xsl:template>

<xsl:template name="alternated-row">
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="boolean(@max) and boolean(m:Values/@max) and m:Values/@max&gt;=@max">
<xsl:if test="position() mod 2 = 1">a_ng</xsl:if>
<xsl:if test="position() mod 2 = 0">b_ng</xsl:if>
</xsl:when>
<xsl:when test="boolean(../../@max) and boolean(@value) and @value&gt;=../../@max">
<xsl:if test="position() mod 2 = 1">a_ng</xsl:if>
<xsl:if test="position() mod 2 = 0">b_ng</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:if test="position() mod 2 = 1">a</xsl:if>
<xsl:if test="position() mod 2 = 0">b</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:template>

<xsl:template name="alternate-count">
<xsl:param name="max">dummy</xsl:param>
<xsl:value-of select="count(m:Values/m:Value[@value&gt;=$max])"/>
</xsl:template>

</xsl:stylesheet>

No comments:

# スクラムマスターを雇う時に聞いてみるとよい47個の質問

  # スクラムマスターを雇う時に聞いてみるとよい47個の質問 スクラムマスターへの質問というPDFがあるので、回答してみた。 定期的に自分の回答がどう変わっていくのか楽しみだ。 Scrum Master Interview Questions: Free Download of...