Basically within your outer for-each the context node is ccc_code. To reach the aaa_code node you need the path
Code:
../parent::aaa_code
.
Here's a slightly more refined version that sorts the nodes as well, you may not need that part:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:key name="code_duplicate" match="ccc_code" use="@V" />
<xsl:template match="proced">
<xsl:for-each select="aaa_code/cat/ccc_code[count(. | key('code_duplicate', @V)[1]) = 1]">
<xsl:sort select="@V"/>
<xsl:value-of select="concat(@V, ' (', name(), ' value)' )"/><xsl:text>#xa;</xsl:text>
<xsl:for-each select="key('code_duplicate', @V)">
<xsl:sort select="../parent::aaa_code/@V"/>
<xsl:variable name="current" select="../parent::aaa_code"/>
<xsl:text>#x9;</xsl:text>
<xsl:value-of select="concat($current/@V, ' (', name($current), ' value)' )"/><xsl:text>#xa;</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
--
Joe (Co-author Beginning XML, 3rd edition)