You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pmd.xslt 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- $Header: /cvsroot/pmd/pmd/etc/xslt/pmd-report-per-class.xslt,v 1.1 2005/06/28 13:51:49 tomcopeland Exp $ -->
  3. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4. <xsl:output method="html" encoding="UTF-8" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
  5. doctype-system="http://www.w3.org/TR/html4/loose.dtd" indent="yes"/>
  6. <xsl:template name="message">
  7. <xsl:value-of disable-output-escaping="yes" select="."/>
  8. </xsl:template>
  9. <xsl:template name="priorityDiv">
  10. <xsl:if test="@priority = 1">p1</xsl:if>
  11. <xsl:if test="@priority = 2">p2</xsl:if>
  12. <xsl:if test="@priority = 3">p3</xsl:if>
  13. <xsl:if test="@priority = 4">p4</xsl:if>
  14. <xsl:if test="@priority = 5">p5</xsl:if>
  15. </xsl:template>
  16. <xsl:template match="pmd">
  17. <html>
  18. <head>
  19. <title>PMD Report</title>
  20. <script type="text/javascript" src="sorttable.js"></script>
  21. <style type="text/css">
  22. body { margin-left: 2%; margin-right: 2%; font:normal verdana,arial,helvetica; color:#000000; }
  23. table { border: 0; border-collapse: collapse; width: 100%; }
  24. table th { text-align: center; }
  25. table.sortable tr th { font-weight: normal; text-align:left; background:#a6caf0; }
  26. table.sortable tr td { background:#eeeee0; }
  27. table.classcount tr th { font-weight: normal; text-align:left; background:#a6caf0; }
  28. table.classcount tr td { background:#eeeee0; }
  29. table.summary tr th { font-weight: normal; text-align:center; background:#a6caf0; }
  30. table.summary tr td { background:#eeeee0;}
  31. .p1 { background:#FF9999; }
  32. .p2 { background:#FFCC66; }
  33. .p3 { background:#FFFF99; }
  34. .p4 { background:#99FF99; }
  35. .p5 { background:#9999FF; }
  36. </style>
  37. </head>
  38. <body>
  39. <table class="summary">
  40. <tr><th colspan="6">Summary</th></tr>
  41. <tr>
  42. <th>Total</th>
  43. <th>Priority 1</th>
  44. <th>Priority 2</th>
  45. <th>Priority 3</th>
  46. <th>Priority 4</th>
  47. <th>Priority 5</th>
  48. </tr>
  49. <tr>
  50. <td><xsl:value-of select="count(//violation)"/></td>
  51. <td><div class="p1"><xsl:value-of select="count(//violation[@priority = 1])"/></div></td>
  52. <td><div class="p2"><xsl:value-of select="count(//violation[@priority = 2])"/></div></td>
  53. <td><div class="p3"><xsl:value-of select="count(//violation[@priority = 3])"/></div></td>
  54. <td><div class="p4"><xsl:value-of select="count(//violation[@priority = 4])"/></div></td>
  55. <td><div class="p5"><xsl:value-of select="count(//violation[@priority = 5])"/></div></td>
  56. </tr>
  57. </table>
  58. <br />
  59. <table class="sortable">
  60. <xsl:attribute name="id">sortable_id_0</xsl:attribute>
  61. <tr>
  62. <th>File</th>
  63. <th>Total</th>
  64. <th>Priority 1</th>
  65. <th>Priority 2</th>
  66. <th>Priority 3</th>
  67. <th>Priority 4</th>
  68. <th>Priority 5</th>
  69. </tr>
  70. <xsl:for-each select="file">
  71. <xsl:sort data-type="number" order="descending" select="count(violation)"/>
  72. <xsl:variable name="filename" select="@name"/>
  73. <tr>
  74. <td><a><xsl:attribute name="href">#<xsl:value-of disable-output-escaping="yes" select="substring-before(translate(@name,'/','.'),'.java')"/>
  75. </xsl:attribute>
  76. <xsl:value-of disable-output-escaping="yes" select="substring-before(translate(@name,'/','.'),'.java')"/></a>
  77. </td>
  78. <td><xsl:value-of select="count(violation)"/></td>
  79. <td><div class="p1"><xsl:value-of select="count(violation[@priority = 1])"/></div></td>
  80. <td><div class="p2"><xsl:value-of select="count(violation[@priority = 2])"/></div></td>
  81. <td><div class="p3"><xsl:value-of select="count(violation[@priority = 3])"/></div></td>
  82. <td><div class="p4"><xsl:value-of select="count(violation[@priority = 4])"/></div></td>
  83. <td><div class="p5"><xsl:value-of select="count(violation[@priority = 5])"/></div></td>
  84. </tr>
  85. </xsl:for-each>
  86. </table>
  87. <hr/>
  88. <xsl:for-each select="file">
  89. <xsl:sort data-type="number" order="descending" select="count(violation)"/>
  90. <xsl:variable name="filename" select="@name"/>
  91. <H3><xsl:attribute name="id"><xsl:value-of disable-output-escaping="yes" select="substring-before(translate(@name,'/','.'),'.java')"/>
  92. </xsl:attribute>
  93. <xsl:value-of disable-output-escaping="yes" select="substring-before(translate(@name,'/','.'),'.java')"/></H3>
  94. <table class="sortable"><xsl:attribute name="id">sortable_id_<xsl:value-of select="position()"/></xsl:attribute>
  95. <tr>
  96. <th>Prio</th>
  97. <th>Line</th>
  98. <th>Method</th>
  99. <th align="left">Description</th>
  100. </tr>
  101. <xsl:for-each select="violation">
  102. <tr>
  103. <td style="padding: 3px" align="right"><div><xsl:attribute name="class"><xsl:call-template name="priorityDiv"/></xsl:attribute><xsl:value-of disable-output-escaping="yes" select="@priority"/></div></td>
  104. <td style="padding: 3px" align="right"><xsl:value-of disable-output-escaping="yes" select="@line"/></td>
  105. <td style="padding: 3px" align="left"><xsl:value-of disable-output-escaping="yes" select="@method"/></td>
  106. <td style="padding: 3px" align="left" width="100%"><xsl:if test="@externalInfoUrl"><a><xsl:attribute name="href"><xsl:value-of select="@externalInfoUrl"/></xsl:attribute><xsl:call-template name="message"/></a></xsl:if><xsl:if test="not(@externalInfoUrl)"><xsl:call-template name="message"/></xsl:if></td>
  107. </tr>
  108. </xsl:for-each>
  109. </table>
  110. <table border="0" width="100%" class="classcount">
  111. <tr>
  112. <th>Total number of violations for this class: <xsl:value-of select="count(violation)"/></th>
  113. </tr>
  114. </table>
  115. <br/>
  116. </xsl:for-each>
  117. <p>Report generated at: <xsl:value-of select="@timestamp"/></p>
  118. </body>
  119. </html>
  120. </xsl:template>
  121. </xsl:stylesheet>