1 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
\r
2 <xsl:output method="html" indent="yes"/>
\r
3 <xsl:decimal-format decimal-separator="." grouping-separator=","/>
\r
5 Checkstyle XML Style Sheet by Daniel Grenner
\r
6 <daniel DOT grenner AT enea DOT se>
\r
7 This stylesheet groups the errors by author name, if used in combination
\r
8 with the WriteTag check:
\r
10 <module name="WriteTag">
\r
11 <property name="tag" value="@author"/>
\r
12 <property name="tagFormat" value="\S"/>
\r
13 <property name="severity" value="ignore"/>
\r
16 The output contains both error and warning messages.
\r
17 Files without errors or warnings are not included.
\r
18 This stylesheet is based on checkstyle-noframes.xsl.
\r
21 <xsl:key name="keyAuthorID" match="//file/error[contains(@message,'@author')]" use="@message" />
\r
22 <xsl:key name="keySeverityID" match="//file/error" use="@severity" />
\r
23 <xsl:template match="checkstyle">
\r
26 <style type="text/css">
\r
34 font:normal 68% verdana,arial,helvetica;
\r
35 background-color:#FFFFFF;
\r
39 background: #efefef;
\r
46 vertical-align: top;
\r
57 table.log tr td, tr th {
\r
68 background: #525D76;
\r
70 text-decoration: none;
\r
80 <!-- jakarta logo -->
\r
81 <table border="0" cellpadding="0" cellspacing="0" width="100%">
\r
83 <td class="bannercell" rowspan="2">
\r
84 <!--a href="http://jakarta.apache.org/">
\r
85 <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
\r
88 <td class="text-align:right">
\r
89 <h2>CheckStyle Audit</h2>
\r
93 <td class="text-align:right">Designed for use with <a href="http://checkstyle.sourceforge.net/">CheckStyle</a> and <a href="http://jakarta.apache.org">Ant</a>.</td>
\r
98 <!-- Summary part -->
\r
99 <xsl:apply-templates select="." mode="summary"/>
\r
100 <hr size="1" width="100%" align="left"/>
\r
102 <!-- Author List part -->
\r
103 <xsl:apply-templates select="." mode="authorlist"/>
\r
104 <hr size="1" width="100%" align="left"/>
\r
106 <!-- For each package create its part -->
\r
107 <xsl:for-each select="file">
\r
108 <xsl:sort select="./error[contains(@message,'@author=')]/@message"/>
\r
109 <xsl:apply-templates select="."/>
\r
113 <hr size="1" width="100%" align="left"/>
\r
117 <xsl:template match="checkstyle" mode="summary">
\r
119 <xsl:variable name="fileCount" select="count(file)"/>
\r
120 <xsl:variable name="errorCount" select="count(key('keySeverityID', 'error'))"/>
\r
121 <xsl:variable name="warningCount" select="count(key('keySeverityID', 'warning'))"/>
\r
122 <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
\r
129 <xsl:call-template name="alternated-row"/>
\r
131 <xsl:value-of select="$fileCount"/>
\r
134 <xsl:value-of select="$errorCount"/>
\r
137 <xsl:value-of select="$warningCount"/>
\r
142 <xsl:template match="checkstyle" mode="authorlist">
\r
145 <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
\r
152 <!-- Process each Author -->
\r
153 <xsl:for-each select="file/error[generate-id(.) = generate-id(key('keyAuthorID', @message)[1])]">
\r
154 <xsl:sort select="@message" />
\r
156 <xsl:variable name="authorFull" select="@message"/>
\r
157 <xsl:variable name="author" select="substring-after($authorFull,'@author=')"/>
\r
158 <xsl:variable name="errors" select="count(key('keyAuthorID', @message)/../error[@severity='error'])"/>
\r
159 <xsl:variable name="warnings" select="count(key('keyAuthorID', @message)/../error[@severity='warning'])"/>
\r
160 <xsl:if test = "not ($author='' or ($errors + $warnings = 0))">
\r
162 <xsl:call-template name="alternated-row"/>
\r
164 <a href="#{$author}">
\r
165 <xsl:value-of select="$author"/>
\r
168 <td><xsl:value-of select="$errors"/></td>
\r
169 <td><xsl:value-of select="$warnings"/></td>
\r
177 <xsl:template match="file">
\r
178 <xsl:variable name="errorCount" select="count(error[@severity='error']) + count(error[@severity='warning'])"/>
\r
179 <xsl:if test="not ($errorCount=0)">
\r
181 <xsl:variable name="author" select="substring-after(./error[contains(@message,'@author')]/@message,'@author=')"/>
\r
183 <a name="#{$author}"/>
\r
184 <h3>File <xsl:value-of select="@name"/>
\r
186 Author <xsl:value-of select="$author"/>
\r
188 <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
\r
190 <th>Error Description</th>
\r
193 <xsl:for-each select="error[not(@severity='info')]">
\r
194 <xsl:sort select="@line" data-type="number"/>
\r
196 <xsl:call-template name="alternated-row"/>
\r
198 <xsl:value-of select="@message"/>
\r
201 <xsl:value-of select="@line"/>
\r
206 <a href="#top">Back to top</a>
\r
211 <xsl:template name="basename">
\r
212 <xsl:param name="path"/>
\r
214 <xsl:when test="contains($path, '\')">
\r
215 <xsl:call-template name="basename">
\r
216 <xsl:with-param name="path">substring-after($path, '\')</xsl:with-param>
\r
217 </xsl:call-template>
\r
220 <xsl:value-of select="$path"/>
\r
226 <xsl:template name="alternated-row">
\r
227 <xsl:attribute name="class"><xsl:if test="position() mod 2 = 1">a</xsl:if><xsl:if test="position() mod 2 = 0">b</xsl:if></xsl:attribute>
\r