-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with CCM metric addition v2 #523
Comments
We tried to realize component connection algorithm in XSL, and got problem with variables reassign for visit checking.
|
@iMaks99 Let's say you have this XML: <root>
<a id="1">
<ref>2</ref>
<ref>4</ref>
</a>
<a id="2">
<ref>1</ref>
<ref>4</ref>
</a>
<a id="5">
<ref>3</ref>
</a>
<a id="3">
<ref>5</ref>
</a>
</root> Then, you need to find combinations of First, you create a function that recursively can turn element <xsl:template name="group">
<xsl:param name="x" as="element()"/>
<xsl:param name="seen"/>
<xsl:element name="group">
<xsl:attribute name="id">
<xsl:value-of select="$x/@id"/>
</xsl:attribute>
<xsl:for-each select="$x/ref">
<xsl:variable name="r" select="."/>
<xsl:if test="not($seen[@id=$r])">
<xsl:element name="e">
<xsl:value-of select="$r"/>
</xsl:element>
<xsl:call-template name="group">
<xsl:with-param name="x" select="/root/a[@id=$r]"/>
<xsl:with-param name="seen">
<xsl:copy-of select="$seen"/>
<xsl:copy-of select="$r"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:template> This code will produce something like this (unsorted!): <group id="1">
<e>2</e>
<e>1</e>
<e>4</e>
</group> Then, you need to collect all groups in a package, making sure each group is sorted inside: <xsl:template name="groups">
<xsl:param name="root"/>
<xsl:element name="groups">
<xsl:for-each select="$root/a">
<xsl:variable name="g">
<xsl:call-template name="group">
<xsl:with-param name="x" select="."/>
<xsl:with-param name="seen"/>
</xsl:call-template>
</xsl:variable>
<xsl:element name="group">
<xsl:for-each select="$g/e">
<xsl:sort select="."/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template> This will produce something like this (elements <groups>
<group id="1">
<e>1</e>
<e>2</e>
<e>4</e>
</group>
<group id="3">
<e>3</e>
<e>5</e>
</group>
</groups> The rest is easy, I believe. You just select unique groups. |
@yegor256 we made a transformation of data in skeleton:
and this data is storing as xsl:variable, how can we call templates above? |
@iMaks99 I'm not sure I understand the question (strongly recommend to use Stackoverflow for such questions), but I would do:
|
To fix the CCM metric, the FindConnectedComponents class was implemented to find the connected components in a graph:
This class needs to be implemented in jpeek , it needs to input the graph found in the file "org/jpeek/metrics/CCM.xsl". As a result of the FindConnectedComponents class we get the number of connectivity components of the graph, this data must be placed in the ncc variable in line 65 in the file "org/jpeek/metrics/CCM.xsl".
After that the problem with CCM metrics will be solved.
The text was updated successfully, but these errors were encountered: