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

checkstyle-xdoc.xsl 4.8 kB

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