> I would like to do some transformations on the xml file that the
> checkstyle plugin generates, before it's converted into HTML.

Well, seems I was to fast in sending the question.

Unfortunately, I had to make a bit of a kludge, since it's the same
goal in the checkstyle plugin that generates both
checkstyle-raw-report.xml and checkstyle-report.xml. Had these been
two different goals, I would not need to redo the <doc:jsl> step in
maven.xml. Oh well, perhaps I should quit my whining and submit a
patch! ;)

Here's my solution (for better or worse):
In my maven.xml I added the following:

        <postGoal name="checkstyle:report">
                <attainGoal name="removeUnwantedCheckstyleEntries"/>
        </postGoal>
        <goal name="removeUnwantedCheckstyleEntries" description="Remove bug
output from checkstyle report">
                <echo message="Removing unwanted Checkstyle entries..."/>
                ${systemScope.setProperty( 'javax.xml.transform.TransformerFactory',
                'org.apache.xalan.processor.TransformerFactoryImpl')} <j:set
                        var="inputFile" 
value="${basedir}/target/checkstyle-raw-report.xml"/>
                <echo message="infile: ${inputFile}"/>
                <util:available file="${inputFile}">
                        <echo message="Input file is present"/>
                        <ant:xslt in="${inputFile}" out="${inputFile}.tmp"
                                style="${basedir}/../../fixCheckstyle.xsl" 
processor="trax"/>
                        <ant:move file="${inputFile}.tmp" tofile="${inputFile}"/>
                        <doc:jsl input="${inputFile}"
                                output="checkstyle-report.xml"
                                
stylesheet="PATH_TO/.maven/plugins/maven-checkstyle-plugin-2.4.1/plugin-resources/checkstyle.jsl"
                                encoding="${maven.docs.outputencoding}" 
outputMode="xml"
prettyPrint="true"/>
                </util:available>
        </goal>

And I also created this XSL file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
        <xsl:template match="*">
                <xsl:copy>
                        <xsl:copy-of select="@*" />
                        <xsl:apply-templates />
                </xsl:copy>
        </xsl:template>
        <xsl:template match="error">
                <xsl:choose>
                        <xsl:when test="starts-with(@message,'Unable to get class 
information for')">
                                <xsl:apply-templates />
                        </xsl:when>
                        <xsl:otherwise>
                                <xsl:copy>
                                        <xsl:copy-of select="@*" />
                                        <xsl:apply-templates />
                                </xsl:copy>
                        </xsl:otherwise>
                </xsl:choose>
        </xsl:template>
</xsl:stylesheet>

I'm running JDK 1.4+ and did not need to add xalan, but you may need
to add the following dependecy:
<dependency>
        <id>xalan</id>
        <version>2.5.1</version>
</dependency>

Hope this helps someone out in the future.

-- 
// p�l brattberg
// eminds F/OSS div.
// http://www.eminds.se 

// Need google mail account? Ask me!

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to