Still not sure I've understood the entire problem but this might point you in the right direction, assuming your entryDetails are in xml like:
Code:
<entries>
<entryDetail>
<account>abc</account>
<amount>xxx</amount>
<measurableId>rs100</measurableId>
</entryDetail>
<entryDetail>
<account>abc</account>
<amount>xxx</amount>
<measurableId>rs200</measurableId>
</entryDetail>
<entryDetail>
<account>def</account>
<amount>xxx</amount>
<measurableId>rs300</measurableId>
</entryDetail>
<entryDetail>
<account>def</account>
<amount>xxx</amount>
<measurableId>rs200</measurableId>
</entryDetail>
<entryDetail>
<account>ghi</account>
<amount>xxx</amount>
<measurableId>rs100</measurableId>
</entryDetail>
</entries>
then the following shows how to group on measurableId, search the Web for Muenchian grouping for an explanation of how this works:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="entries-by-id" match="entryDetail" use="measurableId" />
<xsl:template match="/">
<html><head><title>Costs</title></head>
<body>
<table width="60%" align="center" border="1">
<caption>Entries Grouped By Id</caption>
<tbody>
<xsl:apply-templates/>
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="entries">
<xsl:for-each select="entryDetail[count(. | key('entries-by-id', measurableId)[1]) = 1]">
<xsl:sort select="measurableId" />
<tr><td><xsl:value-of select="measurableId" /></td><td>#xa0;</td></tr>
<xsl:for-each select="key('entries-by-id', measurableId)">
<xsl:sort select="account" />
<tr><td>#xa0;</td><td><xsl:value-of select="account" /></td></tr>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
To match up with the other xml you would need to use the document function to bring the inventory document into play and lookup the cost using the measurableId.
If you need more show your hoped for output and input documents that are valid xml.
--
Joe