PageRenderTime 67ms CodeModel.GetById 60ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/FxCop/Xml/FxCopReportExcludes.xsl

http://github.com/agross/netopenspace
Extensible Stylesheet Language Transformations | 376 lines | 339 code | 37 blank | 0 comment | 0 complexity | 573a5874afd92a61b3e793970cc4024e MD5 | raw file
  1<?xml version="1.0"?>
  2<xsl:stylesheet version="1.0"
  3                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  4                xmlns="http://www.w3.org/TR/xhtml1/strict">
  5
  6<xsl:template match="/FxCopReport">
  7    <html>
  8    <head><title>Analysis Report</title></head>
  9    <style>
 10        #Title {font-family: Verdana; font-size: 14pt; color: black; font-weight: bold}
 11        .ColumnHeader {font-family: Verdana; font-size: 8pt; background-color:white; color: black}
 12        .CriticalError {font-family: Verdana; font-size: 8pt; color: darkred; font-weight: bold; text-align: center}
 13        .Error {font-family: Verdana; font-size: 8pt; color: royalblue; font-weight: bold; text-align: center}
 14        .CriticalWarning {font-family: Verdana; font-size: 8pt; color: green; font-weight: bold; text-align: center}
 15        .Warning {font-family: Verdana; font-size: 8pt; color: darkgray; font-weight: bold; text-align: center}
 16        .Information {font-family: Verdana; font-size: 8pt; color: black; font-weight: bold; text-align: center}
 17
 18        .PropertyName {font-family: Verdana; font-size: 8pt; color: black; font-weight: bold}
 19        .PropertyContent {font-family: Verdana; font-size: 8pt; color: black}
 20        .NodeIcon { font-family: WebDings; font-size: 12pt; color: navy; padding-right: 5;}
 21        .MessagesIcon { font-family: WebDings; font-size: 12pt; color: red;}
 22        .RuleDetails { padding-top: 10;}
 23        .SourceCode { background-color:#DDDDFF; }
 24        .RuleBlock { background-color:#EEEEFF; }
 25        .MessageNumber { font-family: Verdana; font-size: 10pt; color: darkred; }
 26        .MessageBlock { font-family: Verdana; font-size: 10pt; color: darkred; }
 27        .Resolution {font-family: Verdana; font-size: 8pt; color: black; }        
 28        .NodeLine { font-family: Verdana; font-size: 9pt;}
 29        .Note { font-family: Verdana; font-size: 9pt; color:black; background-color: #DDDDFF; }
 30        .NoteUser { font-family: Verdana; font-size: 9pt; font-weight: bold; }
 31        .NoteTime { font-family: Verdana; font-size: 8pt; font-style: italic; }
 32        .Button { font-family: Verdana; font-size: 9pt; color: blue; background-color: #EEEEEE; }
 33    </style>
 34    <script>
 35        function ViewState(blockId) 
 36        { 
 37           var block = document.getElementById(blockId); 
 38           if (block.style.display=='none')
 39           { 
 40              block.style.display='block'; 
 41           }
 42           else
 43           { 
 44              block.style.display='none'; 
 45           } 
 46        } 
 47       
 48        function SwitchAll(how)
 49        {          
 50           var nodes = document.getElementsByTagName("div"); 
 51           for (i = 0; i != nodes.length;i++)
 52           {    
 53              var block = nodes[i]; 
 54              if (block != null)
 55              { 
 56                 if (block.className == 'NodeDiv' 
 57                     || block.className == 'MessageBlockDiv'
 58                     || block.className == 'MessageDiv') 
 59                 { 
 60                    block.style.display=how; 
 61                 }                
 62              } 
 63           } 
 64        } 
 65
 66        function ExpandAll()
 67        { 
 68           SwitchAll('block'); 
 69        } 
 70       
 71        function CollapseAll() 
 72        { 
 73           SwitchAll('none'); 
 74        } 
 75    </script>
 76    <body bgcolor="white" alink="Black" vlink="Black" link="Black">
 77
 78    <!-- Report Title -->
 79    <div id="Title">
 80        FxCop <xsl:value-of select="@Version"/> Analysis Report
 81    </div>
 82    <br/>
 83    <table>
 84        <tr>
 85            <td class="Button">
 86                <a onClick="ExpandAll();">Expand All</a>
 87            </td>
 88            <td class="Button">
 89                <a onClick="CollapseAll();">Collapse All</a>
 90            </td>
 91        </tr>
 92    </table>    
 93    <br/>
 94    <xsl:apply-templates select="Namespaces"/>
 95    <xsl:choose>
 96        <xsl:when test="Namespaces">
 97            <hr/>
 98        </xsl:when>
 99    </xsl:choose>
100    <xsl:apply-templates select="Targets"/>
101    </body>
102    </html>
103</xsl:template>
104
105<xsl:template match="*">
106<xsl:choose>
107    <xsl:when test="@Name or name()='Resources'">
108        <xsl:variable name="MessageCount" select="count(.//Message[@Status='Excluded'])"/>
109        <xsl:choose>
110            <xsl:when test="$MessageCount > 0">
111                <xsl:variable name="nodeId" select="generate-id()"/>
112                <div class="NodeLine">
113
114                    <xsl:attribute name="onClick">
115                        javascript:ViewState('<xsl:value-of select="$nodeId"/>');
116                    </xsl:attribute>
117                    
118                    <!-- Display Icon -->
119                    <xsl:choose>
120                        <xsl:when test="name()='Member' and @Kind='Method'">
121                            <nobr class="NodeIcon">&#x0061;</nobr>    
122                        </xsl:when>
123                        <xsl:when test="name()='Member' and @Kind='Constructor'">
124                            <nobr class="NodeIcon">&#x003D;</nobr>    
125                        </xsl:when>
126                        <xsl:when test="name()='Member' and @Kind='Property'">
127                            <nobr class="NodeIcon">&#x0098;</nobr>    
128                        </xsl:when>
129                        <xsl:when test="name()='Member' and @Kind='Event'">
130                            <nobr class="NodeIcon">&#x007E;</nobr>    
131                        </xsl:when>
132                        <xsl:when test="name()='Member' and @Kind='Field'">
133                            <nobr class="NodeIcon">&#x00EB;</nobr>    
134                        </xsl:when>
135                        <xsl:when test="name()='Type' and @Kind='Class'">
136                            <nobr class="NodeIcon">&#x003C;</nobr>    
137                        </xsl:when>
138                        <xsl:when test="name()='Type' and @Kind='Interface'">
139                            <nobr class="NodeIcon">&#x003C;</nobr>    
140                        </xsl:when>
141                        <xsl:when test="name()='Type' and @Kind='Delegate'">
142                            <nobr class="NodeIcon">&#x003C;</nobr>    
143                        </xsl:when>
144                        <xsl:when test="name()='Type' and @Kind='Enum'">
145                            <nobr class="NodeIcon">&#x003C;</nobr>    
146                        </xsl:when>
147                        <xsl:when test="name()='Type' and @Kind='Struct'">
148                            <nobr class="NodeIcon">&#x003C;</nobr>    
149                        </xsl:when>
150                        <xsl:when test="name()='Namespace'">
151                            <nobr style="color: navy;">{} </nobr>    
152                        </xsl:when>
153                        <xsl:when test="name()='Target'">
154                            <nobr class="NodeIcon">&#x0032;</nobr>    
155                        </xsl:when>
156                        <xsl:when test="name()='Module'">
157                            <nobr class="NodeIcon">&#x0031;</nobr>    
158                        </xsl:when>
159                        <xsl:when test="name()='Resource'">
160                            <nobr class="NodeIcon">&#x009D;</nobr>    
161                        </xsl:when>
162                        <xsl:when test="name()='Resources'">
163                            <nobr class="NodeIcon">&#x00CC;</nobr>    
164                        </xsl:when>
165                        <xsl:otherwise>
166                            [<xsl:value-of select="name()"/>]    
167                        </xsl:otherwise>
168                    </xsl:choose>
169                    
170                    <xsl:choose>
171                        <xsl:when test="name()='Resources'">
172                            <xsl:value-of select="name()"/>
173                        </xsl:when>
174                        <xsl:otherwise>
175                            <xsl:value-of select="@Name"/>
176                        </xsl:otherwise>
177                    </xsl:choose>
178                    <nobr class="MessageNumber">
179                        (<xsl:value-of select="$MessageCount"/>)
180                    </nobr>
181                </div>
182                
183                <div class="NodeDiv" style="display: none; position: relative; padding-left: 11;">
184                    <xsl:attribute name="id">
185                        <xsl:value-of select="$nodeId"/>
186                    </xsl:attribute>
187
188                    <xsl:apply-templates />
189                </div>
190
191            </xsl:when>
192        </xsl:choose>
193    </xsl:when>
194    <xsl:otherwise>
195        <xsl:apply-templates />
196    </xsl:otherwise>
197</xsl:choose>
198</xsl:template>
199
200<xsl:template match="Messages">
201    <xsl:variable name="MessageBlockId" select="generate-id()"/>        
202    <div class="MessageBlock">
203        <xsl:attribute name="onClick">
204            javascript:ViewState('<xsl:value-of select="$MessageBlockId"/>');
205        </xsl:attribute>
206        <nobr class="MessagesIcon">&#x0040;</nobr>
207        <xsl:variable name="MessageCount" select="count(Message[@Status='Excluded'])"/>
208        <xsl:value-of select="$MessageCount"/>
209            Message<xsl:choose><xsl:when test="$MessageCount > 1">s</xsl:when></xsl:choose>
210            for 
211            <xsl:value-of select="../@Name"/>
212    </div>
213    <div class="MessageBlockDiv" style="display: none; position: relative; padding-left: 5;">
214        <xsl:attribute name="id">
215            <xsl:value-of select="$MessageBlockId"/>
216        </xsl:attribute>
217
218        <table width="100%">
219            <tr>
220                <td class="ColumnHeader">Message Level</td>
221                <td class="ColumnHeader">Certainty</td>
222                <td class="ColumnHeader" width="100%">Resolution</td>
223            </tr>
224        <xsl:apply-templates select="Message[@Status='Excluded']"/>
225        </table>
226    </div>
227        
228</xsl:template>
229
230<xsl:template match="Message">
231
232    <!-- Message Row -->
233
234    <xsl:variable name="messageId" select="generate-id()"/>
235    <xsl:variable name="rulename" select="TypeName"/>
236
237        <xsl:apply-templates select="Issue" >
238                <xsl:with-param name="messageId"><xsl:value-of select="$messageId"/></xsl:with-param>
239        </xsl:apply-templates>
240
241    <tr>
242        <td colspan="3">
243            <div class="MessageDiv" style="display: none">
244                <xsl:attribute name="id">
245                    <xsl:value-of select="$messageId"/>
246                </xsl:attribute>
247
248                <!--- Rule Details  -->
249                <table width="100%" class="RuleBlock">
250                                        <xsl:apply-templates select="Notes" mode="notes"/>
251                    <xsl:apply-templates select="/FxCopReport/Rules/Rule[@TypeName=$rulename]" mode="ruledetails" />
252                </table>
253            </div>
254        </td>        
255    </tr>
256</xsl:template>    
257
258<xsl:template match="Issue">
259<xsl:param name="messageId"></xsl:param>
260    <tr>
261        <xsl:attribute name="onClick">
262            javascript:ViewState('<xsl:value-of select="$messageId"/>');
263        </xsl:attribute>
264
265        <xsl:attribute name="bgcolor">
266            <xsl:choose>
267                <xsl:when test="position() mod 2 = 1">#EEEEEE</xsl:when>
268                <xsl:otherwise>white</xsl:otherwise>
269            </xsl:choose>
270        </xsl:attribute>
271
272        <td valign="top">
273            <xsl:attribute name="class"><xsl:value-of select="@Level" /></xsl:attribute>
274            <xsl:value-of select="@Level" />
275        </td>
276        <td valign="top">
277            <xsl:attribute name="class"><xsl:value-of select="@Level" /></xsl:attribute>
278            <xsl:value-of select="@Certainty" />
279        </td>
280        <td class="Resolution" valign="top">
281            <xsl:value-of select="text()" />
282        </td>
283    </tr>
284    <xsl:if test="@Path">
285    <tr class="SourceCode">
286        <td class="PropertyName">Source:</td>
287        <td class="PropertyContent" colspan="2">
288            <a>
289                <xsl:attribute name="href">
290                    <xsl:value-of select="@Path"/>\<xsl:value-of select="@File"/>
291                </xsl:attribute>
292                <xsl:value-of select="@Path"/>\<xsl:value-of select="@File"/>
293            </a>
294            (Line <xsl:value-of select="@Line"/>)
295        </td>
296    </tr>
297    </xsl:if>    
298</xsl:template>
299
300<xsl:template match="Notes" mode="notes">
301        <xsl:apply-templates select="User" mode="notes" />
302</xsl:template>
303
304<xsl:template match="User" mode="notes">
305    <tr class="Note">
306        <td class="Note">
307        <nobr class="NoteUser"><xsl:value-of select="@Name"/></nobr>
308        &#160;    
309        <xsl:apply-templates select="Note" mode="notes">
310        <xsl:with-param name="username"><xsl:value-of select="@Name"/></xsl:with-param>
311        </xsl:apply-templates>
312        </td>
313    </tr>
314</xsl:template>
315
316<xsl:template match="Note" mode="notes">
317    <xsl:param name="username"></xsl:param>
318    <xsl:variable name="id" select="@Id"/>
319    <xsl:apply-templates select="/FxCopReport/Notes/User[@Name=$username]/Note[@Id=$id]" mode="notesPointer"/>
320</xsl:template>
321
322
323
324<xsl:template match="Note" mode="notesPointer">
325        <td colspan="2" class="Note">
326        <nobr class="NoteTime">[<xsl:value-of select="@Modified"/>]</nobr>:
327        <xsl:value-of select="."/>
328        </td>        
329</xsl:template>
330
331<xsl:template match="Description" mode="ruledetails">
332    <tr>
333        <td class="PropertyName">Rule Description:</td>
334        <td class="PropertyContent"><xsl:value-of select="text()" /></td>
335    </tr>    
336</xsl:template>
337
338<xsl:template match="LongDescription" mode="ruledetails">
339    <!-- Test, don't display line if no data present -->
340    <xsl:choose>
341        <xsl:when test="text()">
342            <tr>
343                <td class="PropertyName">Long Description:</td>
344                <td class="PropertyContent"><xsl:value-of select="text()" /></td>
345            </tr>    
346        </xsl:when>
347    </xsl:choose>
348</xsl:template>
349
350<xsl:template match="File" mode="ruledetails">
351    <tr>
352        <td class="PropertyName">Rule File:</td>
353        <td class="PropertyContent"><xsl:value-of select="@Name"/> [<xsl:value-of select="@Version"/>]</td>
354    </tr>    
355</xsl:template>
356
357<xsl:template match="Rule" mode="ruledetails">
358    <tr>
359        <td class="PropertyName">Rule:</td>
360        <td class="PropertyContent"><xsl:value-of select="Name" /></td>
361    </tr>    
362    <tr>
363        <td class="PropertyName">Category:</td>
364        <td class="PropertyContent"><xsl:value-of select="Category" /></td>
365    </tr>    
366    <tr>
367        <td class="PropertyName">Check Id:</td>
368        <td class="PropertyContent"><xsl:value-of select="CheckId" /></td>
369    </tr>    
370    <xsl:apply-templates select="Description" mode="ruledetails" />
371    <xsl:apply-templates select="File" mode="ruledetails" />
372</xsl:template>
373
374<!-- End Rule Details -->
375
376</xsl:stylesheet>