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.

checkstyle-xdoc.xsl 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  2. xmlns:lxslt="http://xml.apache.org/xslt"
  3. xmlns:redirect="org.apache.xalan.lib.Redirect"
  4. extension-element-prefixes="redirect">
  5. <!--
  6. Copyright 2003-2004 The Apache Software Foundation
  7. Licensed under the Apache License, Version 2.0 (the "License");
  8. you may not use this file except in compliance with the License.
  9. You may obtain a copy of the License at
  10. http://www.apache.org/licenses/LICENSE-2.0
  11. Unless required by applicable law or agreed to in writing, software
  12. distributed under the License is distributed on an "AS IS" BASIS,
  13. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. See the License for the specific language governing permissions and
  15. limitations under the License.
  16. -->
  17. <xsl:output method="xml" indent="yes"/>
  18. <xsl:decimal-format decimal-separator="." grouping-separator="," />
  19. <xsl:param name="output.dir" select="'.'"/>
  20. <xsl:param name="basedir" select="'.'"/>
  21. <xsl:template match="checkstyle">
  22. <document>
  23. <properties>
  24. <title>Checkstyle Audit</title>
  25. </properties>
  26. <body>
  27. <xsl:apply-templates select="." mode="summary"/>
  28. <!-- File list part -->
  29. <xsl:apply-templates select="." mode="filelist"/>
  30. <xsl:apply-templates select="file[count(error) != 0]"/>
  31. </body>
  32. </document>
  33. </xsl:template>
  34. <xsl:template match="checkstyle" mode="filelist">
  35. <section name="Files">
  36. <table>
  37. <tr>
  38. <th>Name</th>
  39. <th>Errors</th>
  40. </tr>
  41. <xsl:apply-templates select="file[count(error) != 0]" mode="filelist">
  42. <xsl:sort select="count(error)" order="descending" data-type="number"/>
  43. </xsl:apply-templates>
  44. </table>
  45. </section>
  46. </xsl:template>
  47. <xsl:template match="file" mode="filelist">
  48. <tr>
  49. <xsl:call-template name="alternated-row"/>
  50. <td nowrap="nowrap">
  51. <a>
  52. <xsl:attribute name="href">
  53. <xsl:text>files</xsl:text><xsl:value-of select="substring-after(@name, $basedir)"/><xsl:text>.html</xsl:text>
  54. </xsl:attribute>
  55. <xsl:value-of select="substring-after(@name, $basedir)"/>
  56. </a>
  57. </td>
  58. <td><xsl:value-of select="count(error)"/></td>
  59. </tr>
  60. </xsl:template>
  61. <xsl:template match="file">
  62. <redirect:write file="{$output.dir}/files{substring-after(@name, $basedir)}.xml">
  63. <document>
  64. <properties>
  65. <title>Checkstyle Audit</title>
  66. </properties>
  67. <body>
  68. <section name="Details for {substring-after(@name, $basedir)}">
  69. <table>
  70. <tr>
  71. <th>Error Description</th>
  72. <th>Line</th>
  73. </tr>
  74. <xsl:for-each select="error">
  75. <tr>
  76. <xsl:call-template name="alternated-row"/>
  77. <td><a title="{@source}"><xsl:value-of select="@message"/></a></td>
  78. <td><xsl:value-of select="@line"/></td>
  79. </tr>
  80. </xsl:for-each>
  81. </table>
  82. </section>
  83. </body>
  84. </document>
  85. </redirect:write>
  86. </xsl:template>
  87. <xsl:template match="checkstyle" mode="summary">
  88. <section name="Summary">
  89. <xsl:variable name="fileCount" select="count(file)"/>
  90. <xsl:variable name="errorCount" select="count(file/error)"/>
  91. <xsl:variable name="fileErrorCount" select="count(file[count(error) != 0])"/>
  92. <table>
  93. <tr>
  94. <th>Files</th>
  95. <th>Files With Errors</th>
  96. <th>Errors</th>
  97. </tr>
  98. <tr>
  99. <xsl:call-template name="alternated-row"/>
  100. <td><xsl:value-of select="$fileCount"/></td>
  101. <td><xsl:value-of select="$fileErrorCount"/></td>
  102. <td><xsl:value-of select="$errorCount"/></td>
  103. </tr>
  104. </table>
  105. </section>
  106. </xsl:template>
  107. <xsl:template name="alternated-row">
  108. <xsl:attribute name="class">
  109. <xsl:if test="position() mod 2 = 1">oddrow</xsl:if>
  110. <xsl:if test="position() mod 2 = 0">evenrow</xsl:if>
  111. </xsl:attribute>
  112. </xsl:template>
  113. </xsl:stylesheet>