我有这个XML
<food>
<foodprice foodID="1" Price="10.0000"></foodprice>
<foodprice foodID="2" Price="20.0000"></foodprice>
<foodprice foodID="3" Price="30.0000"></foodprice>
</food>
<basket Name="Any1">
<vegetables foodID="1"></vegetables>
<vegetables foodID="2"></vegetables>
</basket>
<basket Name="Any2">
<vegetables foodID="1"></vegetables>
</basket>
<basket Name="Any3">
<vegetables foodID="1"></vegetables>
<vegetables foodID="3"></vegetables>
</basket>
<basket Name="Any4">
<vegetables foodID="2"></vegetables>
<vegetables foodID="3"></vegetables>
</basket>
现在,我为每个购物篮使用的变量和过滤器选择值
<xsl:template match="vegetables">
<xsl:variable name="vegId" select="@foodID"/>
<xsl:for-each select="/ROOT/food/foodprice[@foodID=$vegId]">
<xsl:value-of select="(/ROOT/food/foodprice[@foodID=$vegId]/@Price div count(/ROOT/Basket/vegetables[@foodID=$vegId]))"/>
</xsl:for-each>
</xsl:template>
结果是-
Any1
3,33
10
Any2
3,33
Any3
3,33
15
Any4
10
15
我的问题是,如何计算Any1 13,33; Any2 3,33; Any3 18,33; Any4 25
等的总和。
谢谢