CPD

4 views
Skip to first unread message

SPS

unread,
Oct 16, 2007, 12:57:46 PM10/16/07
to glean-code-users
I've been having problems getting CPD to work neatly within Glean.
Using windows XP, ant 1.7 and java 1.5.

Here's what I've done:

1) Added the below to toolhome.properties.local

# CPD is part of the PMD project.
cpd.home=${pmd.home}

2) To fix a transform error:

set ANT_OPTS=-Dfile.encoding=UTF-8

However, I still can't get the created html to correctly reference the
marked up java source (created by java2html14). The PMD html does
correctly reference the source.

I think the problem is that in this xsl fragment from cpd.xsl is
borked:

<xsl:template match="file">
<xsl:variable name="path" select="@path"/>
<xsl:variable name="line" select="@line"/>
<xsl:variable name="translated-path" select="translate(@path, '\',
'/')"/>
<xsl:variable name="linkpath" select="substring-after($translated-
path, $source-root)"/>
<tr>
<td class="file">Starting at <a href="{$context-root}/
{$linkpath}.html#{$line}">line <xsl:value-of select="@line"/></a> of
<xsl:value-of select="$linkpath"/></td>
</tr>
</xsl:template>

the value in 'linkpath' is just plain wrong- the substring-after isn't
correctly returning a local path, it's just set to an empty string.

Anyone have similar problems?

Paul

John Brugge

unread,
Oct 16, 2007, 1:34:10 PM10/16/07
to glean-co...@googlegroups.com
Paul,

What value do you have for "src.dir" (or "project.root") for your project? Does it have "\" backslashes in it? If so, try change it to forward slashes - "c:/path/to/my/project". The "translated-path" var in the CPD XSL is an attempt to make the path separator uniform in the path that is pulled out of the CPD output.

Perhaps what should really be done is to also handle the possible differences in the "source-root" var as well.


    <xsl:variable name="translated-path" select="translate(@path, '\', '/')"/>
    <xsl:variable name="translated-root" select="translate($source-root, '\', '/')"/>
    <xsl:variable name="linkpath" select="substring-after($translated-path, $translated-root)"/>

You might try that instead, and let me know if it works.

The PMD output doesn't have this problem because it only gives you a relative path; the CPD output is an absolute path that we need to extract the relevant bits from.

Thanks for the file encoding suggestion. What encoding is it using by default on your system?

John
Reply all
Reply to author
Forward
0 new messages