kati: Apache Ant XSLT Task wirft eine Exception

Beitrag lesen

Hallo Christian,

danke für Dein Feedback. Ich beabsichtige ein zuvor generiertes XML in HTML zu überführen,
dafür habe ich einen Task eingerichtet, der zunächst das XML-Dokument erzeugt. Es ist übrigens
ein Standardbeispiel, nichts Ausgefallenes, siehe auch die Seite http://checkstyle.sourceforge.net/anttask.html.

Das Ant-Script schaut so aus:

<project name="checkstyle" default="checkstyle" basedir="." xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
  <!-- checkstyle specific properties -->
  <!-- svn specific properties -->
  <!-- load taskdef for checkstyle -->
  <taskdef resource="checkstyletask.properties" classpath="${checkstyle.jar}"/>
  <!-- TARGET: checkstyle -->
  <target name="checkstyle" description="Generates a report of code convention violations.">
    <cs:checkstyle config="sun_checks.xml" failureProperty="checkstyle.failure" failOnViolation="false">
      <formatter type="xml" tofile="checkstyle_report.xml"/>
      <fileset dir="${svn.checkout.tmp}" casesensitive="yes">
        <filename name="**/trunk/**/*.java"/>
      </fileset>
    </cs:checkstyle>
    <xslt in="checkstyle_report.xml" out="checkstyle_report.html" style="contrib/checkstyle-simple.xsl"/>
  </target>
</project>

Das erzeugte XML-File (erzgeugt durch cs:checkstyle) sieht etwa so aus:

<checkstyle version="5.0-beta01">
<file name="/data/Test.java">
<error line="0" severity="error" message="Missing package-info.java file." source="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck"/>
</file>
</checkstyle>

Das zugehörige XSL:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
    <head>
    <title>Sun Coding Style Violations</title>
    </head>
    <body bgcolor="#FFFFEF">
    <p><b>Coding Style Check Results</b></p>
    <table border="1" cellspacing="0" cellpadding="2">
 <tr bgcolor="#CC9966">
     <th colspan="2"><b>Summary</b></th>
 </tr>
 <tr bgcolor="#CCF3D0">
     <td>Total files checked</td>
     <td><xsl:number level="any" value="count(descendant::file)"/></td>
 </tr>
 <tr bgcolor="#F3F3E1">
     <td>Files with errors</td>
     <td><xsl:number level="any" value="count(descendant::file[error])"/></td>
 </tr>
 <tr bgcolor="#CCF3D0">
     <td>Total errors</td>
     <td><xsl:number level="any" value="count(descendant::error)"/></td>
 </tr>
 <tr bgcolor="#F3F3E1">
     <td>Errors per file</td>
     <td><xsl:number level="any" value="count(descendant::error) div count(descendant::file)"/></td>
 </tr>
    </table>
    <hr align="left" width="95%" size="1"/>
    <p>The following are violations of the Sun Coding-Style Standards:</p>
    <p/>
 xsl:apply-templates/
    </body>
  </html>
</xsl:template>

<xsl:template match="file[error]">
    <table bgcolor="#AFFFFF" width="95%" border="1" cellspacing="0" cellpadding="2">
 <tr>
     <th> File: </th>
     <td>
  <xsl:value-of select="@name"/>
     </td>
 </tr>
    </table>
    <table bgcolor="#DFFFFF" width="95%" border="1" cellspacing="0" cellpadding="2">
 <tr>
     <th> Line Number </th>
     <th> Error Message </th>
 </tr>
 <xsl:apply-templates select="error"/>
    </table>
    <p/>
</xsl:template>

<xsl:template match="error">
    <tr>
 <td>
     <xsl:value-of select="@line"/>
 </td>
 <td>
     <xsl:value-of select="@message"/>
 </td>
    </tr>
</xsl:template>

</xsl:stylesheet>

Die genannte Exception wird auch hier geworfen. Jetzt frage ich mich, was da nicht stimmt. Sieht mmN
definitiv nach einem Bug aus. Er beschwert sich definitiv über das version-Attribut im xsl:stylesheet.
Mit xsl:version="1.0" funktioniert es genauso wenig, seltsamerweise wird die gleiche Exception geworfen.

Fällt dir dazu noch was ein?
thx
kati