Using templates, a key and exsl:node-set
I wrote
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common" exclude-result-prefixes="exsl">
<xsl:key name="by-name" match="SimpleFood" use="@name"/>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="FoodList">
<table>
<thead>
<tr>
<th>Name</th>
<th>Calories</th>
</tr>
</thead>
<tbody>
<xsl:apply-templates/>
</tbody>
</table>
</xsl:template>
<xsl:template match="SimpleFood">
<tr>
<td><xsl:value-of select="@name"/></td>
<td><xsl:value-of select="@calories"/></td>
</tr>
</xsl:template>
<xsl:template match="AggregateFood">
<tr>
<td><xsl:value-of select="@name"/></td>
<td>
<xsl:variable name="ing-cals">
<xsl:for-each select="IngredientList/Ingredient">
<cal><xsl:value-of select="key('by-name', @typeRef)/@calories"/></cal>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="sum(exsl:node-set($ing-cals)/cal)"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
which outputs
<html>
<body>
<table>
<thead>
<tr>
<th>Name</th>
<th>Calories</th>
</tr>
</thead>
<tbody>
<tr>
<td>Banana</td>
<td>50</td>
</tr>
<tr>
<td>IceCream</td>
<td>100</td>
</tr>
<tr>
<td>BananaSplit</td>
<td>250</td>
</tr>
</tbody>
</table>
</body>
</html>